How can I copy files with SSH?
I am trying to copy a file from my other computer, to another computer. (both running Ubuntu 9.10)
So, I've ssh'ed into the other computer; I cd
to the directory; and I entered cp File.zip /home/me/Desktop
as file.zip
is located in the directory I just used cd
with.
Now, it gives me the following error message:
cannot create regular file '/home/me/Desktop': no such file or directory
What do I have to do?
Solution 1:
This isn't really programming related, but you can use scp to do this.
scp file.zip remote-box-name:/path/to/destination/file.zip
If your username is different on the remote box, you will need to prefix it:
scp file.zip yourusername@remotebox:/path/to/destination/file.zip
And to retrieve a file you could do this:
scp remotebox:/path/to/destination/file.zip file.zip
Solution 2:
On machine A, open two terminal windows
On machine A, ssh to machine B. Look around, find the path on machine B to the file you wish to copy
On machine A, the second terminal window type:
scp yourusername@remotebox:/path/to/destination/file.zip /home/me/Desktop
The file should be copied from machine B to machine A, in to the /home/me/Desktop folder (if the folder exists on Machine A
You can't copy over the existing ssh session. You need to create a second session. As others have noted:
yourusername
is for Machine B, and is only needed if the username for Machine B is different than on Machine Aremotebox
can be a resolvable name or an IP address
Alternatives:
- Places -> Connect to Server, and then select Service Type of SSH from the pulldown menu of the Connect to Server dialog box