如何scp文件夹从远程到本地?
我不知道是否有可能从远程文件夹scp到本地,但我仍然没有其他select。 我使用SSHlogin到我的服务器,并从那里我想复制文件夹foo到home/user/Desktop (我的本地)。 有什么指令可以做到吗? 
 scp -r user@your.server.example.com:/path/to/foo /home/user/Desktop/ 
 从man scp 
 -r Recursively copy entire directories 
要使用scp的全部function,您需要经过以下步骤:
- 公钥授权
- 创buildssh别名
那么,例如,如果你有这个〜/ .ssh / config :
 Host test User testuser HostName test-site.com Port 22022 Host prod User produser HostName production-site.com Port 22022 
你可以节省自己的密码input,并简化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 
此外,您将能够使用远程path完成:
 scp test:/var/log/ # press tab twice Display all 151 possibilities? (y or n) 
更新:
 为了启用远程bash完成,你需要在<source>和<target>主机上都有bash-shell,并且正常工作bash-completion。 有关更多信息,请参阅相关问题 
  如何在使用scp时为远程path启用自动完成function? 
  SCP文件名选项卡完成 
将所有从本地位置复制到远程位置 (上传)
 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 . 
帮帮我:
-   -rrecursion地复制所有目录和文件
-  始终使用/完整位置,通过pwd获取完整位置
-   scp将会replace所有现有的文件
-   hostname名将是主机名或IP地址
-  如果需要定制端口(除了端口22),请使用-P portnumber
- 。 (点) – 它表示当前的工作目录,所以从服务器下载/复制并粘贴在这里。
注意:由于端口在防火墙中是不允许的,所以有时自定义端口将不起作用,因此请确保防火墙中的自定义端口允许传入和传出连接
我总是使用的是:
 scp -r username@IP:/path/to/server/source/folder/ . 
  。  (点) :表示current folder 。 所以从服务器复制并粘贴在这里只。 
  IP :可以是125.55.41.311类的IP地址,也可以是ns1.mysite.com类的ns1.mysite.com 。 
最好先在远程服务器上压缩目录:
 tar czfP backup.tar.gz /path/to/catalog 
其次,从远程下载:
 scp user@your.server.example.com:/path/to/backup.tar.gz . 
最后,提取文件:
 tar -xzvf backup.tar.gz 
如果你有一个地狱的文件从远程位置下载,如果你不太在乎安全性,请尝试改变默认encryption(Triple-DES)到像'blowfish'的东西。
这将大大减less文件复制时间。
 scp -c blowfish -r user@your.server.example.com:/path/to/foo /home/user/Desktop/ 
转到统一工具栏上的文件
  
 
按Ctrl + l并写入here_goes_your_user_name@192.168.10.123
192.168.1.103是您要连接的主机。
这里是一个例子
  
 
典型场景,
 scp -r -P port username@ip:/path-to-folder . 
用样本解释,
 scp -r -P 27000 abc@10.70.12.12:/tmp/hotel_dump . 
哪里,
 port = 27000 username = "abc" , remote server username path-to-folder = tmp/hotel_dump . = current local directory 
如果您遇到“身份validation失败太多” ,请指定您添加到服务器ssh服务器的确切SSH密钥:
 scp -r -i /path/to/local/key user@remote.tld:/path/to/folder /your/local/target/dir 
 问题是如何使用scp命令将远程文件夹复制到本地。 
 $ scp -r userRemote@remoteIp:/path/remoteDir /path/localDir 
 但是,用sftp做这件事更好 –  SSH文件传输协议(也叫安全文件传输协议,或SFTP)是一种networking协议,它提供文件访问,文件传输和文件pipe理function。 。 
 $ sftp user_remote@remote_ip 
 sftp> cd /path/to/remoteDir 
 sftp> get -r remoteDir 
 Fetching /path/to/remoteDir to localDir 100% 398 0.4KB/s 00:00 
 有关sftp命令的帮助,只需inputhelp或?  。 
我不知道为什么,但我不得不在源服务器指令之前使用本地文件夹。 使其工作
 scp -r . root@888.888.888.888:/usr/share/nginx/www/example.org