GO Online Toolset
home
search
To Boss

Scp operating instructions
new
7  |   |   |  0

scp Command Quick Reference

Basic Syntax

scp [options] [source_path] [destination_path]

Common Usage Examples

1. Upload local file to remote server
scp ./file.txt user@192.168.1.10:/home/user/
2. Download file from remote server to local
scp user@192.168.1.10:/home/user/file.txt ./file.txt
3. Upload directory to remote server
scp -r ./mydir user@192.168.1.10:/home/user/
4. Download directory from remote server to local
scp -r user@192.168.1.10:/home/user/mydir ./mydir
5. Use specific port (e.g., 2222)
scp -P 2222 ./file.txt user@192.168.1.10:/home/user/
6. Use specific private key file
scp -i ~/.ssh/id_rsa ./file.txt user@192.168.1.10:/home/user/

Common Options

OptionDescription
-rRecursively copy entire directories
-PSpecify remote host port (note: uppercase P)
-iSpecify SSH private key file
-CEnable compression to improve transfer speed
-pPreserve file modification times, permissions
-qQuiet mode, suppress progress information

Path Format

TypeExample
Local path./file.txt or /home/user/file.txt
Remote pathuser@host:/path/to/file.txt

Common Error Troubleshooting

ErrorPossible Cause
Permission deniedInvalid SSH key, or no write permission to remote directory
No such file or directoryIncorrect source or destination path
Connection refusedTarget port unreachable or SSH service not running
Host key verification failedFirst time connecting to remote host, host fingerprint not accepted. Try ssh login first

Additional Tips

Copy file between two remote servers
scp user1@host1:/path/file.txt user2@host2:/path/

Current machine must have access to both host1 and host2

Batch upload files (script example)
for f in *.log; do
  scp "$f" user@host:/var/logs/
done

Common Command Templates

scp ./local.txt user@host:/remote/path/
scp user@host:/remote/file.txt ./local/
scp -r ./dir user@host:/remote/
scp -i ~/.ssh/key.pem -P 2222 ./file user@host:/dest/