Download Files from Ubuntu Server Using SFTP

Secure File Transfer Protocol (SFTP) is a secure and efficient way to transfer files between a remote Ubuntu Linux server and your local machine. This guide provides a straightforward, step-by-step walkthrough on how to connect to your server and download files using the SFTP command-line interface.

Step 1: Connect to the Remote Server

Open the terminal on your local machine (Linux, macOS, or Windows Git Bash/PowerShell) and run the following command to establish an SFTP connection:

sftp username@your_server_ip

Replace username with your actual Ubuntu server username and your_server_ip with your server’s IP address or domain name. If you use a non-standard SSH port, add -P followed by the port number:

sftp -P 2222 username@your_server_ip

Enter your password or SSH key passphrase when prompted. Once connected, your terminal prompt will change to sftp>.

Step 2: Navigate and Locate Your Files

Before downloading, you need to navigate to the directory containing the file on the remote server, and optionally set the target folder on your local machine.

Step 3: Download the File

To download a file from the remote Ubuntu server to your local machine, use the get command followed by the filename:

get filename.ext

If you want to download the file and rename it during the transfer, specify the new name as the second argument:

get filename.ext new_local_filename.ext

To download an entire directory recursively, use the -r option:

get -r remote_directory_name

Step 4: Disconnect from SFTP

Once your file transfer is complete, close the SFTP connection by typing:

bye

Or alternatively:

exit