SSH connection on ec2

1.1k views Asked by At

I'm trying to connect to an AWS ec2 instance but I keep being refused. I'm using the same computer, the same wifi but suddenly when I connect to one of my ec2 instance, it fails.

when I connect, it says..

ssh -i successintoeflcom.pem [email protected]
ssh: connect to host 52.68.152.179 port 22: Connection refused

ssh -v successintoeflcom.pem [email protected]
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

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. honestly, I'm new to ssh settings. 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.

2

There are 2 answers

1
Ramprasad On
  • Check the Security groups inbound settings, make sure ssh protocol enabled with source as anywhere. Because your System IP address might change.

  • Check with .pem file permission. It should be set with chmod 600.

0
Lior Kirshner On

Start with checking the VPC configuration: ensure the internet gateway is associated properly with the subnet; ensure the SSH port (22) is opened in both the security group and the network ACL. You can follow the guide and the troubleshooting described in the blog-post configure VPC and create SSH connection to a Linux-based EC2. It touches the traffic rules configuration and explains how to define the SSH keys properly.