Download file on Linux Ubuntu Server using SCP
Linux server is very efficient to manage files and processes. Sometimes you need to take backup of files or need to download code to modify locally. In linux server to download files either you use ftp or scp. SCPstands for Secure copy protocol, that is a means of securely transferring computer files between a local host and a remote host or between two remote hosts. Here we are providing all the way to transfer files from the Linux server to Local Computer.
The basic command structure is as follow:
scp <Server Username>@<Host>:<Path of Server File> <Local File>
Now take some different type of examples for different situations to upload file on the server.
1. Download a single file
scp firstname.lastname@example.org:/home/ubuntu/myfiles/sample.txt ~/Desktop
Here you will be asked for the password of the server.
2. Download a Directory or Folder
scp -r email@example.com:/home/ubuntu/myfiles ~/Desktop/myfiles
Here myfiles is a directory and I have added -r for recursive file transfer.
3. Server SSH have different port
scp -r -P 9001 firstname.lastname@example.org:/home/ubuntu/myfiles ~/Desktop/myfiles
Here -P 9001 is for the specified port.
4. The server has a Private Key File like pem or ppk to connect
scp -r -P 9001 -i ~/Desktop/server.pem email@example.com:/home/ubuntu/myfiles ~/Desktop/myfiles
Here server.pem is my Private Key file to authenticate the server.
5. Download in the current directory local computer
scp -r -P 9001 -i ~/Desktop/server.pem firstname.lastname@example.org:/home/ubuntu/myfiles .
Here I have used . for the local address to locate the working directory
If you have any other situation to download file on the Linux server then comment us the situation.
To upload files read the article:
Upload file on Linux Ubuntu Server using SCP