What this is
SCP and SFTP are secure methods to transfer files over SSH.
What it is for
- Upload website files to your VPS
- Download backups/logs from your VPS
- Move configuration files safely
Prerequisites
- SSH access to the VPS
- Server IP, username, and SSH port (if custom)
- Local terminal (PowerShell/Terminal) on your computer
Step-by-step: SCP (command-line copy)
Upload a file to the server
scp localfile.txt USERNAME@YOUR_SERVER_IP:/home/USERNAME/
What it does: Copies a local file to the remote folder.
Expected output: A progress indicator and completion.
Download a file from the server
scp USERNAME@YOUR_SERVER_IP:/etc/nginx/nginx.conf ./nginx.conf
Copy a folder (recursive)
scp -r ./myfolder USERNAME@YOUR_SERVER_IP:/home/USERNAME/
Warning: For large folders, consider rsync (faster/resumable).
Using a custom SSH port
scp -P 2222 localfile.txt USERNAME@YOUR_SERVER_IP:/home/USERNAME/
Note: SCP uses -P (uppercase) for port.
Using an SSH key file
scp -i ~/.ssh/id_ed25519 localfile.txt USERNAME@YOUR_SERVER_IP:/home/USERNAME/
Step-by-step: SFTP (interactive file transfer)
Start an SFTP session
sftp USERNAME@YOUR_SERVER_IP
Expected output: An sftp> prompt.
Common SFTP commands
pwd
lpwd
ls
lls
cd /var/www
lcd ~/Downloads
get remote.txt
put local.txt
bye
What they do: Remote vs local navigation, download (get), upload (put), exit.
Warnings & useful notes
- Be careful when uploading to system folders; you may need sudo to move files into place.
- For website deployments, upload to your home folder first, then move with sudo.
Final verification
On the server, confirm the file exists:
ls -la /home/USERNAME/
Conclusion
SCP is fast for quick copies; SFTP is great when you want an interactive session. Both are secure because they run over SSH.