Transfer files using scp: permission denied
I try to transfer files from remote computer using
sshto my computer :
scp My_file.txt [email protected]:/Home
This should put My_file.txt in the home folder on my own computer, right? I get
scp/Home: permission denied
Also when I try:
[email protected]:/Desktop, in order to copy the files from the remote computer to my desktop.
What am I doing wrong?
Your commands are trying to put the new Document to the root (
/) of your machine. What you want to do is to transfer them to your home directory (since you have no permissions to write to
/). If path to your home is something like
/home/ereztry the following:
scp My_file.txt [email protected]:/home/erez/
You can substitute the path to your home directory with the shortcut
~/, so the following will have the same effect:
scp My_file.txt [email protected]:~/
You can even leave out the path altogether on the remote side; this means your home directory.
scp My_file.txt [email protected]:
That is, to copy the file to your desktop you might want to transfer it to
scp My_file.txt [email protected]:/home/erez/Desktop/
or using the shortcut:
scp My_file.txt [email protected]:~/Desktop/
or using a relative path on the remote side, which is interpreted relative to your home directory:
scp My_file.txt [email protected]:Desktop/
As @ckhan already mentioned, you also have to swap the arguments, it has to be
scp FROM TO
So if you want to copy the file
My_file.txtfrom the server
[email protected]to your desktop you should try the following:
scp [email protected]:/path/to/My_file.txt ~/Desktop/
If the file
My_file.txtis located in your home directory on the server you may again use the shortcut:
scp [email protected]:~/My_file.txt ~/Desktop/
- I've tried: "~/" for 'Home' now, and also "~/Desktop/. Both resulted in : My_file.txt 100% 0 0.0 KB/s 00:00, and I cannot see the files in my folders. What am I still doing wrong ? Thanks a lot!
On your second command example, the `~` should be protected from evaluation so as to be evaluated on the remote host: `\~` for example.