如何使用scp
将文件夹从远程复制到本地主机?
我使用ssh
登录我的服务器。然后,我想将远程文件夹foo
复制到本地/home/user/Desktop
。
我该如何实现?
问题是如何使用scp
命令将文件夹从远程复制到本地。
我不知道为什么,但是在源服务器指令之前,我不得不使用本地文件夹。使它工作
要使用scp的全部功能,您需要执行以下步骤:
然后,例如,如果您有这个〜/ .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
此外,您将可以使用远程路径完成:
scp test:/var/log/ # press tab twice
Display all 151 possibilities? (y or n)
更新:
为了启用远程bash补全,您需要在<source>
和<target>
主机上都具有bash-shell,并且bash补全正常工作。有关更多信息,请参见相关问题:
How to enable autocompletion for remote paths when using scp?SCP filename tab completion
将全部从本地位置复制到远程位置(上传)
scp -r /path/from/destination username@hostname:/path/to/destination
将全部从远程位置复制到本地位置(下载)
scp -r username@hostname:/path/from/destination /path/to/destination
xxxx
为自定义端口号的自定义端口
scp -r -P xxxx username@hostname:/path/from/destination /path/to/destination
从远程到本地复制到当前目录
scp -r username@hostname:/path/from/file .
帮助:
-r
递归复制所有目录和文件/
中的完整位置,请按pwd
中的位置获取完整位置>scp
将替换所有现有文件hostname
将是主机名或IP地址-P portnumber
注意:
我一直使用的是:
最好先在远程服务器上压缩目录:
并且,如果您有一个要从远程位置下载的文件,并且您不太在意安全性,请尝试将scp默认加密(Triple-DES)更改为“ blowfish”。
转到统一工具栏上的文件
典型情况,
如果遇到“验证失败太多”