Bug 1989 - SCP wihout a source path
Summary: SCP wihout a source path
Status: CLOSED WONTFIX
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: scp (show other bugs)
Version: 4.3p2
Hardware: All All
: P2 normal
Assignee: Assigned to nobody
URL:
Keywords: help-wanted
Depends on:
Blocks:
 
Reported: 2012-03-06 16:40 AEDT by cent9ur
Modified: 2015-08-11 23:04 AEST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description cent9ur 2012-03-06 16:40:45 AEDT
Hi,

I regularly use scp to copy files between hosts like this:

"scp -prv user@remotehost:/path/to/copy ."

However, today, I made a mistake and typed this instead:
"scp -prv user@remotehost: /path/to/copy ."

This started copying user@remotehosts $HOME to . on the local host I was on.

So I have now tried "scp -prv user@remotehost: ." which also copies $HOME to . on the local host. I did not know you could do this. I am under the impression that I must always include a path or at least a "/" after ":" as this is how I interpret the "file" in the man pages as it does not have "[]"

Additionally, if I use "scp -prv user@remotehost: /path/to/copy ." it starts writing everything to . instead of /path/to/copy.

Is this a bug?

System Profile:
"Linux myhostname 2.6.18-274.el5 #1 SMP Fri Jul 8 17:36:59 EDT 2011 x86_64 x86_64 x86_64 GNU/Linux"
Red Hat Enterprise Linux Server release 5.7 (Tikanga)
openssh-clients-4.3p2-72.el5_6.3
http://www.unix.com/unix-advanced-expert-users/178058-scp-wihout-source-path.html#post302603942
Comment 1 Damien Miller 2012-03-09 10:05:39 AEDT
No, this is not a bug.

The path after : is optional, with the default being the remote user's home directory. Consider "scp blah.txt user@host:"

For the case of "scp -prv user@remotehost: /path/to/copy .", it's doing exactly what you tell it: copying user@remotehost's home directory as well as /path/to/copy to your local home directory.
Comment 2 Damien Miller 2015-08-11 23:04:58 AEST
Set all RESOLVED bugs to CLOSED with release of OpenSSH 7.1