linux scp(安全复制) 命令

scp(Secure Copy,安全复制)是一项比传统远程复制工具rcp更安全的文件复制技术。文件都是通过SSH加密通道进行传输的。

从当前目录复制到远程主机:

$scp filename user@remotehost:/home/path/

其中,remotehost可以使用ip地址或者域名。

举例:[zhang@testtemp]$ scp words.zip zhang@10.10.1.4:/home/zhang/temp/The authenticity of host ‘10.10.1.4 (10.10.1.4)’ can’t be established.RSA key fingerprint is 9d:87:f2:4b:51:b8:08:6f:dc:d7:8e:87:f4:9c:f6:ad.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added ‘159.226.11.46’ (RSA) to the list of known hosts.zhang@10.10.1.4’s password:words.zip 100% 213 0.2KB/s 00:00[zhang@test temp]$

也可以从远程主机中的文件复制到当前目录,并采用给定的文件名。格式如下:

$scp user@remotehost:/home/path/filename filename

如果SSH没有运行在端口22,使用-oPort,并采用和sftp相同的语法。

举例:[zhang@test temp]$ scp zhang@10.10.1.4:/home/zhang/temp/user.jsp user.jspzhang@10.10.1.4’s password:user.jsp 100% 4114 4.0KB/s 00:01[zhang@test temp]$

用scp进行递归复制,使用-r选项,我们可以在两天网络主机之间对文件夹进行递归复制:

$scp -r /home/filefolder user@remotehost:/home/backups

scp的-p选项能够在复制文件的同时保留文件的权限和模式

举例:[zhang@test temp]$ scp -r temp zhang@10.10.1.4:/home/lhb/temp/zhang@10.10.1.4’s password:test.txt.gz 100% 29 0.0KB/s 00:00zhang.txt 100% 0 0.0KB/s 00:00zz.zip 100% 150 0.2KB/s 00:00zhang.gz 100% 20 0.0KB/s 00:00zhang.txt.gz 100% 30 0.0KB/s 00:00[zhang@test temp]$

我爱你….为了你的幸福,我愿意放弃一切—包括你。

linux  scp(安全复制)  命令

相关文章:

你感兴趣的文章:

标签云: