SCP from one external server to another

did you check that direct authentication works from first remote host to the second one?

scp user@host:/file user@otherhost:/otherfile is shorthand for

ssh user@host scp /file user@otherhost:/otherfile

which leeds me to think:

ssh -p XXX user@host scp -P XXX /file user@otherhost:/otherfile might work.


It seems like scp doesn't realize that the special port should also be used on the second server. You could try to explicitly call ssh to start the remote scp transfer:

ssh -P xxxx user@host scp -P xxxx /file user@otherhost:/otherfile

Define the servers in your .ssh/config file, for example:

Host foobar
User youruser
Port 2222
Hostname the.real.hostname

Host foobar2
User youruser
Port 2222
Hostname the2.real.hostname

You can then simply do:

scp foobar:file foobar2:

and it will use the defined custom ports.