从远程将目录拷回本地
scp -r 用户名@计算机IP或者计算机名称:目录名 本地路径
-r 若 source 中含有目录名,则将目录下之档案亦皆依序拷贝至目的地
-a 尽可能将档案状态、权限等资料都照原状予以复制
[root@y2_zilong ~]# echo a >> /etc/hosts
[root@y2_zilong ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.133 y1_zilong.example.com y1 y1_zilong
10.0.0.121 y2_zilong.example.com y2 y2_zilong
a
a
[root@y2_zilong ~]# scp root@10.0.0.133:/etc/hosts /etc/hosts
root@10.0.0.133's password:
hosts 100% 250 0.2KB/s 00:00
[root@y2_zilong ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.133 y1_zilong.example.com y1 y1_zilong
10.0.0.121 y2_zilong.example.com y2 y2_zilong
[root@y2_zilong ~]#
将本地目录拷贝到远程 scp -r目录名 用户名@计算机IP或者计算机名称:远程路径
[root@y1_zilong ~]# echo a > /etc/hosts
[root@y1_zilong ~]# cat /etc/hosts
a
[root@y2_zilong ~]# scp /etc/hosts root@10.0.0.133:/etc/hosts
root@10.0.0.133's password:
hosts 100% 250 0.2KB/s 00:00
[root@y2_zilong ~]#
[root@y1_zilong ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.133 y1_zilong.example.com y1 y1_zilong
10.0.0.121 y2_zilong.example.com y2 y2_zilong
[root@y1_zilong ~]#