ssh:连接到主机 ec2-xxxxxxxx.compute-1.amazonaws.com 端口 22:连接被拒绝

ssh: connect to host ec2-xxxxxxxx.compute-1.amazonaws.com port 22: Connection refused

我先列出emr集群:

✗ aws emr list-clusters
{
    "Clusters": [
        {
            "Id": "j-MQIKB378OARL",
            "Name": "Spark cluster",
            "Status": {
                "State": "WAITING",
                "StateChangeReason": {
                    "Message": "Cluster ready after last step failed."
                },
                "Timeline": {
                    "CreationDateTime": 1524200251.319,
                    "ReadyDateTime": 1524201100.225
                }
            },
            "NormalizedInstanceHours": 6
        },

然后我尝试连接:

✗ aws emr ssh --cluster-id j-MQIKB378OARL --key-pair-file ~/.ssh/keys/key-pair.pem
ssh -o StrictHostKeyChecking=no -o ServerAliveInterval=10 -i /Users/myuser/.ssh/keys/key-pair.pem hadoop@ec2-xxxxxxxxxx.compute-1.amazonaws.com -t
ssh: connect to host ec2-xxxxxxxxxx.compute-1.amazonaws.com port 22: Connection refused

我是不是漏掉了什么?

  1. 编辑安全组ElasticMapReduce-...
  2. 编辑端口 22 的源 IP
  3. 不正确
  4. 更新到您的源 ip 或任何地方。

您的实例的安全组似乎不允许传入的 ssh 流量。

来自AWS Documentation

Security groups enable you to control traffic to your instance, including the kind of traffic that can reach your instance. For example, you can allow computers from only your home network to access your instance using SSH. If your instance is a web server, you can allow all IP addresses to access your instance using HTTP or HTTPS, so that external users can browse the content on your web server.

要使用控制台为通过 IPv4 的入站 SSH 流量向安全组添加规​​则:

  1. 在 Amazon EC2 控制台的导航窗格中,选择实例。 Select 您的实例并查看 Description 选项卡;安全组列出与实例关联的安全组。选择查看规则以显示对实例有效的规则列表。

  2. 在导航窗格中,选择安全组。 Select 与您的实例关联的安全组之一。

  3. 在详细信息窗格的“入站”选项卡上,选择“编辑”。在对话框中,选择添加规则,然后从类型列表中选择 SSH。

  4. 在“来源”字段中,选择“我的 IP”以使用本地计算机的 public IPv4 地址自动填充该字段。或者,选择自定义并以 CIDR 表示法指定计算机或网络的 public IPv4 地址。例如,如果您的 IPv4 地址是 203.0.113.25,请指定 203.0.113.25/32 以 CIDR 表示法列出此单个 IPv4 地址。如果贵公司从一个范围内分配地址,请指定整个范围,例如 203.0.113.0/24.

  5. 选择保存。