executing RSYNC command in jenkins
Solution 1
Well I replaced the know_host files but I was still having issues. so for anyone that has issues with the know_host file you would fix the offending key by doing a:
ssh-keygen -R hostnameOfOfendingKey
and this will remove the ofending key and now your known_host file is working again.
NOW to resolve the other issue I found the answer in this other place: https://stackoverflow.com/questions/25755418/executing-rsync-in-jenkins/25770519#25770519
and This was what I did to solve it
sudo su jenkins -s /bin/bash
then once as jenkins user copy my ssh key to the server I want to connect/execute commands in, etc
ssh-copy-id [email protected]
it then will present you this
[email protected]'s password:
Now try logging into the machine, with "ssh '[email protected]'", and check in:
.ssh/authorized_keys
to make sure we haven't added extra keys that you weren't expecting.
then I did this for testing purposes:
bash-4.1$ rsync -PSauve ssh --exclude=JenkinsBuild /srv/pd/* [email protected]:/srv/pdc/test1
and it passed without asking for password or anything. Notice that I'm still log as jenkins.
So now when I created the Jenkins job with some shell commands as part of the build it will work as expected :D
Solution 2
Host key verification failed.
The account running jenkins likely has a bad value for the host key for the machine you are sshing to in ~/.ssh/known_hosts.
Solution 3
I had a similar problem.
In my case jenkins was not executing rsync with the expected user (jenkins) but with another (jboss in my case)
adding 'whoami
' to the script and using ssh verbose:
rsync -e "ssh -v" .......
helped to find the problem.
Related videos on Youtube
JAT2007
Full Stack Engineer, Always learning new stuff... love JS and everything related to it Always looking for ways to evolve
Updated on September 18, 2022Comments
-
JAT2007 over 1 year
I'm trying to deploy my code to a remote server. So far I've tried
- Publish over SSH Plugin: the problem is that I'm unable to keep file permissions
- Rsync command: this keeps the file permissions, but the problem is that I don't know how to set the password for it to work automatically
This is what I get:
[JenkinsBuild] $ /bin/sh -xe /var/lib/jenkins/tmp/hudson4646064064846581974.sh + rsync -PSauve ssh --exclude=JenkinsBuild app bower.json config gruntfile.js karma.conf.js LICENSE.md Makefile node_modules package.json Procfile protractor.conf.js public README README.md server.js [email protected]:/srv/dp/prod Host key verification failed. rsync: connection unexpectedly closed (0 bytes received so far) [sender] rsync error: unexplained error (code 255) at io.c(600) [sender=3.0.6]
Any ideas what I'm doing wrong here?
-
JAT2007 over 9 yearsthanks this gave me a hint on what was wrong, and since I don't have enough points I can't give you a +1