如何将整个文件夹从 Amazon EC2 Linux 实例复制到本地 Linux 计算机?
我使用私钥从 ssh 连接到 Amazon 的 linux 实例。我正在尝试将整个文件夹从该实例复制到我的本地 Linux 计算机。
谁能告诉我正确的 scp
命令来执行此操作?
或者我还需要 scp
以外的东西吗? 两台机器都是 Ubuntu 10.04 LTS
I connected to Amazon's linux instance from ssh using private key. I am trying to copy entire folder from that instance to my local linux machine .
Can anyone tell me the correct scp
command to do this?
Or do I need something more than scp
?
Both machines are Ubuntu 10.04 LTS
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
另一种方法是
我犯的一个错误是
scp -ir
。密钥必须位于-i
之后,然后是-r
。所以
another way to do it is
One mistake I made was
scp -ir
. The key has to be after the-i
, and the-r
after that.so
使用递归选项从客户端计算机调用
scp
:Call
scp
from client machine with recursive option:对于 EC2 ubuntu,
请转到您的 .pem 文件目录
For EC2 ubuntu
go to your .pem file directory
您甚至可以使用 rsync。
You could even use rsync.
这就是我将文件从亚马逊 ec2 服务复制到本地窗口电脑的方法:
对于 Linux 复制目录:
要连接到亚马逊,需要密钥对身份验证。
注意:
用户名很可能是 ubuntu。
This's how I copied file from amazon ec2 service to local window pc:
For Linux to copy a directory:
To connect to amazon it requires key pair authentication.
Note:
Username most probably is ubuntu.
我使用 sshfs 并将远程目录挂载到本地计算机并执行您想做的任何操作。 这里是一个小指南,命令可能会在您的系统上发生变化
I use sshfs and mount remote directory to local machine and do whatever you want. Here is a small guide, commands may change on your system
这也很重要,并且与上面的答案相关。
将本地目录中的所有文件复制到 EC2。这是 Unix 的答案。
将整个本地文件夹复制到 EC2 中的文件夹:
scp -i "key-pair.pem" -r /home/Projects/myfiles [电子邮件受保护]:/home/dir
仅将本地文件夹的全部内容复制到 EC2 中的文件夹:
scp -i "key-pair.pem" -r /home/Projects/myfiles/* [电子邮件受保护]:/home/dir
This is also important and related to the above answer.
Copying all files in a local directory to EC2. This is a Unix answer.
Copy the entire local folder to a folder in EC2:
scp -i "key-pair.pem" -r /home/Projects/myfiles [email protected]:/home/dir
Copy only the entire contents of local folder to folder in EC2:
scp -i "key-pair.pem" -r /home/Projects/myfiles/* [email protected]:/home/dir
我不喜欢对大量文件使用 scp,因为它为每个文件执行“事务”。下面的方法要好得多:
您可以向 tar 添加一个
z
标志,以在服务器上压缩并在客户端上解压缩。I do not like to use scp for large number of files as it does a 'transaction' for each file. The following is much better:
You can add a
z
flag to tar to compress on server and uncompress on client.我在 youtube 上发现的一种方法是将本地文件夹与 EC2 实例中的共享文件夹连接。请观看此视频了解完整说明。共享是即时的。
One way I found on youtube is to connect a local folder with a shared folder in EC2 instance. Please view this video for the full instruction. The sharing is instantaneous.