[scp] scp files from local to remote machine error: no such file or directory

I want to be able to transfer a directory and all its files from my local machine to my remote one. I dont use SCP much so I am a bit confused.

I am connected to my remote machine via ssh and I typed in the command

scp name127.0.0.1:local/machine/path/to/directory filename

the local/machine/path/to/directory is the value i got from using pwd in the desired directory on my local host.

I am currently getting the error

No such file or directory

This question is related to scp

The answer is


As @Astariul said, path to the file might cause this bug.
In addition, any parent directory which contains non-ASCII character, for example Chinese, will cause this.
In that case, you should rename you parent directory


i had a kind of similar problem. i tried to copy from a server to my desktop and always got the same message for the local path. the problem was, i already was logged in to my server per ssh, so it was searching for the local path in the server path.

solution: i had to log out and run the command again and it worked


In my case I had to specify the Port Number using

scp -P 2222 username@hostip:/directory/ /localdirectory/

You also need to make sure what is in the .bashrc file of the user.

I've also got this ridiculous error because I put cd and ls commands in there, as it was mean to let them see the current files & directories when the user is has logged in from ssh.


The filename should go at the end of the path to the directory. That is, it should be the full path to the file. You are doing this from a command line, and you have a working directory for that command line (on your local machine), this is the directory that your file will be downloaded to. The final argument in your command is only what you want the name of the file to be. So, first, change directory to where you want the file to land. I'm doing this from git bash on a Windows machine, so it looks like this:

cd C:\Users\myUserName\Downloads

Now that I have my working directory where I want the file to go:

scp -i 'c:\Users\myUserName\.ssh\AWSkeyfile.pem' [email protected]:/home/ec2-user/IwantThisFile.tar IgotThisFile.tar

Or, in your case:

cd /local/path/where/you/want/the/file/to/land
scp [email protected]:/local/machine/path/to/directory/filename filename

Your problem can be caused by different things. I will provide you three possible scenarios in Linux:

  • The File location

When you use scp name , you mean that your File name is in Home directory. When it is in Home but inside in another Folder, for example, my_folder, you should write:

scp /home/my-username/my_folder/name [email protected]:/Path....
  • You File Permission

You must know the File Permission your File has. If you have Read-only you should change it.

To change the Permission:

As Root ,sudo caja ( the default file manager for the MATE Desktop) or another file manager ,then with you Mouse , right-click to the File name , select Properties + Permissions and change it on Group and Other to Read and write .

Or with chmod .

  • You Port Number

Maybe you remote machine or Server can only communicate with a Port Number, so you should write -P and the Port Number.

scp -P 22 /home/my-username/my_folder/name [email protected] /var/www/html

If you want to copy everything in a Folder + have a special Port use this one. Works for me on Ubuntu 18.04 and a local machine with Mac OS X.

-r for recursive
-P for Port

scp -rP 1234 /Your_Directory/Source_Folder/ [email protected]:/target/folder

Be sure the folder from where you send the file does not contain space !

I was trying to send a file to a remote server from my windows machine from VS code terminal, and I got this error even if the file was here.

It's because the folder where the file was contained space in its name...