Hostxpeed
Login Get Started →
Getting Started

How to Transfer Files Using SCP

5 min read
25 views
Jun 10, 2026

Prerequisites

Before using SCP, make sure you have:

  • SSH access to your VPS (SCP uses same credentials)
  • Your server IP address and username (hxroot)
  • Local file path (what you want to copy)

💡 SCP (Secure Copy) uses SSH encryption, making it safe to transfer files over the internet.

Command Syntax

scp [options] source destination

Method 1: Copy File from Local to VPS

On your local computer (not connected to SSH):

scp /local/path/file.txt hxroot@YOUR_SERVER_IP:/remote/path/

Example - upload a file to root directory:

scp backup.zip hxroot@148.113.173.106:/root/

Specify custom SSH port:

scp -P 2222 file.txt hxroot@YOUR_SERVER_IP:/home/

Note: For SCP, use uppercase -P for port (lowercase -p preserves file times).

Method 2: Copy File from VPS to Local

scp hxroot@YOUR_SERVER_IP:/remote/path/file.txt /local/path/

Example:

scp hxroot@148.113.173.106:/var/log/syslog ~/Desktop/

Method 3: Copy Directory Recursively

Use -r flag for directories:

scp -r /local/folder/ hxroot@YOUR_SERVER_IP:/remote/folder/

Example:

scp -r /home/user/documents/ hxroot@148.113.173.106:/root/backups/

Method 4: Copy Between Two Remote Servers

scp hxroot@SERVER1_IP:/file.txt hxroot@SERVER2_IP:/file.txt

Useful SCP Options

  • -r - Copy directories recursively
  • -P port - Specify SSH port (uppercase P)
  • -i keyfile - Use SSH key instead of password
  • -C - Compress data during transfer (slower but smaller)
  • -l limit - Limit bandwidth (Kbit/s)
  • -v - Verbose output (for debugging)
  • -q - Quiet mode (no progress)
  • -p - Preserve file modification times (lowercase p)

Common Examples

Copy with compression:

scp -C largefile.zip hxroot@YOUR_SERVER_IP:/root/

Limit bandwidth to 1Mbit/s:

scp -l 1024 largefile.zip hxroot@YOUR_SERVER_IP:/root/

Use SSH key:

scp -i ~/.ssh/id_rsa file.txt hxroot@YOUR_SERVER_IP:/root/

Copy multiple files:

scp file1.txt file2.txt file3.txt hxroot@YOUR_SERVER_IP:/root/

Preserve file attributes:

scp -p file.txt hxroot@YOUR_SERVER_IP:/root/

Progress and Verification

SCP shows progress by default:

file.txt          100% 245KB 245.2KB/s   00:00

After transfer, verify on server:

ssh hxroot@YOUR_SERVER_IP -p 22 ls -la /root/file.txt

Common SCP Errors and Fixes

Permission denied:

  • Check username and password
  • Verify SSH key permissions (chmod 600 ~/.ssh/id_rsa)

No such file or directory:

  • Verify source path exists locally
  • Check destination path on remote server

Connection refused:

  • Verify server IP and SSH port
  • Check firewall allows SSH port

Host key verification failed:

ssh-keygen -R YOUR_SERVER_IP

Alternative: Use SCP with Different Username

If your local username differs from remote:

scp file.txt hxroot@YOUR_SERVER_IP:/home/hxroot/

Script Example: Automated Backup with SCP

#!/bin/bash
# Backup and SCP script
DATE=$(date +%Y%m%d)
tar -czf /tmp/backup-$DATE.tar.gz /var/www/
scp /tmp/backup-$DATE.tar.gz hxroot@BACKUP_SERVER:/backups/
rm /tmp/backup-$DATE.tar.gz
echo "Backup completed at $(date)"

SCP vs SFTP vs RSYNC

  • SCP - Simple, good for single files
  • SFTP - Interactive, supports resume
  • RSYNC - Best for directories and incremental backups

✅ You can now securely transfer files between your local computer and Hostxpeed VPS using SCP.

Was this article helpful?