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


当前回答

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

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

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

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

其他回答

我在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

祝你好运

以上答案有点陈旧。

首先创建一个密钥对,然后将其附加到Elastic Beanstalk环境。

创建密钥对的步骤

登录AWS 服务—> EC2 .单击“确定” 在左边的网络和安全下选择密钥对 选择创建新的密钥对,键入密钥名称,然后单击创建。 密钥将自动下载到您的系统中。

将创建的密钥对附加到Elastic Beanstalk环境的步骤

AWS ->服务->弹性豆茎 选择您的环境并单击左侧的配置。 在“配置概览”中选择“安全性”中的“修改”。 在“虚拟机权限”下选择我们创建的密钥对。 单击“保存”,然后单击“保存配置”。

这将花费一些时间反映到您的EC2实例。

我来这里是为了寻找一种方法,在配置期间向Beanstalk创建的实例添加一个键(我们使用Terraform)。您可以在Terraform中执行以下操作:

resource "aws_elastic_beanstalk_environment" "your-beanstalk" {
   ... 
   setting {
      namespace = "aws:autoscaling:launchconfiguration"
      name      = "EC2KeyName"
      value     = "${aws_key_pair.your-ssh-key.key_name}"
   }
   ...
}

然后,您可以使用该密钥SSH进入该盒子。

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

Elastic Beanstalk可以将单个EC2对绑定到实例概要文件。让多个用户ssh进入EBS的手动解决方案是在authorized_keys文件中添加他们的公钥。