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
Solution 1:
Looks like you are trying to copy to a local machine with that command.
An example scp looks more like the command below:
Copy the file "foobar.txt" from the local host to a remote host
$ scp foobar.txt [email protected]:/some/remote/directory
scp "the_file" your_username@the_remote_host:the/path/to/the/directory
to send a directory:
Copy the directory "foo" from the local host to a remote host's directory "bar"
$ scp -r foo [email protected]:/some/remote/directory/bar
scp -r "the_directory_to_copy" your_username@the_remote_host:the/path/to/the/directory/to/copy/to
and to copy from remote host to local:
Copy the file "foobar.txt" from a remote host to the local host
$ scp [email protected]:foobar.txt /your/local/directory
scp your_username@the_remote_host:the_file /your/local/directory
and to include port number:
Copy the file "foobar.txt" from a remote host with port 8080 to the local host
$ scp -P 8080 [email protected]:foobar.txt /your/local/directory
scp -P port_number your_username@the_remote_host:the_file /your/local/directory
From a windows machine to linux machine using putty
pscp -r <directory_to_copy> username@remotehost:/path/to/directory/on/remote/host
Solution 2:
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
Solution 3:
In my case I had to specify the Port Number using
scp -P 2222 username@hostip:/directory/ /localdirectory/
Solution 4:
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