简体   繁体   中英

Jenkins slave using an ssh gateway

I have jenkins running on master.com , and want to have a slave running on slave.com . However, to ssh to the slave I need to go through gateway.com . Generally to ssh to this machine from my normal account, I just use ~/.ssh/config to set up a ProxyCommand.

I have replicated this setup in my /var/lib/jenkins/.ssh/config file:

Host slave.com
 User felix
 ProxyCommand ssh felix@gateway.com nc %h %p

I have public key authentication set up for both the gateway and the slave, such that from the command line I can ssh directly from jenkins@master.com to felix@slave.com simply by doing ssh slave.com .

Unfortunately Jenkins does not seem to respect my .ssh/config setup, and the connection times out (the slave is not reachable directly). The Jenkins slave log file is:

java.io.IOException: There was a problem while connecting to slave.com:22
....
Caused by: java.net.ConnectException: Connection timed out

How can I figure out whether or not jenkins is respecting my .ssh/config file? Am I missing a step in configuring the master jenkins account or the .ssh/config file for jenkins?

Instead of using Jenkin's built in SSH implementation, use the "Launch slave by execution of command on the Master". You can then use the regular ssh command, and take advantage of .ssh/config like you're used to. If you click the ? button next to the option, it should give you all the details you need.

The jenkins-ssh-slaves plugin uses the trilead SSH2 implementation written in Java.

~/.ssh/config is only read by OpenSSH , and won't affect how Jenkins connects to your slaves.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM