Search code examples
copylocalhostscpremote-server

scp from local to remote - "no such file or directory"


I am attempting to copy a local file to a remote server using scp on my macbook.

I am continuously getting the error "no such file or directory" when I know the file exists(I have checked and rechecked the path). The file has file rwx privileges for u,g and o. The file is not a symlink.

The syntax I am using is:

scp a2.pdf username@remoteserver:~pathto/directory/

The file a2.pdf is in the root directory of my local machine. I have also copied the path exactly as it shows when I use pwd in the directory it is contained it so like this:

scp Users/LocalUsername/a2.pdf username@remoteserver:~pathto/directory/

I am initiating this command while logged into the remote server. The error is given for the local path.

If I attempt to specify localhost information as such:

scp username@localhost:a2.pdf remoteusername@remoteserver:~~pathto/directory/

The prompt I get is to give my localhost password. I try my mac password and I am given permission denied. I am not sure how to move on from this and any advice would be very much appreciated.


Solution

  • I ran the command from my local machine instead and that fixed the problem. In the local file, I gave the command scp file.txt [email protected]: