This guide explains how you can connect to a Linux server using SSH, transfer data between two servers, and download files to your own computer. It’s especially helpful if your main server is currently unavailable and you’re using a temporary KVM server.
What is SSH and why do I need it?
SSH (Secure Shell) is a secure protocol that allows you to log into a remote Linux server. It’s used to:
- Run commands remotely
- Access files and directories
- Transfer data securely
You’ll typically use the command line (terminal) to work via SSH. On Windows, you can use tools like PuTTY or WinSCP.
How do I connect to a Linux server via SSH?
To connect, you’ll need:
- The IP address of the server
- The username (usually
root
) - The password or an SSH key
Example (Linux, macOS, or Windows using WSL):
ssh root@123.123.123.123
When connecting for the first time, you’ll be asked to confirm the fingerprint. Type yes
and press Enter. Then, enter your password when prompted.
Tip for Windows users: Use PuTTY as an alternative if you’re not using a terminal.
How do I transfer data from one Linux server to another?
Method 1: Using scp
(secure copy)
Great for small directories or single files.
Example:
scp -r /var/www/html root@212.87.215.194:/root/html-backup
-r
means “recursive” – it transfers entire directories.
Method 2: Using rsync
(recommended for large or repeated transfers)
Efficient for large amounts of data or repeat transfers, as it only syncs changes.
Example:
rsync -avz /var/www/ root@212.87.215.194:/root/html-backup/
-a
: archive mode-v
: verbose output-z
: compression during transfer
What should I do if my server uses a non-standard SSH port?
Some servers use a custom SSH port instead of the default port 22. You’ll need to specify the correct port manually.
Connect using a custom SSH port:
ssh -p 2222 root@123.123.123.123
Use scp
with a custom port:
scp -P 2222 -r /var/www/html root@destination:/root/
Use rsync
with a custom port:
rsync -avz -e "ssh -p 2222" /var/www/ root@destination:/root/html-backup/
How do I download files from the server to my computer?
On Linux or macOS:
scp -r root@123.123.123.123:/root/html-backup /home/yourname/Documents/
With a custom port:
scp -P 2222 -r root@123.123.123.123:/root/html-backup /home/yourname/Documents/
On Windows using WinSCP:
- Download WinSCP and install it.
- Open the program and enter your connection details:
- Protocol: SCP
- Host name: Server IP address
- Port number: e.g. 2222
- Username: root
- Password: your SSH password
- You can now browse server files and drag & drop them to your PC.
What commands should I know?
Task | Command/Tool |
---|---|
Connect via default SSH port | ssh root@IP-address |
Connect via custom SSH port | ssh -p PORT root@IP-address |
Transfer data using scp | scp -r or scp -P PORT |
Transfer data using rsync | rsync -avz or rsync -e "ssh -p PORT" |
Download data to local PC | scp (Linux/macOS) or WinSCP (Windows) |
How can I keep transfers running overnight?
Pro tip: If you’re running a large transfer that may take a while (e.g., overnight), it’s best to use the screen
tool. This allows the process to continue even if you disconnect from the server or lose your internet connection.
Here’s how to use it:
- Start a new screen session:
screen -S transfer
- Run your transfer command inside the screen session (e.g.,
rsync
orscp
). - To detach the screen session without stopping the process:
- Press:
Ctrl + A
, thenD
- Press:
- To resume the session later:
screen -r transfer
If screen
is not installed:
apt install screen
This way, you avoid interruptions and can safely run transfers in the background.
What can I do if I need help?
If you’re unsure or need assistance transferring your data, feel free to contact our support team.