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
@itsandip
Copy link

itsandip commented May 7, 2021

I tried to login aws EC2 ubuntu instance using gitbash but getting error as below :
ssh: Could not resolve hostname \342\200\223v: Temporary failure in name resolution

@NoSubstitute
Copy link

The two first dashes on line 27 are the wrong kind.
This will not work.
ssh –v –i my.pem ec2-user@my-instance-dns

This will work.
ssh -v -i my.pem ec2-user@my-instance-dns

@tmosest
Copy link
Author

tmosest commented Aug 28, 2022

Thanks 🙏! I didn’t realize the typo. Probably copied from word instead of note pad ++ or something dumb like that. I usually just type it in, create an alias, or use my terminal history.

I’ll try to update it tomorrow though.

@RajeswariSuresh
Copy link

Hi

line 9: Bad configuration option: ehost in gbash how to resolve this

@NoSubstitute
Copy link

@RajeswariSuresh this is not a script. You can't run it as it is. It's an instruction.
You have to read it and do what it says.

@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