Cp: cannot stat : No such file or directory

centoscplinuxscp

I am getting an error when I try to copy a file from my local computer to a remote server. I get the same error whether I use cp or scp.

Here is my input at the resulting error:

[root@xxx.xx.xxx.xx /]# cp /home/username/some.xml root@xxx.xx.xxx.xx:/path/to/directory/  
cp: cannot stat ‘/home/username/some.xml’: No such file or directory

I have checked, and there is definitely a file at the path /home/username/some.xml on my local machine.

Both the local computer and the remote server are running CentOS 7. How can I resolve this error and copy successfully?

Best Answer

You have TWO problems.

A: you're apparently are on the machine you're trying to copy to, rather than the one you're trying to copy from

B: cp cannot transfer between machines.

To resolve A try

scp username@YYY.YYY.YYY.YYY:/home/username/some.xml /path/to/directory/
Related Question