.-- .. - .... .-.. --- ...- .

home archive about

How to scp a file with colon in its name

06 Feb 2012

As we know that scp is a command for secure copy, it copies file between remote hosts. Normally, we follow the below two examples to copy a file from/to localhost to/from a remote machine:

scp /path/to/filename [email protected]:/path/to/destination/directory/
scp [email protected]:/path/to/filename /path/to/local/directory/

These commands and their deformation usually work fine. But when I tried to scp a file to my VPS this afternoon. I encountered a problem:

scp file\:name [email protected]:
ssh: Could not resolve hostname example: Name or service not known

I Googled this problem for quite a while and finally found out that the culprit is the colon in the name of my file. The solution to this problem turns out to be very simple:

scp ./file\:name [email protected]:
scp /path/to/file\:name [email protected]:
Creative Commons License

comments powered by Disqus