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 Code (markup): 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
As a side note, port 21 is used for FTP by default not SSH. Anyhow, to specify specific port, as described in scp's man page one might use the '-P' switch. (see man scp | grep -A 3 -B 1 'port'). so the correct command would be: scp -P 21 -r /home/direc/file.tar username@secondhost:/home/dir/ Code (markup): you may also use rsync for this. For example: rsync -Waq -e 'ssh -p 21' /home/direc/file.tar username@secondhost:/home/dir/ Code (markup): HTH
As I can see the thread is marked as [solved] by the OP so I assume that this has already been resolved.