运维日志您现在的位置是:首页 > 博客日志 > 运维日志

如何使用scp命令在远程主机之间复制文件

<a href='mailto:'>微wx笑</a>的头像微wx笑 2024-01-20运维日志 0 0关键字: scp  

使用scp命令可以在本地主机和远程主机之间安全地复制文件。基本语法:scp [选项] 源文件 目标主机:目标路径或scp [选项] 源主机:源路径 目标路径主要选项:-r: 递归复制目录 -p:

无知人生,ivu4e.com,ivu4e.cn

使用scp命令可以在本地主机和远程主机之间安全地复制文件。VBk无知

基本语法:VBk无知

scp [选项] 源文件 目标主机:目标路径VBk无知

VBk无知

scp [选项] 源主机:源路径 目标路径VBk无知

主要选项:VBk无知

-r: 递归复制目录 -p: 保留文件属性(如修改时间、权限等)VBk无知

使用scp复制本地文件到远程主机:VBk无知

scp filename user@remotehost:/path/to/destinationVBk无知

使用scp从远程主机复制文件到本地:VBk无知

scp user@remotehost:/path/to/source/filename /local/destination/pathVBk无知

使用scp在两个远程主机之间复制文件:VBk无知

scp user1@host1:/path/to/source/file user2@host2:/path/to/destinationVBk无知

例子:VBk无知

将本地文件file1复制到远程主机remote的/home/user1目录下:VBk无知

scp file1 user1@remote:/home/user1VBk无知

将远程主机remote1上的目录dir递归复制到远程主机remote2的/path目录下:VBk无知

scp -r user1@remote1:/home/dir user2@remote2:/pathVBk无知

所以scp命令可以很方便地在本地和远程主机,或两个远程主机之间安全地复制文件和目录。VBk无知


VBk无知

无知人生,ivu4e.com,ivu4e.cn

本文由 微wx笑 创作,采用 署名-非商业性使用-相同方式共享 4.0 许可协议,转载请附上原文出处链接及本声明。
原文链接:https://www.ivu4e.cn/blog/service/2024-01-20/2005.html

很赞哦! () 有话说 ()

相关文章