The Windows agent launched via SSH and on the agent we are having trouble executing SSH commands in a Jenkins pipeline.
Jenkins version: 2.452.1
Request you to help us to move forward.
The Windows agent launched via SSH and on the agent we are having trouble executing SSH commands in a Jenkins pipeline.
Jenkins version: 2.452.1
Request you to help us to move forward.
Could you share how you are invoking the ssh in the pipeline or if you are using any plugins.
Hi Markbosire,
Thanks for the reply. Here are the details.
Jenkins version: 2.462.3
SSH plugin version: 2.6.1
pipeline {
agent {
label “template-2019”
}
stages {
stage(‘Setup’) {
steps {
dir (‘test’) {
deleteDir()
}
}
}
stage(‘Build’) {
steps {
sleep 3
bat(“set”)
}
}
stage(‘Test’) {
steps {
echo ‘Testing..’
sleep 3
bat ‘’‘set TERM=xterm
C:\Windows\System32\OpenSSH\ssh.exe -vvv -F /Users/jenkins/.ssh/config -i /Users/jenkins/.ssh/id_rsa -t -o StrictHostKeyChecking=no XXXX@XXXXXXXXXX ls -ltra >bla 2>&1’‘’ }
}
stage(‘Deploy’) {
steps {
echo ‘Deploying…’
}
}
}
}
Please find the attached output of ssh & pipeline
(Attachment pipeline.output.txt is missing)
(Attachment ssh.out.txt is missing)
Jenkins.zip (13.3 KB)
Please find the attachment.
The pipeline seems to be running in a mixed Windows/Unix environment. Your bat command is trying to use /Users/jenkins/.ssh/config which appears to be a Unix-style path, but you’re running on a Windows agent.
The agent is running on template-MG24 in the output but your pipeline specifies template-2019. This mismatch might indicate configuration issues.
Windows paths should use backslashes or escaped backslashes. For SSH config and key files, try:
bat ‘’‘set TERM=xterm
C:\Windows\System32\OpenSSH\ssh.exe -vvv -F C:\Users\jenkins\.ssh\config -i C:\Users\jenkins\.ssh\id_rsa -t -o StrictHostKeyChecking=no XXXX@XXXXXXXXXX ls -ltra >bla 2>&1’‘’
Also Consider using the Jenkins SSH Steps plugin for cleaner syntax if available.
Also before executing complex commands, try a simple connection test:
bat “C:\Windows\System32\OpenSSH\ssh.exe -o StrictHostKeyChecking=no XXXX@XXXXXXXXXX echo Connection Successful”
Also check target server access: Ensure the target server allows SSH connections from your Jenkins agent and the user has appropriate permissions.