Reputation: 829
My jenkins is run in docker, I write a demo to remote my server with ssh-agent.
Here is my pipeline
pipeline {
agent any
stages {
stage('Hello') {
steps {
sshagent (credentials: ['hehu']) {
sh 'ssh -o StrictHostKeyChecking=no -l yunwei xxx.xxx.xx.25 -a'
sh 'pwd'
sh 'whoami'
}
}
}
}
}
It looks like pwd
and whoami
command still run in jenkins docker not my server. I have no idea how to use this plugin, I can't find any usage from ssh-agent
document.
Upvotes: 0
Views: 1621
Reputation: 11752
You should use:
sh 'ssh -o StrictHostKeyChecking=no -l yunwei x.x.x.x pwd && whoami && cmd...'
Upvotes: 1