Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to a SCP on my local server that copies a file from one remote server to another remote server (Both remote servers use a custom port (xxxx)

I am trying:

scp -r -P xxxx

But i get the following error:

ssh: connect to host port 22: Connection timed out

Any suggestions?

Thanks in advance.

share|improve this question
Cross posted here:… – Dennis Williamson Nov 5 '09 at 11:54
up vote 7 down vote accepted

I ended up doing the following:

ssh -p xxxx "scp -r -P xxxx /home/myimages/images.tar.gz"

An SSH followed by an SCP.

share|improve this answer
I agree, +1 for the solution as it avoids data transferring down from server 1 and up to server 2 (2 transfers instead of 1 as suggested) – drAlberT Nov 5 '09 at 10:22
what I was going to write, then forgot about the page :) – warren Nov 5 '09 at 11:38
ssh 'tar cf - /home/myimages/images.tar.gz' | ssh 'tar xf -'

Ssh-pipes are extremely useful. Learn and love them!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.