Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download file to local computer via SCP while ssh connection to remote computer [closed]

Tags:

terminal

ssh

I keep getting an error when trying to download a file from a remote computer when connected via SSH.

I'm using a Mac and connecting via terminal.

I type the following:

scp username@host : /path/to/hosts/file/host_file.txt ~/desktop 

I then enter my password and get the following error:

scp: .: not a regular file cp: cannot create regular file '/host_file.txt': permission denied /directory/user/desktop: no such file or directory 

Any help?

It appears to be trying to save it to a directory on the remote system but I'm not sure.

**update:

I removed space on either side of the : It now appears to download but I don't see anything on my desktop.

Thanks for all your help.

like image 677
msmis88 Avatar asked Apr 02 '13 16:04

msmis88


People also ask

Can you SCP while SSH?

The scp command allows you to copy files over ssh connections. This is pretty useful if you want to transport files between computers, for example to backup something. The scp command uses the ssh command and they are very much alike.

How do I copy files from remote desktop to local desktop SCP?

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 you SCP from remote to local?

The scp command copies files or directories between a local and a remote system or between two remote systems. You can use this command from a remote system (after logging in with the ssh command) or from the local system. The scp command uses ssh for data transfer.

How do I download files from remote server to local?

Copy a Remote File to a Local System using the scp Command To copy a file from a remote to a local system, use the remote location as a source and local location as the destination. If you haven't set a passwordless SSH login to the remote machine, you will be asked to enter the user password.


1 Answers

Instead of

scp username@host : /path/to/hosts/file/host_file.txt ~/desktop 

remove the spaces surrounding the :.

scp username@host:/path/to/hosts/file/host_file.txt ~/desktop 

Edit:

I keep getting an error when trying to download a file from a remote computer when connected via SSH.

You shouldn't run the scp command when you are already sshed into the server --- that just downloads the file from the server... to the server.

You should run the scp command directly from your mac.

like image 94
dave4420 Avatar answered Sep 30 '22 03:09

dave4420