0

I've just come across a what I think is an odd behavior in scp. Consider the following:

root@box:~$ scp foo.txt [email protected]:
[email protected]'s password:
foo.txt: No such file or directory

I find it odd that I didn't get the no such file error before logging in to the remote server so, Is this a bug and if not why is this behavior desireable?

I'm running openssh-client version 1:6.7p1-5 on Debian Jessie.

3
  • 1
    scp's primary purpose is not to validate the existence of files, but rather secure file transfer, so it makes sense that it prioritizes making a secure connection, before file operations. I would recommend reading the RFC for SSH for a fuller understanding of the technical details of the protocol and it's reasons for working as it does.
    – Don Simon
    Jun 16, 2015 at 16:34
  • 2
    I think this is mainly a code efficiency issue actually. For this behavior to change scp would need to check if the file exists before creating the connection. When the connection is made there is still a chance that the file was already deleted. This means that a check before connecting is actually not needed. From a user experience point it might make sense to do it anyway....
    – Paul
    Jun 16, 2015 at 21:27
  • @Paul Many thanks, that makes sense. Could you put that into an answer?
    – nettux
    Jun 17, 2015 at 14:28

1 Answer 1

1

I think this is mainly a code efficiency issue actually. For this behavior to change scp would need to check if the file exists before creating the connection. When the connection is made there is still a chance that the file was already deleted. This means that a check before connecting is actually not needed. From a user experience point it might make sense to do it anyway....

You must log in to answer this question.

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