6

I am reposting a slightly edited version of this Ask Ubuntu question SCP with two different ports, as the answer there that works with command-line options only (without modifying ssh_config) no longer works for me.

How can I use scp command to copy files between two remote servers that use different ports from my local PC?

Setup

  • remote server 1 : IP=67.12.21.133 & port=6774
  • remote server 2 : IP=67.129.242.40 & port=6775

Problem

  • If I use
    scp -rp -P 6774 [email protected]:/home/denny/testapp1.txt  [email protected]:
    
    it gives an error:
    ssh: connect to host 67.12.21.133 port 22: Connection refused
    
  • If I use
    scp -rp -P 6774 [email protected]:/home/denny/testapp1.txt -P 6775 [email protected]:
    
    it gives me this error:
    ssh: connect to host 67.129.242.133 port 6775: Connection refused  
    ssh: connect to host 67.129.242.40 port 6774: Connection refused  
    lost connection
    
0

1 Answer 1

7

Specify the ports in source and target URLs:

scp -3 scp://host1:port1//path/to/file  scp://host2:port2//path/to/file
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .