[Bug 2809] New: SCP gives very confusing / wrong error message when -p is used incorrectly

bugzilla-daemon at bugzilla.mindrot.org bugzilla-daemon at bugzilla.mindrot.org
Fri Dec 8 14:12:06 AEDT 2017


https://bugzilla.mindrot.org/show_bug.cgi?id=2809

            Bug ID: 2809
           Summary: SCP gives very confusing / wrong error message when -p
                    is used incorrectly
           Product: Portable OpenSSH
           Version: 7.5p1
          Hardware: Other
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P5
         Component: scp
          Assignee: unassigned-bugs at mindrot.org
          Reporter: mail at nh2.me

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!

-- 
You are receiving this mail because:
You are watching the assignee of the bug.


More information about the openssh-bugs mailing list