scp different ssh port

scp different ssh ports (one or two different ports)

You can use

to specify the ports to use for the hosts (and for setting many other nice things; check the man page


When doing this, you have to use the option

to scp, which copies the files through your local machine. Otherwise, scp issues the scp command via ssh on the first host, so it actually runs

and then the ~/.ssh/config of the first remote host ( is used instead of your local one.

When you have setup your

correctly, this should work:

Of course, you can also copy the contents of the ~/.ssh/config file onto your first remote host, and then you can use scp without the

option, which will probably speeden up the transfer.

Or you can use the trick that scp uses and use such a command line:

(Note the different case of the port parameter for ssh and scp:



PS: I got this information from the OpenSSH bugzilla where I entered this as a bug:



Leave a Reply