Jenkins pipeline unable to ssh in to unix machine

Jenkins pipeline unable to ssh in to unix machine,jenkins,ssh,jenkins-pipeline,Jenkins,Ssh,Jenkins Pipeline,I am trying to set up a new jenkins pipeline. The problem I am facing is that: when jenkins pipeline is run, it cannot login to the unix box. But when I ssh in to jenkins box, and from there ssh in to the unix box - that works. On the jenkins pipeline it gets stuck when trying to login to the unix box and then the job has to be aborted. Any idea why ssh does not work from the pipeline but the exact same command works fine when I ssh in the jenkins machine? Sequence of commands: ssh -i jenki

I am trying to set up a new jenkins pipeline. The problem I am facing is that: when jenkins pipeline is run, it cannot login to the unix box. But when I ssh in to jenkins box, and from there ssh in to the unix box - that works. On the jenkins pipeline it gets stuck when trying to login to the unix box and then the job has to be aborted.

Any idea why ssh does not work from the pipeline but the exact same command works fine when I ssh in the jenkins machine?

Sequence of commands:

ssh -i jenkins.key jenkins@jenkinsServer
ssh serviceAccount@AnotherUnixBox 

This works. Logs serviceAccount in to AnotherUnixBox. But running same command in the pipeline does not work. Some of the commands tried:

ssh serviceAccount@AnotherUnixBox   
ssh -t -t serviceAccount@AnotherUnixBox 
ssh -t -t -o StrictHostKeyChecking=no serviceAccount@AnotherUnixBox 

sshAgent is installed and used in the script. I am using groovy dsl to build the pipeline.


#1

Problem resolved by: Had to add the public key of the of the unix server for the service account to the list of .ssh/authorized_keys for the service account. So here:

/home/apps/serviceAccount/.ssh

#2

does the jenkins user have one or more ssh keys to connect to the unix box?

#3

Yes, it has the ssh keys to connect to the unix box and the jenkins public key has been copied over to the unix box.

#4

very stupid question: did you try to setup a ~jenkins/.ssh/config defining what key and what user should be used? otherwise it'd help to add some verbosity to the ssh command. something like ssh -vvv unixBox in the command executed by the pipeline

#5

I think there's a misunderstanding and I think it's my mistake. When I wrote "very stupid question: I meant the next part I was going to write, not your question :) Sorry if it came in the wrong way.

#6

Got it @Stefano! I tried your suggestion. More verbosity helped. This is the the last line in the debug I see: debug1: read_passphrase: can't open /dev/tty: No such device or address