Easily Download / Upload File from/to remote Ubuntu, Debian Server

Want to backup your data from remote Linux server to local machine, or upload something to the server? It’s quite easy to do the job even if your server provider does not offer a graphical interface.

Option 1: Download from Linux server via a temporary http service

The most efficient way to grab file from Linux server could be creating a temporary HTTP server, using the pre-installed Python language.

NOTE: This method is ONLY recommended for small and unimportant files (generally less than 1 GB).
  1. First, connect to your remote server either via SSH or other ways that you favorite.
  2. Then, run command in server side to navigate to the folder (e.g., backup) that contains the data you want to download.
    cd backup
  3. Finally, create a temporary http server via command:
    python3 -m http.server 8993

Change the number 8993 if it’s already in use. Then, visit http://server-ip:8993 in anywhere via a web browser to access the files in server and right-click save as to download them.

setup temporary http server in Linux server

IMPORTANT: After downloading, you MUST have to disable this http server by pressing ‘Ctrl+Z’ in server console!

Option 2: Use scp command to transfer data between local and Linux server

The previous method is easy but NOT security for important data. So, here’s another way to do the job via scp (OpenSSH secure file copy).

1. Install SSH server

If you’re connecting to remote Linux server using ssh command, then you can just skip this step.

Or, run command in server side to install openssh server:

sudo apt install openssh-server

And, make sure the service is running via:

sudo systemctl enable sshd && sudo systemctl start sshd

2. Transfer file from server to local machine

To download a file from remote server, use command in your local Linux machine or putty in Windows:

scp [email protected]:/PATH/TO/FILE ./

replace username and server ip you use to login the Linux server. And, add -P number if non-default port is in use.

For example, use command below to download ‘openvpn.ovpn‘ from remove server to current local folder:

  • username on server: merilyn
  • server ip: 54.217.52.149
  • ssh listening port: 29901 (default is 22)
  • file located in server user’s home, and downloaded to local folder in current machine.
scp -P 29901 [email protected]:~/openvpn.ovpn ./

Answer ‘y’ if it asks to add key, and type the password of the remote user to authenticate.

2. Upload file from local machine to server

To transfer file from local machine to remote server, run command in local Linux machine or Putty:

scp /PATH/TO/LOCAL/FILE [email protected]:/PATH/TO/DESTINATION

For example, upload backup.tar.xz from local Downloads folder to server user’s home directory via command:

scp -P 29901 ~/Downloads/backup.tar.xz [email protected]:~/

Last words

The temporary http server via Python command is simple, but ONLY recommended for less important and small files due to security reasons. For important data, scp command is always a good choice.

Merilyn Ne
Hi, I'm Merilyn Ne, a computer geek working on Ubuntu Linux for many years and would like to write useful tips for beginners. Forgive me for language mistakes. I'm not a native speaker of English.