Skip to content

Instantly share code, notes, and snippets.

@tmosest
Created September 14, 2016 02:35
Show Gist options
  • Save tmosest/706b748dae6816909fab7efe4bc2a8ee to your computer and use it in GitHub Desktop.
Save tmosest/706b748dae6816909fab7efe4bc2a8ee to your computer and use it in GitHub Desktop.
AWS EC2: Connecting To An Instance.
To open an AWS Instance you:
==========================
Windows Computers
==========================
1) Open Git Bash to the folder that contains my .pem file that you generated with your instance
2) Using Git command prompt you use chmod 400 my.pem to set the correct permissions on my.pem file
3) You then type in “ssh –v –i my.pem ec2-user@my-instance-dns” into Git command prompt to connect
==========================
Mac
==========================
1) Open Terminal
2) Use the cd command to move to the appropriate folder.
3) Type the following command to change the pem key permissions:
> chmod 400 my.pem
4) Connect using:
> ssh –v –i my.pem ec2-user@my-instance-dns
@Rpv5695
Copy link

Rpv5695 commented Jun 30, 2023

It's not working with me.

Giving error :
@ec2-user DNS: Permission denied (publickey,gssapi-keyex,gssapi-with-mic).

@Yash-shetty
Copy link

Hi @NoSubstitute
I'm facing an issue , kindly help me.

$ ssh -i "my_key.pem" ubuntu@my_public_ip.compute.amazonaws.com

ssh: connect to host my_public_ip.ap-south-1.compute.amazonaws.com port 22: Connection timed out


$ ping my_public_ip

Pinging my_public_ip with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.

Ping statistics for my_public_ip:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),

NOTE: Above, I changed original public id address of mine for security purpose.

@NoSubstitute
Copy link

@Yash-shetty the errors you are seeing indicate that your IP isn't actually accessible from the outside. You need to fix that first.
It's probably done in some section that manages the firewall.

I haven't ever used AWS. I just used these same instructions to connect to SSH in Google Cloud.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment