日期:2014-05-16  浏览次数:20662 次

Linux下远程文件传输命令——scp
SCP- secure copy (remote file copy program)
命令原型:
     scp [-1246BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file] [-l limit] [-o ssh_option] [-P port] [-S program] [[user@]host1:]file1 ... [[user@]host2:]file2

命令描述:

scp用于通过网络实现主机之间的文件复制。它使用ssh来进行文件传输,并且和ssh一样使用同样的认证和提供同样的安全性。

命令使用:

现在只关心两台主机之间的文件传输,其他参数先不考虑,所以只需要看如下部分:

[[user@]host1:]file1 ... [[user@]host2:]file2

如我在一台主机—Server3上有一个文件scp_test,现在需要将该文件拷贝到主机Server2上:

[root@Server3 wan-test]# ls -l scp_test
-rw-r--r--. 1 root root 16  5月  4 15:11 scp_test


在server2上输入如下命令:

[root@Server2 games]# scp root@192.168.0.31:/usr/games/wan-test/scp_test /usr/games/


注意一点:如果你现在不是root用户,则运行这条命令之后,需要输入认证密码。之后将会输出如下内容:

scp_test                                      100%   16     0.0KB/s   00:00

然后在server2上就可以查看到该文件了:

[root@Server2 games]# ls -l scp_test
-rw-r--r--. 1 root root 16  5月  4 15:01 scp_test