简体   繁体   English

ec2 上的 SSH 连接

[英]SSH connection on ec2

I'm trying to connect to an AWS ec2 instance but I keep being refused.我正在尝试连接到 AWS ec2 实例,但一直被拒绝。 I'm using the same computer, the same wifi but suddenly when I connect to one of my ec2 instance, it fails.我使用的是同一台计算机,同样的 wifi,但突然当我连接到我的 ec2 实例之一时,它失败了。

when I connect, it says..当我连接时,它说..

ssh -i successintoeflcom.pem ec2-user@52.68.152.179
ssh: connect to host 52.68.152.179 port 22: Connection refused

ssh -v successintoeflcom.pem ec2-user@52.68.152.179
OpenSSH_6.2p2, OSSLShim 0.9.8r 8 Dec 2011
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 26: Applying options for *
ssh: Could not resolve hostname successintoeflcom.pem: nodename nor servname provided, or not known

I looked at /etc/ssh_config line 26, and found我查看了 /etc/ssh_config 第 26 行,发现

Host *
   SendEnv LANG LC_*

something got to be wrong, but I haven't found a way to make it right.一定是出了什么问题,但我还没有找到一种方法来纠正它。

I also tried deleting the ec2 instance and make new one with new ssh key and new EIP but it did not work.我还尝试删除 ec2 实例并使用新的 ssh 密钥和新的 EIP 创建一个新实例,但它不起作用。 honestly, I'm new to ssh settings.老实说,我是 ssh 设置的新手。 Any help would be appreciated.任何帮助,将不胜感激。

PS For some reason, I was able to connect to other ec2 instance that is on other aws account, which I use for work. PS 由于某种原因,我能够连接到其他 aws 帐户上的其他 ec2 实例,我将其用于工作。

  • Check the Security groups inbound settings, make sure ssh protocol enabled with source as anywhere.检查安全组入站设置,确保启用 ssh 协议并在任何地方使用源。 Because your System IP address might change.因为您的系统 IP 地址可能会更改。

  • Check with .pem file permission.检查 .pem 文件权限。 It should be set with chmod 600.它应该用 chmod 600 设置。

Start with checking the VPC configuration: ensure the internet gateway is associated properly with the subnet;首先检查 VPC 配置:确保 Internet 网关与子网正确关联; ensure the SSH port (22) is opened in both the security group and the network ACL.确保在安全组和网络 ACL 中都打开了 SSH 端口 (22)。 You can follow the guide and the troubleshooting described in the blog-post configure VPC and create SSH connection to a Linux-based EC2 .您可以按照博客文章中描述的指南和故障排除配置 VPC 并创建到基于 Linux 的 EC2 的 SSH 连接 It touches the traffic rules configuration and explains how to define the SSH keys properly.它涉及交通规则配置并解释了如何正确定义 SSH 密钥。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM