0

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.

  • I think you need to send the commands to the remote server like in here http://stackoverflow.com/questions/4412238/whats-the-cleanest-way-to-ssh-and-run-multiple-commands-in-bash – KeepCalmAndCarryOn Jan 12 '15 at 04:10
  • 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 Jan 12 '15 at 06:56
  • I think so, if you have root access then you can `su - jenkins` and generate the keys – KeepCalmAndCarryOn Jan 12 '15 at 07:12
  • 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 Jan 12 '15 at 07:41

1 Answers1

0

Try to use Jenkins ssh plugin.

kkamil
  • 2,593
  • 11
  • 21