To enable ssh use like this:
ssh -i keyname.pem username@xxx.xx.xxx.xx
Where keyname.pem is the name of your private key, username is the correct username for your os distribution, and xxx.xx.xxx.xx is the public IP address.
When it expires or does not work, check the following:
Security group
Make sure for the inbound rule for tcp port 22 and all ips or ip. The security group can be found through the ec2 menu in the instance options.
Routing table
For a new subnet in vpc, you need to change the routing table, which points 0.0.0.0/0 to the target of the Internet gateway . When you create a subnet in your vpc, by default it assigns a default routing table, which probably does not accept incoming traffic from the Internet. You can edit the routing table parameters in the vpc menu, and then subnets.
Elastic IP
For an instance in vpc, you need to assign a public elastic ip address and associate it with the instance. Private IP is not accessible externally. You can get elastic ip in the ec2 menu (and not in the instance menu).
Username
Make sure you use the correct username . It must be one of ec2-user or root or ubuntu . Try them if necessary.
Private key
Make sure that you are using the correct private key (the one you download or select when starting the instance). It seems obvious, but a copy of the paste got me twice.
AJcodez May 29 '15 at 16:21 2015-05-29 16:21
source share