背景说明

Linux scp命令用于Linux之间复制文件和目录。

scp是secure copy的缩写,scp是Linux系统下基于ssh登陆进行安全的远程文件拷贝命令。

从本地复制到远程

# 拷贝文件
scp /home/test/test.txt root@192.168.0.2:/home/test/
# 拷贝目录
scp -r /home/test/ root@192.168.0.2:/home/test/

从远程复制到本地

# 拷贝文件
scp root@192.168.0.2:/home/test/ /home/test/test.txt
# 拷贝目录
scp -r root@192.168.0.2:/home/test/ /home/test/

小结

结合screen【服务器】Linux会话服务Screen教程 来进行挂机远程复制,服务器与服务器对拷,确实堪称搬家利器。