我刚刚注册了亚马逊的Elastic Beanstalk新产品。我不明白的是如何SSH到Beanstalk实例。我没有私钥,因为Beanstalk代表我生成了实例。


当前回答

在EC2实例的“实例操作”菜单中有一个方便的“连接”选项。它将为您提供使用实例的正确url执行的确切SSH命令。杰布利的全部指示都是正确的。

其他回答

您需要使用ec2实例的公共ip地址直接连接到它。您无法使用elasticbeanstalk url进行连接。

可以通过在ec2控制台中查找实例ip地址。

您还需要确保端口22是开放的。默认情况下,ssh连接完成后,EB CLI会关闭22端口。您可以调用eb ssh -o在ssh会话完成后保持端口开放。

警告:你应该知道弹性豆茎可以在任何时候替换你的实例。在任何弹性豆茎实例上都不能保证状态。最好只将ssh用于测试和调试,因为您所修改的任何内容都可能随时消失。

不久前我也遇到了同样的问题。我想使用密钥文件,但是Amazon在某个地方说不能向现有的EC2服务器添加密钥文件。对于第一个Beanstalk应用程序,Amazon为您预配置了应用程序。您需要创建一个新的应用程序,您可以配置运行Beanstalk应用程序的EC2服务器使用旧的pem文件(如果使用Putty则为ppk),或者您也可以创建一个新的pem文件。现在您应该能够SSH了。

然后配置,然后删除你的旧应用。

如果您已经使用eb init设置了您的环境的CLI,那么它应该是 简单

Eb SSH -设置,它将允许您创建一个新的密钥对或使用一个现有的(如果存在的话)。

您还可以使用eb连接到现有的环境,尽管我还没有这样做。

安装CLI的详细信息- https://docs.aws.amazon.com/console/elasticbeanstalk/eb-cli-install

如果您正在使用elastic bean和EB CLI,只需使用EB ssh登录到实例。您可以使用下列链接中指定的选项 http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/eb3-ssh.html

我在2013年8月使用linux客户端和简单的AWS Beanstalk安装(单个EC2实例)的经验如下(基于上面的Community Wiki)

配置安全组

In the AWS console, select EC2 to go to the EC2 Dashboard Discover the security group to which your EC2 instance belongs by clicking Instances in the left hand panel and then selecting the instance you want to connect to (in my case there is only one - called Default Environment). The details are shown at the base of the page - You should see a field for Security Groups - make a note of the name - in my case "awsweb...". From the left hand panel select Security Groups. Select the awsweb... security group and the details should show at the base of the page Select the Inbound tab and choose SSH from the "Create a New Rule" drop down. Insert the ip address/CIDR of your local machine (from which you intend to connect), e.g. 192.168.0.12/32 and click Add Rule and Apply Rule Changes.

创建公私钥对

在EC2仪表板中,从左手面板中选择Key Pairs 单击密钥对(在顶部)并输入一个名称,如myname-key-pair-myregion或任何您喜欢的有效密钥名称。 确认并接受从浏览器下载私钥,例如将其保存到您的主目录或任何您喜欢的地方。确保该目录只有您的写权限。

将公私钥对关联到Elastic Beanstalk EC2服务器

向Elastic Beanstalk EC2添加公共-私有密钥对 instance do: Services -> Elastic Beanstalk -> My App -> Default Environment将带您到默认环境(您将在其中 上传你的应用) 点击配置(在左手面板),然后在齿轮/齿轮 与“实例”相关的 显示“服务器”页面 从EC2密钥对中选择预构建的密钥参数并保存 将显示一些警告消息,因此请再次保存。

使用SSH连接到AWS EC2实例

在终端会话中,更改到包含您的私钥(。pem文件)。 如果你已经尝试过几次,你可能应该做一些关于.ssh/known_hosts(如果你有一个)的事情,比如重命名它。否则,您可能会得到一个关于主机标识已更改的错误。 执行:ssh -i ./myname-key-pair-my-region。pem ec2 - user@ec2一些address.us -西方- 2. compute.amazonaws.com

祝你好运