setting up ssh for Jenkins to use at runtime

jenkins, ssh

Solution

Ssh is asking for password either because the key is not valid or the key is protected by a passphrase.

Try the key by running the same command yourself to find out which problem you need to solve.

If the key is protected by a passphrase, you should probably remove the passphrase because there is no good way to input the passphrase in a Jenkins job. You can do it with `ssh-keygen -p -f /path/to/key/file`. Set an empty passphrase to remove passphrase.

When you use ssh command in a non-interactive build job, you should probably use option `-o BatchMode=yes`. You might also want to use `-o StrictHostKeyChecking=no`, unless you can do the first login interactively and accept the host key.

Problem

I need some Jenkins jobs to have shell command line access to some other machines via ssh. How can I do this? I do not have the password of the target server[s], but I have a 'key' file, but when I run a job with the following ``` ssh -i /path/to/key/file name@someserver some_command ``` as a shell command, I get the following: ``` ssh_askpass: exec(/usr/bin/ssh-askpass): No such file or directory ``` ssh_askpass is a GUI utility which I nor the Jenkins user has access to. I don't have the password to the Jenkins user (or whatever Jenkins runs as), so I cannot log in and create an ~/.ssh/id_dsa file. What to do? Thanks.

Original source