利用scp指令可以在linux机器间传递文件,个人使用几次感觉效率还是较高的,比SFTP+本地做媒介要高得多。

1.本地拷贝到远程

这种方式的命令模式是scp local_file remote_username@remote_ip:remote_file

示例如下:

[root@msg45 hy]# ls
rpm  test.txt  wasliberty

将test.txt从本地拷贝到远程
[root@msg45 hy]# scp test.txt [email protected]:/home/hy/
The authenticity of host 'msg43.matson.ufo.com (91.200.193.93)' can't be established.
RSA key fingerprint is dc:ab:dc:c8:09:6d:c7:fe:b5:f6:b8:9a:93:89:75:07.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'msg43.matson.ufo.com,91.200.193.93' (RSA) to the list of known hosts.
[email protected]'s password:
test.txt                                                                                                                                       100%   15     0.0KB/s   00:00    
[root@msg45 hy]#

2.远程拷贝到本地

从 远程 复制到 本地,只要将 从 本地 复制到 远程 的命令 的 后2个参数 调换顺序 即可,如下。

scp  remote_username@remote_ip:remote_file local_file

示例如下:

[root@msg45 hy]# scp [email protected]:/home/hy/test.txt  test1.txt
[email protected]'s password:
test.txt                                                                                                                                       100%   15     0.0KB/s   00:00    
[root@msg45 hy]#

05-11 11:21