Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Copy Files to a Remote Server with SCP on Ubuntu

SCP sends files and folders to another server over SSH. Here are the commands you need.

Files and FTP2 min read6 screenshots

What SCP is

SCP (Secure Copy Protocol) copies files between two computers through an encrypted SSH connection. In the examples below, the SSH service on the remote server listens on port 2222. If your server uses the default port 22, leave out the -P 2222 part.

Before you start

Make sure the SSH service runs on the server you copy to:

sudo systemctl status ssh
The SSH service is active

Copy one file

scp -P 2222 ~/Documents/backup-folder/file.txt user@server_IP:~/Downloads
Copying a single file

What each part means:

  • -P 2222 is the SSH port of the remote server (a capital P).
  • ~/Documents/backup-folder/file.txt is the file on your computer.
  • user@server_IP is the login on the remote server.
  • :~/Downloads is the folder on the remote server.

Copy several files

Move to the folder first, then list the files:

cd ~/Documents/backup-folder/
scp -P 2222 file.txt image.jpg user@server_IP:~/Downloads
Copying two files from one folder

Files from different folders work too:

scp -P 2222 ~/Documents/backup-folder/file.txt ~/Documents/sample.doc user@server_IP:~/Downloads
Copying files from different folders

Copy a whole folder

Add -r (recursive):

scp -r -P 2222 ~/Documents/backup-folder user@server_IP:~/Downloads
Copying a folder

Check the result

List the files on the remote server:

ssh user@server_IP -p 2222 "ls -l ~/Downloads/"
The copied files on the remote server

Download from the server

Reverse the order to copy a file to your computer:

scp -P 2222 user@server_IP:~/Downloads/file.txt ~/Documents/
Tip: For large or repeated transfers, rsync over SSH is often faster because it sends only what changed.

Quick recap

  • scp -P port file user@host:/path copies a file.
  • Add -r for folders.
  • Use ssh ... "ls" to confirm the copy.