[Linux] How to Download Files and Folders from Remote Server
To use scp
to download a file from a remote server to your local machine, you can use the following syntax:
scp username@host:/path/to/remote/file /path/to/local/destination
This will download the file located at /path/to/remote/file
on the remote server, and save it to /path/to/local/destination
on your local machine.
You will need to replace username
with your username on the remote server, host
with the hostname or IP address of the remote server, and /path/to/remote/file
and /path/to/local/destination
with the actual paths to the remote file and the local destination, respectively.
If the remote server requires you to use a specific port to connect, you can use the -P
flag to specify the port, like this:
scp -P portnumber username@host:/path/to/remote/file /path/to/local/destination
Replace portnumber
with the actual port number that you need to use to connect to the remote server.
If you want to download a folder from the remote server, you can use the -r
flag to tell scp
to download the folder and its contents recursively. For example:
scp -r username@host:/path/to/remote/folder /path/to/local/destination
This will download the /path/to/remote/folder
and all of its contents, including any subdirectories and files, and save it to /path/to/local/destination
on your local machine.
Note: scp
requires that you have an SSH connection to the remote server. If you don’t have an SSH connection, you can use the ssh
command to establish one before running the scp
command.
If this post helped you to solve a problem or provided you with new insights, please upvote it and share your experience in the comments below. Your comments can help others who may be facing similar challenges. Thank you!