Bug 2020

Summary: Remote-to-remote copying doesn't work when second host not on port 22
Product: Portable OpenSSH Reporter: Daniel Kullmann <daniel.kullmann>
Component: scpAssignee: Assigned to nobody <unassigned-bugs>
Status: CLOSED INVALID    
Severity: normal CC: dtucker
Priority: P2    
Version: 6.0p1   
Hardware: All   
OS: All   

Description Daniel Kullmann 2012-06-21 17:46:14 AEST
It is not possible to specify a different port for the second remote host in a scp command line, e.g.

scp -P 3434 host1:file -P 8765 host2:file

is not possible, because the second -P is in an illegal position.

This would not be bad if the port could be specified in another way, but scp does not use the Port setting in .ssh/config for the second host. It does use the setting for the first host, though.
Comment 1 Darren Tucker 2012-06-21 19:44:01 AEST
Actually it *is* looked up in ~/.ssh/config, but on the remote host.

By default, scp remote1:foo remote2:bar actually runs "ssh remote1 scp foo remote2:bar" (this is behaviour inherited from rcp).

You need to either put the port number in the config file on the remote host, or use scp's "-3" option to do a 3-way copy which will use the local config file.
Comment 2 Daniel Kullmann 2012-06-21 23:58:30 AEST
OK, thanks for clearing that up.
Comment 3 Damien Miller 2015-08-11 23:04:24 AEST
Set all RESOLVED bugs to CLOSED with release of OpenSSH 7.1