To push a file from a Linux terminal to a Windows system, the following two examples work just fine.
scp /home/user.name/file.html user.name@local.ip.num:/C:/Users/user.name/test_folder/file.htmlscp /home/user.name/file.html user.name@local.ip.num:"/C:/Users/user.name/test_folder/file.html"
I need to do this where the local folder has spaces and I cannot change the name, say
/C:/Users/user.name/test folder/
All of the following fail with the message
scp: ambiguous target
scp /home/user.name/file.html user.name@local.ip.num:"/C:/Users/user.name/test folder/file.html"scp /home/user.name/file.html user.name@local.ip.num:"/C:/Users/user.name/test folder/file.html"scp /home/user.name/file.html user.name@local.ip.num:"'/C:/Users/user.name/test folder/file.html'"scp /home/user.name/file.html user.name@local.ip.num:"/C:/Users/user.name/test\ folder/file.html"scp /home/user.name/file.html user.name@local.ip.num:"'/C:/Users/user.name/test\ folder/file.html'"scp /home/user.name/file.html user.name@local.ip.num:"/C:/Users/user.name/test\ folder/file.html"scp /home/user.name/file.html user.name@local.ip.num:"'/C:/Users/user.name/test\ folder/file.html'"
How do I get this to work?
Solution:
Try using
quotes '
orDouble quotes "
around complete argument.As suggested by @dirkt in comments Quoting the complete path argument for the ssh host should do the work. That makes your command like this :
scp /home/user.name/file.html 'user.name@local.ip.num:/C:/Users/user.name/test folder/'
Use
escape sequence for space
in between name of folder.You can use
(backslash with a space) that is escape sequence for a space. That makes your command like this :
scp /home/user.name/file.html 'user.name@local.ip.num:/C:/Users/user.name/test folder/'
Notice the
with a space in between
test
&folder
that makes ittest folder
.It maybe the case that you
need to escape twice
as It is escaped first locally and then on the remote end. In that case you can write like this :"'complete argument'"
inside quotes within double quotes like this :"'user.name@local.ip.num:/C:/Users/user.name/test folder/'"
OR
Escape spaces and quote complete argument like this :
'user.name@local.ip.num:/C:/Users/user.name/test folder/'
OR
Escape twice directly using escape sequence like this
user.name@local.ip.num:/C:/Users/user.name/test\ folder/
Feel free to add-in more details.