Ubuntu – ssh scp to copy file to remote server port 21

scp

I am trying to copy file from my server to another so I am using the following command:

scp root@myhost /home/direc/file.tar username@secondhost:/home/dir

I am getting the error:

ssh: connect to host secondhost port 22 connection timed out

I know it might be because port 22 is not open on second host

so How do I transfer by specifying port 21 on my second host

Best Answer

Try

scp -P 21 root@myhost /home/direc/file.tar username@secondhost:/home/dir

Where -P stands for port number.

Related Question