How to Run SCP when Copying From a Machine not using the Default SSH Port 21 CodeUnit 22 JAN 2011

Although port 21 is the default port used for SSH connections and thus SCP, most of the time you will find that in order to increase protection, the actual assigned port is far removed from the default 21. So how do you specify this when running a SCP copy operation?

Well SSH has the lowercase -p switch that allows you to specify which port to attempt to connect on, looking like this in practice:

ssh -p 6188

However, SCP for some or other reason (most likely due to the prevalence of using -p as a password switch elsewhere in Linux) does not use the lowercase -p to specify port, opting rather to make use of a capital -P to specify the port to use.

This means your SCP call would look like this:

scp -P 6188 /home/file

And now you know. Nifty.

Related Posts:

About Craig Lotter

Software developer, husband and dad to two little girls. Writer behind An Exploring South African. I don't have time for myself any more.