scp: ambiguous target
If you are transferring files from your host to another host and there are spaces in the path, you could get this error.
If there are spaces in the directory name of source (your system) and you have used double quotes in the path, you will not get the error but if there are spaces in the directory name of destination (remote host) and you have used double quotes in the path, you could still get the error.
To remove this error
Use backslash before spaces.
Suppose there is a directory "linux host" in the root of Remote Host and you want to transfer a file test.txt from your root directory to the remote host directory "linux host". You should use this command.
Now you will not get the error while file transfer.
If you put just double quotes in the remote host path and you do not put backslash before space, you will get the error scp: ambiguous target
One more example :
192.168.xx.xx is IP of Remote Host
If you are transferring files from your host to another host and there are spaces in the path, you could get this error.
If there are spaces in the directory name of source (your system) and you have used double quotes in the path, you will not get the error but if there are spaces in the directory name of destination (remote host) and you have used double quotes in the path, you could still get the error.
To remove this error
Use backslash before spaces.
Suppose there is a directory "linux host" in the root of Remote Host and you want to transfer a file test.txt from your root directory to the remote host directory "linux host". You should use this command.
# scp "/root/test.txt" 192.168.xx.xx:"/root/linux\ host"
Since there is space in the directory name "linux host" that's why I have used backslash before space.Now you will not get the error while file transfer.
If you put just double quotes in the remote host path and you do not put backslash before space, you will get the error scp: ambiguous target
One more example :
# scp "/root/Documents/file.txt" 192.168.xx.xx:"/root/untitled\ folder/red\ hat/linux\ host"
where192.168.xx.xx is IP of Remote Host