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.
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With