Files travel to and from your server over SSH, the same connection you use for commands. Nothing has to be installed on the server. This page shows three ways: a program with windows, the command scp for a quick copy, and rsync for large folders. The examples use a server with Ubuntu 26.04 LTS.
All commands on this page run on your computer, not on the server.
What You Need
- The address of your server, a user (
rootor your own) and its password or SSH key: How to Connect to a Linux Server via SSH. - The SSH port, 22 unless you changed it.
1. With a Program: WinSCP or FileZilla
Both programs show your computer on one side and the server on the other, and you drag files between them. Enter these values in the login window:
| Field | Value |
|---|---|
| Protocol | SFTP |
| Host | the address of your server |
| Port | 22 |
| User | root or your own user |
| Password | the password of that user, or choose your key file instead |
The windows of WinSCP are shown step by step in WinSCP: Transfer Files Between Your Computer and Your Service (SFTP and FTPS). That guide was written for App Hosting; with your server, use the SFTP part with the values from the table.
2. One Command: scp
scp is part of Windows, macOS and Linux. Open PowerShell or a terminal on your computer.
Copy a file to the server, into the folder /root:
scp notes.txt root@your-server:/root/
On Windows with the full path of the file:
scp C:\Users\Alex\Desktop\notes.txt root@your-server:/root/
Copy a whole folder with -r:
scp -r photos root@your-server:/root/
Copy a file or a folder from the server to your computer; the dot at the end means the folder you are in:
scp root@your-server:/root/notes.txt . scp -r root@your-server:/root/photos .
- Another SSH port: add
-P 2222(a capital P) afterscp. - A key file: add
-iand the path of the key, for examplescp -i ~/.ssh/id_ed25519 notes.txt root@your-server:/root/. - The first connection asks whether you trust the server; answer
yes.
3. Large Folders: rsync
rsync copies only what is missing or has changed. When the connection breaks, you run the same command again and it continues. It is part of macOS and Linux; on Windows, use WinSCP instead.
First see what would be copied. With n in the options nothing is changed, and the answer ends with (DRY RUN):
rsync -avPn photos/ root@your-server:/root/photos/
Then copy:
rsync -avP photos/ root@your-server:/root/photos/
And in the other direction, from the server to your computer:
rsync -avP root@your-server:/root/photos/ photos/
- The slash at the end of the first folder means "the contents of this folder". Keep it on both sides as in the examples.
- Another SSH port: add
-e "ssh -p 2222". - A second run of the same command sends nothing when everything is already there.
4. A Few Files by Hand: sftp
sftp opens a small command line for files on the server:
sftp root@your-server
| Command | What it does |
|---|---|
ls, cd /root/photos | Lists and changes the folder on the server. |
lcd Desktop | Changes the folder on your computer. |
put notes.txt | Copies a file to the server. |
get notes.txt | Copies a file from the server. |
bye | Closes the connection. |
5. After the Copy
- Owner. Files you copy as
rootbelong toroot. A website or an app that runs as another user may not be allowed to read or change them: File Permissions on Linux: Who May Read, Change and Run a File. - Space. Check the free space on the server with
df -hbefore you copy a lot: What Fills the Disk and What Loads the Server.
If Something Does Not Work
- No such file or directory: the file on your computer or the folder on the server does not exist. Check both paths; the folder on the server must exist before you copy into it.
- Permission denied at the login: the user or password is wrong, or the server accepts only keys. See Log In to Your Linux Server With an SSH Key.
- Connection refused or no answer: the port is wrong or a firewall blocks you: Change the SSH Port of Your Linux Server, Protect Your Linux Server With a Firewall and Fail2ban.
- A warning that the host key has changed after a reinstall: see the section about it in How to Connect to a Linux Server via SSH.
Good to Know
- From another server instead of your computer: Move Your Data From Another Server to Your Linux Server.
- Give another person access to one folder only: Give Someone SFTP Access to One Folder Only.
- Keep a folder in sync all the time: Sync Folders With Your Linux Server: Syncthing.