Bug 3541

Summary: remote-to-remote case doesn't look at sshport
Product: Portable OpenSSH Reporter: Edward Jones <tractorboy>
Component: scpAssignee: Assigned to nobody <unassigned-bugs>
Status: NEW ---    
Severity: minor    
Priority: P5    
Version: 9.1p1   
Hardware: Other   
OS: Linux   

Description Edward Jones 2023-02-17 04:55:37 AEDT
I tried to create a PR on Github but couldn't push. Is it restricted to certain collaborators? Would have been nice for me to raise a PR for this with a fix :).

Anyway, for OpenSSH8.0 (7.4 worked fine), the -P argument gets dropped. "-o Port=" works fine as a workaround. As does specifying the port number in a URI

Here's my command with the first line of debug output (don't think the "-4" is valid that's just what I happened to be using)

> scp -v -4 -i /users/<me>/.ssh/<private key> -P 28001 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ConnectTimeout=10 -o LogLevel=DEBUG root@localhost:/<path to file> <me>@<remote ip>:<dest dir>
Executing: /usr/bin/ssh -x -oClearAllForwardings=yes -t -v -4 -i /users/<me>/.ssh/<private key> -p 28001 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o ConnectTimeout=10 -o LogLevel=DEBUG -l root -- localhost scp -v <path to file> <me>@<remote ip>:<dest dir>


It looks like at https://github.com/openssh/openssh-portable/blob/master/scp.c#L1160 you need to set sport to sshport if sshport is valid (and sport is invalid? Not completely on top of that)
I'm not sure why that case is not calling do_cmd/do_cmd2 (which do correctly consider sshport)