10.10.06

Copying files with colons using scp or rsync


OpenSSH
Seems that there's a lot of people out there that do not know how to copy a file with a colon in it's name (for example a:a.txt) using scp or rsync, so here's an explanation:

The trick is to know where you're using the : character. If it's a remote file there's no problem and no need of escaping since you preceded already by an :. Example:

scp me@my.machine.com:a:a.txt .

If it's a local file you just have to say it explicitly by expressing a path. Example:

scp ./a:a.txt me@my.machine.com:

This works for me at least on OpenSSH 4.3.