shell - 如何使用scp将文件夹从远程复制到本地?
如何使用ssh将文件夹从远程复制到本地主机?
我使用ssh登录我的服务器。
然后,我想将远程文件夹foo复制到本地/home/user/Desktop。
怎么做到这一点?
11个解决方案
3938 votes
scp -r user@your.server.example.com:/path/to/foo /home/user/Desktop/
电话:man scp(查看在线手册)
-r递归复制整个目录
Gryphius answered 2018-12-17T12:12:14Z
242 votes
要使用scp的全部功能,您需要执行以下步骤:
公钥授权
创建ssh别名
然后,例如,如果你有这个〜/ .ssh / config:
Host test
User testuser
HostName test-site.com
Port 22022
Host prod
User produser
HostName production-site.com
Port 22022
你将节省密码输入并简化scp语法,如下所示:
scp -r prod:/path/foo /home/user/Desktop # copy to local
scp -r prod:/path/foo test:/tmp # copy from remote prod to remote test
更重要的是,