Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Copy file from remote to local using ssh

I'm trying to copy a file from a Ubuntu server to my mac but I keep receiving a No such file or directory error.

After I ssh in I'm using:

scp -p 8888 [email protected]:/var/www/html/00000001.jpg /Users/myusername/Documents/

But receive the error:

/Users/myusername/Documents/: No such file or directory

Is this error telling me that there is no such file or directory on my local machine? Any advice as to how to fix would be greatly appreciated.

like image 755
brandozz Avatar asked Feb 12 '16 01:02

brandozz


People also ask

How do you copy a file from a remote server to a local machine?

To copy the files you will need to first invoke the SCP, followed by the remote username@IP address, path to file. If you do not specify the path, it is assumed as default in this case which will be the user's home directory, this will be followed the path where the file will be stored locally.

Can I use SSH to copy files?

It's based on the SSH protocol used with it. A client can use an SCP to upload files to a remote server safely, download files, or even transfer files via SSH across remote servers.

How do I transfer files between local and SSH?

Often you will need to move one or more files/folders or copy them to a different location. You can do so using an SSH connection. The commands which you would need to use are mv (short from move) and cp (short from copy). By executing the above command you will move (rename) the file original_file to new_name.

How do I copy a remote folder to local?

Copy or Download a File From Remote to Local Using SCP SCP syntax is pretty simple. Just invoke SCP followed by the remote username, @, the IP address or host, colon, and the path to the file. If not specified, the default path is the remote user's home directory.


2 Answers

Don't ssh in to your server first. Just execute that scp command from your local machine.

EDIT:

Also, the -p should be capitalized (according to the manpage on my machine), so:

scp -P 8888 [email protected]:/var/www/html/00000001.jpg /Users/myusername/Documents/
like image 173
tokamak Avatar answered Oct 06 '22 22:10

tokamak


Yes, it's talking about your local machine. I'm guessing that you might have just typed something wrong. Try doing it like this instead:

scp -P 8888 [email protected]:/var/www/html/00000001.jpg ~/Documents/

Make sure you're typing this command at your Mac OS X Terminal prompt, not on the actual remote server. xx1.xx1.xx1.xx1 should be the remote Ubuntu machine ("pull" the file down to your machine, don't try to "push" it).

Also, although it's ssh -p, it's scp -P. For scp, -p just preserves modification times, and -P is the port.

like image 26
Will Avatar answered Oct 06 '22 20:10

Will