ssh scp to copy file to remote server port 21

Discussion in 'Site & Server Administration' started by ska_defender, Aug 30, 2012.

  1. #1
    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
     
    Solved! View solution.
    ska_defender, Aug 30, 2012 IP
  2. #2
    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
     
    RoseHosting, Aug 31, 2012 IP
  3. cesurasean

    cesurasean Active Member

    Messages:
    269
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    80
    #3
    I can help you with this via skype - cesurasean is my screen name.
     
    cesurasean, Sep 26, 2012 IP
  4. RoseHosting

    RoseHosting Well-Known Member

    Messages:
    230
    Likes Received:
    11
    Best Answers:
    11
    Trophy Points:
    138
    #4
    As I can see the thread is marked as [solved] by the OP so I assume that this has already been resolved.
     
    RoseHosting, Sep 26, 2012 IP