【问题标题】:upload file to ec2 instance in fedora将文件上传到 Fedora 中的 ec2 实例
【发布时间】:2011-08-28 06:25:31
【问题描述】:

我有一个 ec2 实例,我想将文件上传到其中。我是这样做的: 我从 AWS 管理控制台找到了公共 DNS。 然后我运行scp 命令得到了这个。

    scp  -v  helloworld.java ec2-user@ec2-204-236-198-218.compute-1.amazonaws.com:/home
Executing: program /usr/bin/ssh host ec2-204-236-198-218.compute-1.amazonaws.com, user ec2-user, command scp -v -t -- /home
OpenSSH_5.5p1, OpenSSL 1.0.0d-fips 8 Feb 2011
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to ec2-204-236-198-218.compute-1.amazonaws.com [204.236.198.218] port 22.
debug1: Connection established.
debug1: identity file /home/dassio/.ssh/id_rsa type -1
debug1: identity file /home/dassio/.ssh/id_rsa-cert type -1
debug1: identity file /home/dassio/.ssh/id_dsa type -1
debug1: identity file /home/dassio/.ssh/id_dsa-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.5
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 'ec2-204-236-198-218.compute-1.amazonaws.com' is known and matches the RSA host key.
debug1: Found key in /home/dassio/.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: Trying private key: /home/dassio/.ssh/id_rsa
debug1: Trying private key: /home/dassio/.ssh/id_dsa
debug1: No more authentication methods to try.
Permission denied (publickey).
lost connection

为什么会这样?

【问题讨论】:

  • 如果您编辑问题,请仅添加新信息或修复错误数据,不要完全重新编写问题。您的编辑完全改变了问题,现在以前相关的答案似乎与问题无关。在这样的网站上,这是不好的礼仪。您可以根据新进展进行更新,但应该有一个可以理解的进展,或者针对新问题切换到新问题。
  • 这次对不起,我会记住这一点的。

标签: ssh amazon-ec2


【解决方案1】:

您使用的 IP 地址是内部网络地址,只能从 EC2 可用区内访问。

您需要使用外部地址来访问实例。您可以使用ec2-describe-instances 找到它。该地址可能类似于 ec2.x-x-x-x.blah.amazonaws.com。

此外,虽然您似乎已经在命令行中,但您可能已经这样做了,您可能需要允许通过 EC2 防火墙访问您的实例的端口 22。

【讨论】:

  • 我改了ip,还是不行,我用公网DNS对吗?(我改了上面的问题)
  • 您的问题正在演变。上面的答案对于您的原始问题是正确的,但是您当前的编辑显示了一个完全不同的问题。您现在遇到了身份验证问题。您的实例希望通过基于密钥的系统授权您,而您的 scp 未提供任何凭据。
【解决方案2】:

Caleb 是对的。我必须向亚马逊提供一些凭据。语法如下: scp -i YOUR_KEY_PAIR FILE_WANT_TO_UPLOAD ec2-user@ec2.x-x-x-x.blah.amazonaws.com:/home/ec2-user 您无法上传到主目录(我猜是因为您使用的是 ec2 用户名)。

ec2.x-x-x-x.blah.amazonaws.com

是 Caleb 提到的外部地址。我在最初的问题中所做的是我从ifconfig 命令获得了内部地址。再次抱歉搞砸了这个问题。

【讨论】:

    猜你喜欢
    • 2013-10-24
    • 1970-01-01
    • 2015-11-19
    • 2016-10-17
    • 2014-06-04
    • 2020-09-17
    • 1970-01-01
    • 1970-01-01
    • 2016-02-12
    相关资源
    最近更新 更多