0
votes

I am trying to ssh to my deployment server to run a script using jenkins build server but it is giving error:

Started by user anonymous
Building in workspace /var/lib/jenkins/jobs/test/workspace
[workspace] $ /bin/sh -xe /tmp/hudson2847284723784326.sh
+ ssh user@serverIP
Pseudo-terminal will not be allocated because stdin is not a terminal.
Host key verification failed.
Build step 'Execute shell' marked build as failure
Finished: FAILURE

I am using Execute shell build utility in jenkins. Steps used are:

  1. ssh user@serverIP
  2. cd pathofscript
  3. ./script.sh

I can login manually in server without using password. I used this article to setup password less login : http://www.linuxproblem.org/art_9.html

Kindly let me know what am I doing wrong.

1
I think you need to send the commands to the remote server like in here stackoverflow.com/questions/4412238/… - KeepCalmAndCarryOn
I tried ssh user@serverIP /path/test.sh and it worked through my build machine but when I tried the same with jenkins it says: Host key verification failed. My builduser is different than jenkins. Do I need to generate ssh-keys for Jenkins also? - ankit bisaria
I think so, if you have root access then you can su - jenkins and generate the keys - KeepCalmAndCarryOn
Yes I logged in with jenkins user and followed the same link that I provided above and it resolved the issue. Thankyou for the help . - ankit bisaria

1 Answers

0
votes

Try to use Jenkins ssh plugin.