average guy
average guy

Reputation: 103

setting up ssh for Jenkins to use at runtime

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.

Upvotes: 7

Views: 23977

Answers (3)

Synthetic Meshwork
Synthetic Meshwork

Reputation: 31

I had not installed the bin file ssh-askpass, so there is No such file or directory... I needed to install it.

Linux: sudo apt-get install ssh-askpass

Upvotes: 3

vatsal
vatsal

Reputation: 3933

Do not try to ssh directly into the remote machine by putting the command in the "Execute Shell" field. Instead use the SSH plugin or Publish Over SSH plugin. You wont have to generate keys for the jenkins user. It will work out of the box.

Upvotes: 1

sti
sti

Reputation: 11075

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.

Upvotes: 14

Related Questions