"No such file or directory" error when attempting to copy (using scp) from remote host to local machine
scp
does not require that you SSH to the remote computer in order to make the copy (and this is where you're currently running into trouble with your command).
scp essentially works in either a push or pull fashion. You can push files/folders from your local PC to a remote. The command syntax for this method is as follows:
scp /folderpath/tofile/file.txt user@remotehost:/folderpath/tocopyfileto/
Which will prompt you for the password of user
on remotehost
.
You can also pull file/folders from a remote PC to your local PC. The command syntax for this method is as follows:
scp user@remotehost:/folderpath/tofile/file.txt /folderpath/tolocalfolder/
Which will also prompt you for the password to user
on remotehost
.
The problem you were running into with your command above is that you were using the data pull syntax of the scp command in order to grab a file from a remotehost, but you were also SSH'd into that remotehost while running it.
The correct way to run this command is to run it from your local machine
scp -P 2222 [email protected]:/home4/user/public_html/website.com/folder_1/folder_2/file_to_copy.zip /Users/username/Desktop/
**Note that I removed the superfluous -r
from your original command. It's not something that will throw off an error, but it's just that it's not necessary in your case. The -r
option of scp
is to be used when recursively copying a folder and all its contents. In your case you were just copying a file so it wasn't necessary.
**I also added the -P 2222
since subsequent comments from you indicated that you needed to use port 2222 instead of standard port 22.