When the user assumes `-p` does the same for scp as it does for ssh, funny things happen: touch myfile scp -p 22 myfile targetmachine:targetfile The above prints "scp: targetfile: No such file or directory", which, while true (there is no file called "targetfile" on the host -- the users intent was to put it there), is a very confusing error message. The problem here is that `-p` doesn't accept an argument for scp as it does for ssh, and so "22" is treated as a file name. It is the file "22" that doesn't exist. Let's touch ~/targetfile on `targetmachine`. What happens then? $ scp -p 22 myfile zh.nh2.me:targetfile scp: targetfile: Not a directory Certainly true, targetfile is not a directory. Nevertheless, not quite the error message the user would hope for. What if we make `targetfile` a directory then (`rm ~/targetfile && mkdir targetdir` on targethost)? $ scp -p 22 myfile zh.nh2.me:targetdir 22: No such file or directory myfile 100% 0 0.0KB/s 00:00 Finally an error message that points out what the user did wrong. Would it be possible to improve scp's error messages, such that for this very common error of using `-p` incorrectly, the earlier examples point out more helpfully to the user that "22" doesn't exist? Thanks!
It isn't possible to fix this generally without completely rewriting getopt() and we aren't prepared to do that, sorry.
Close all resolved bugs after release of OpenSSH 7.7.