I'm trying to SCP a file from my Amazon EC2 instance into my Linux machine. I've done quite a bit of reading and nothing seems to work.
我正在尝试从我的Amazon EC2实例中SCP文件到我的Linux机器上。我读了不少书,但似乎什么也没有。
I can SSH from my Linux machine into my instance (that's how I connect to it), and can even SCP into it by doingscp -i my-key-pair.pem SampleFile.txt ec2-user@ec2-198-51-100-1.compute-1.amazonaws.com:~
. According to Amazon's instructions at this link, in order to SCP from the instance to my machine I need only to "simply reverse the order of the host parameters." In other words, this:
我可以从Linux机器上SSH到实例(这就是我连接它的方式),甚至可以通过执行SCP -i my-key-pair来SCP。pem SampleFile。txt ec2 - user@ec2 - 198 - 51 - 100 - 1. -计算- 1. - amazonaws.com ~。根据Amazon在这个链接上的说明,为了从实例到我的机器进行SCP,我只需要“简单地反转主机参数的顺序”。换句话说,这个:
scp -i my-key-pair.pem
ec2-user@ec2-198-51-100-1.compute-1.amazonaws.com:~/SampleFile.txt
~/SampleFile2.txt
I've googled around, and have even read some similar questions on here including this one, but I've had no luck. I'm not sure what the problem is. The other day I managed to SCP across instances (i.e., from one EC2 instance to another) without a problem -- which at least supposedly requires a bit more tinkering.
我在谷歌上搜索了一下,甚至还在这里读到了一些类似的问题,包括这个问题,但我运气不好。我不知道是什么问题。前几天,我成功地跨实例执行SCP。在一个EC2实例到另一个实例之间)没有问题——这至少需要更多的修改。
Another bit that is troubling me as well, is the fact that the command to SCP from the instance to the local machine includes the private key (my-key-pair.pem on the code block above), and I've looked for a .pem file on the instance and have not found one. Am I missing something? Thanks in advance.
另一个困扰我的问题是,从实例到本地机器的SCP的命令包含了私钥(my-key-pair)。上面代码块上的pem),我在实例上查找了一个.pem文件,但是没有找到。我遗漏了什么东西?提前谢谢。
By the way, I'm seeing the generic "Permission denied (public key)" error.
顺便说一下,我看到了通用的“权限被拒绝(公钥)”错误。
4 个解决方案
#1
1
I found out what the problem was. I was running the command from the instance instead of my local machine, which is somewhat odd given that when you SCP from an instance to another you run the SCP command from the instance you're copying from, but oh well.
我发现了问题所在。我是从实例而不是本地机器运行命令,这有点奇怪,因为当您从一个实例SCP到另一个实例时,您从正在复制的实例运行SCP命令,但是哦,好吧。
#2
1
`scp -r user@your.server.example.com:/path/to/foo /home/user/Desktop/`
-- use above command to scp a folder from server..use -i key if the key used is not the default.
——使用上面的命令从服务器上scp文件夹。如果使用的键不是默认值,则使用-i键。
scp -r -i key.pem user@your.server.example.com:/path/to/foo /home/user/Desktop/
scp - r -我的关键。pem user@your.server.example.com:/ / / foo /home/user/Desktop/
#3
1
This command should work First connect to Amazon EC2 over ssh,
这个命令应该首先通过ssh连接到Amazon EC2,
scp -i my-key-pair.pem <local file name on Amazon EC2> user_name@<linux_host_ip>:/<copy path>
scp -我my-key-pair。pem < Amazon EC2上的本地文件名> user_name@
ex:
例:
scp -i my-key-pair.pem SampleFile2.txt user_name@linuxHostIp:/home/userName/fileName.txt
scp -我my-key-pair。pem SampleFile2。txt user_name@linuxHostIp:/ home /用户名/ fileName.txt
#4
0
The IP of your machine is what is expected while scp and not of your router.
您的机器的IP是预期的,而scp不是您的路由器。
Otherwise possibly it might not be able to identify which machine to copy to, and copy all data to all machines behind the router which is not desired.
否则,它可能无法识别要复制到哪台机器上,并将所有数据复制到路由器后面的所有机器上,这是不需要的。
Possibly that is why it fails.
这可能就是它失败的原因。
#1
1
I found out what the problem was. I was running the command from the instance instead of my local machine, which is somewhat odd given that when you SCP from an instance to another you run the SCP command from the instance you're copying from, but oh well.
我发现了问题所在。我是从实例而不是本地机器运行命令,这有点奇怪,因为当您从一个实例SCP到另一个实例时,您从正在复制的实例运行SCP命令,但是哦,好吧。
#2
1
`scp -r user@your.server.example.com:/path/to/foo /home/user/Desktop/`
-- use above command to scp a folder from server..use -i key if the key used is not the default.
——使用上面的命令从服务器上scp文件夹。如果使用的键不是默认值,则使用-i键。
scp -r -i key.pem user@your.server.example.com:/path/to/foo /home/user/Desktop/
scp - r -我的关键。pem user@your.server.example.com:/ / / foo /home/user/Desktop/
#3
1
This command should work First connect to Amazon EC2 over ssh,
这个命令应该首先通过ssh连接到Amazon EC2,
scp -i my-key-pair.pem <local file name on Amazon EC2> user_name@<linux_host_ip>:/<copy path>
scp -我my-key-pair。pem < Amazon EC2上的本地文件名> user_name@
ex:
例:
scp -i my-key-pair.pem SampleFile2.txt user_name@linuxHostIp:/home/userName/fileName.txt
scp -我my-key-pair。pem SampleFile2。txt user_name@linuxHostIp:/ home /用户名/ fileName.txt
#4
0
The IP of your machine is what is expected while scp and not of your router.
您的机器的IP是预期的,而scp不是您的路由器。
Otherwise possibly it might not be able to identify which machine to copy to, and copy all data to all machines behind the router which is not desired.
否则,它可能无法识别要复制到哪台机器上,并将所有数据复制到路由器后面的所有机器上,这是不需要的。
Possibly that is why it fails.
这可能就是它失败的原因。