Newbie Unix tip: I don't normally do Unix tips (though there's no reason why I shouldn't), but I've tripped over this enough times that I should probably blog it to reduce the likelihood of tripping again later. scp lets you securely copy files between hosts over an ssh connection. When specifying remote filenames or directories that have characters that require shell escaping, such as names that contain spaces, you have to escape the characters twice: once for your local shell, and once for the remote shell.
scp "Source File" "user@remotehost.com:~/Destination File"
will result in:
scp: ambiguous target
because, despite the correct use of quotes to tell the shell that "...~/Destination File" is all one term, scp interprets the destination filename as two terms, "~/Destination" and "File". Additionally escaping the spaces in the remote filename within the quotes works as originally intended:
scp "Source File" "user@remotehost.com:~/Destination\ File"
Notice that local names (like "Source File") do not need to be double-escaped. [Update: fixed example.]
thanks for posting this. I found it on Google, cleared me up right away. It's a non-intuitive way of doing it, if you ask me, but I guess it makes sense...