15.1 安全复制
scp 命令用于安全地将文件复制到远程目标或从远程目标复制文件。如果文件在当前工作目录中,只需提供文件名即可,否则需要提供完整路径,包括远程主机名。scp localfile.txt /home/friend/share/
scp user@remotehost.com:/var/www/html/remote_file.txt ./
scp user1@remotehost1.com:/var/www/html/file.txt user2@remotehost2.com:/home/user2/
scp -r user@remotehost.com:/var/www/html/ ./html/
15.2 基本用法
# 将远程文件复制到本地目录scp user@remotehost.com:/remote/path/to/foobar.md /local/dest# 将本地文件复制到远程目录scp /local/path/to/foobar.md user@remotehost.com:/remote/path# 可以使用密钥文件(就像 ssh 一样)scp -i /path/to/key/file /local/path/to/foobar.md user@remotehost.com:/remote/path