Deployment with Rsync

How do you do this when using a non-standard port? I have tried 'ssh -p 2200' and no luck, no matter what i do it still try's to connect on port 22 which is disabled on our server. 

My current script: ( Please point out any potential errors that I may have)

(running as inline-script)

rsync -avv --delete 'ssh -p 2200' ./ user@destination:/home/user/public_html/awesomeWebsite
I have also tried to use rsync over SSH with the following;
rsync -avv --delete --exclude='/home/user/public_html/awesomeWebsite/assets' --exclude=".*" ./public_html/awesomeWebsite/* /home/jecourte/public_html/awesomeWebsite/

The build process is a success here but it tells me everything is up to date, which my thinking is that maybe its only trying to rsync the same folder on the destination host?

Please help, this is driving me crazy!!!

After trying the -rsh 'ssh -p 2200' I know get this;
15-Jul-2015 15:02:33Could not create directory '/home/Bamboo/.ssh'.
15-Jul-2015 15:02:33Host key verification failed.
15-Jul-2015 15:02:33rsync: connection unexpectedly closed (0 bytes received so far) [sender]
15-Jul-2015 15:02:33rsync error: unexplained error (code 255) at /usr/src/ports/rsync/rsync-3.0.9-1/src/rsync-3.0.9/io.c(605) [sender=3.0.9]



Sorry, it won't let me respond anymore with comments (it says I'm over the 24 hour limit for new users)

Is there a way to disable the cause of Host key verification failed. 

Also since I'm doing a script where am I supposed to actually input the credentials? Will the shared credentials on bamboo be enough so that I can connect?

@David - No offense taken. My issue is that everything is ran through Atlassians Bamboo website so I have no way to access the server. The build servers are one of many on amazon S3. Maybe I'm missing something but I am not bridging the gap between where I can get the key to sit and how to pass those things into the script that I'm running during my build process.

5 answers


--rsh='ssh -p 2200'


I also do this for my own deployments, though you could just put the private key somewhere bamboo can access, instead of embedding them as a script line. The sed stuff at the end just reformats the single line string of the private key, into the acceptable format file that SSH expects.


echo "-----BEGIN RSA PRIVATE KEY----- MIIa...== -----END RSA PRIVATE KEY-----" | sed -e "s/- /-\n/" | sed -e "s/= /=\n/" | sed -e "2s/ /\n/g" > ${}/tmpkey

chmod 0600 ${}/tmpkey
--rsh='ssh -p 22022 -i ${}/tmpkey'
15-Jul-2015 14:37:08ssh: connect to host port 22: Connection timed out
15-Jul-2015 14:37:08rsync: connection unexpectedly closed (0 bytes received so far) [sender]
15-Jul-2015 14:37:08

rsync error: unexplained error (code 255) at /usr/src/ports/rsync/rsync-3.0.9-1/src/rsync-3.0.9/io.c(605) [sender=3.0.9]


It still shows port 22 even with the flag to change the port to 2200

did you change the 'ssh -p 2200' part so the command looks more like: rsync -avv --delete --rsh='ssh -p 2200' ./ user@destination:/home/user/p.... ?

I'm glad the port issue is solved for you now. Regarding host key verification, ssh attempts to save the host's identity in a file called known_hosts in the hidden .ssh directory of the user running the command. For bamboo, its the bamboo user, hence the /home/Bamboo reference. The quickest way to get this going is to log into the bamboo server as the bamboo user, and ssh to the machine you want to deploy to. If you can do that, then just replicate the switches you need into the rsync command. If you can't do that, you'll have to use additional ssh command line switches to disable the host key verification and other possible checks.

Ahhh... you're using the cloud instance version. Well, that may change how you handle it. I'm only using Atlassian software on my own servers, hence my answers before are from that viewpoint. The method I'm using in my answer below *may* work for you, but it relies on being able to save a file somewhere so that command line ssh can read it. You may want to send a request to support to find out what read/write abilities you have as the bamboo user of a cloud instance. Make sure you reference this question here so they have a good idea of what you're trying to do. I'm sure you aren't the first to attempt to do this.

Suggest an answer

Log in or Sign up to answer
Community showcase
Asked Thursday in Jira Ops

I'm John Allspaw, Ask Me Anything about incident analysis and postmortems

I'm John Allspaw, co-founder of   Adaptive Capacity Labs, where we help teams use their incidents to learn and improve. We bring research-driven methods and approaches to drive effective inciden...

4,408 views 20 13
View question

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you