scp
2026-06-15
基本格式
scp [选项] 源文件 目标路径
远程路径格式:
user@host:/path/to/file
1. 本地 → 远程(上传文件)
scp file.txt user@192.168.1.10:/home/user/
2. 远程 → 本地(下载文件)
scp user@192.168.1.10:/home/user/file.txt .
3. 上传整个目录(-r)
scp -r myfolder user@host:/remote/path/
4. 下载整个目录
scp -r user@host:/remote/folder .
5. 指定端口(-P,大写P)
scp -P 2222 file.txt user@host:/path/
6. 使用 SSH 私钥(-i)
scp -i ~/.ssh/id_rsa file.txt user@host:/path/
显示传输详情(-v)
scp -v file.txt user@host:/path/
限速(-l,单位 Kbit/s)
scp -l 1000 file.txt user@host:/path/
保留文件属性(时间/权限)
scp -p file.txt user@host:/path/