scp: copying filenames with colons

2008-07-19 Sat – 18:11:07

# annoying:

[jem:pgl]:~/p/misc_useful $ /usr/bin/scp scp\:copying-filenames-with-colons-in-them.txt localhost:/dev/null
ssh: scp: Name or service not known

# sorted:

[jem:pgl]:~/p/misc_useful $ /usr/bin/scp ./scp\:copying-filenames-with-colons-in-them.txt localhost:/dev/null
The authenticity of host ‘localhost (’ can’t be established.
RSA key fingerprint is 12:2b:3a:4e:be:6f:41:f2:20:4c:1b:ee:6a:46:35:61.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added ‘localhost’ (RSA) to the list of known hosts.
pgl@localhost’s password:
scp:copying-filenames-with-colons-in-them.txt 100% 0 0.0KB/s 00:00

Executive summary: filenames with :colons: break scp, unless they’re prefixed with a path.

Why: scp has no way of telling that a file called “file:name” is isn’t the user specifying host:path, which is the usual way it’s used. To disambiguate this for scp, prefix the filename with its path (either relative to your current directory, or a full path, it doesn’t matter); ie, instead of “scp filename:with:colons“, it’s “scp ./filename:with:colons“.

Sorry, comments for this entry are closed at this time.