Linux Can';从scp到AWS

Linux Can';从scp到AWS,linux,amazon-ec2,Linux,Amazon Ec2,我可以使用以下方式ssh到我的linux实例: ssh -i dj_mongo.pem -v ec2-user@xxx.compute-1.amazonaws.com 但每当我试图将文件从本地计算机复制到服务器时,都会出现以下错误: scp -i dj_mongo.pem ck.pem root@xxx.compute-1.amazonaws.com:/ Please login as the ec2-user user rather than root user. scp -i dj

我可以使用以下方式ssh到我的linux实例:

ssh -i dj_mongo.pem -v ec2-user@xxx.compute-1.amazonaws.com
但每当我试图将文件从本地计算机复制到服务器时,都会出现以下错误:

 scp -i dj_mongo.pem ck.pem  root@xxx.compute-1.amazonaws.com:/
Please login as the ec2-user user rather than root user.

 scp -i dj_mongo.pem ck.pem  ec2-user@xxx.compute-1.amazonaws.com:/
Permission denied (publickey).
lost connection
dj_mongo-pem和ck.pem都拥有600权限

终端的输出复制如下:

 Applying options for *
debug1: Connecting to xxx.compute-1.amazonaws.com [xxx] port 22.
debug1: Connection established.
debug1: identity file dj_mongo.pem type -1
debug1: identity file dj_mongo.pem-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.6
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(1024<1024<8192) sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: expecting SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Host 'xxx.compute-1.amazonaws.com' is known and matches the RSA host key.
debug1: Found key in /Users/sadmin/.ssh/known_hosts:6
debug1: ssh_rsa_verify: signature correct
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: Roaming not allowed by server
debug1: SSH2_MSG_SERVICE_REQUEST sent
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering RSA public key: /Users/sadmin/.ssh/github_rsa
debug1: Authentications that can continue: publickey
debug1: Trying private key: dj_mongo.pem
debug1: read PEM private key done: type RSA
debug1: Authentications that can continue: publickey
debug1: No more authentication methods to try.
Permission denied (publickey).
lost connection
将选项应用于*
debug1:连接到xxx.compute-1.amazonaws.com[xxx]端口22。
debug1:已建立连接。
debug1:标识文件dj_mongo.pem type-1
debug1:标识文件dj_mongo.pem-cert类型-1
debug1:远程协议版本2.0,远程软件版本OpenSSH_5.3
debug1:match:OpenSSH_5.3 pat OpenSSH*
debug1:启用协议2.0的兼容模式
debug1:本地版本字符串SSH-2.0-OpenSSH_5.6
debug1:SSH2\u MSG\u KEXINIT已发送
debug1:SSH2\u MSG\u KEXINIT已收到
debug1:kex:server->client aes128 ctr hmac-md5无
debug1:kex:客户端->服务器aes128 ctr hmac-md5无

debug1:SSH2\u MSG\u KEX\u DH\u GEX\u请求(1024在典型的详细scp输出中

debug1: Trying private key: dj_mongo.pem
debug1: read PEM private key done: type RSA
debug1: Authentication succeeded (publickey).
Authenticated to your.server.com ([i.p.v.4]:22).
在您的输出中,读取私有PEM密钥后,它将跳过该密钥

没有什么明显的事情-

  • 服务器是否使用与dj_mongo.pem对应的相同密钥启动
  • 您正在连接到同一台服务器吗

  • 我无法找出我的问题的原因。
    最后,我创建了新的Linux实例,并附加了停止响应的旧实例的EBS。

    我可能错了,但很多版本的Linux都会阻止通过root用户进行SSH/SCP访问。特别是如果您使用的是Amazon AMI,他们会设置一个名为ec2 user的root用户,您应该已经将pem密钥上载到该用户,因此应在以该用户身份登录时进行所有设置。

    您是否具有以ec2用户身份对远程系统根文件夹的写入权限?无论我尝试在何处复制文件,我都会得到此权限。例如sadmin$scp-I dj_mongo.pem ck.pem ec2-user@ec2-54-243-218-25.compute-1.amazonaws.com:/home/ec2用户ec2用户由ec2用户所有,拥有777个许可证我还复制了一些文件…但我不记得我是怎么做的。我认为问题在于身份验证。你读过吗?