This post assumes the user has logged in to the AWS management console and launched the EC2 instance already.
To know how to launch an EC2 instance refer to the following link:
To connect to the EC2 instance that has a Public IP
Method 1 – EC2 Instance Connect
From the EC2 management console, select the Instance and click connect, and by default EC2 Instance Connect would be selected with the user ec2-user (or use the custom username) and press connect.
Method 2 – SSH Client
Open the command prompt and go to the folder where the key pairs that you created while launching the EC2 instance are stored. (.pem file)
Right click EC2 instance > connect > select SSH client tab
Copy the example ssh command > paste it in the command prompt.
It will warn about the authenticity of host, you can ignore it and type “yes” and enter. You should be able to enter to the EC2 instance however if you get an error saying that “Permissions for ‘…pem’ are too open then you need to revoke permissions of the file.
Copy the .pem file in windows folder and paste it into “C:\Users\Admin.ssh” and run command prompt from that folder and try to connect. It should connect to the EC2 Instance.
Method 3 – Session Manager
Session Manager provides secure and auditable instance management without the need to open inbound ports, maintain bastion hosts, or manage SSH keys.
EC2 session manager requires a SSM role attached to the EC2 instances.
Go to IAM management console > Roles > Create Role
Select EC2 > Next:Permissions and search for “AmazonEC2RoleforSSM” and select it > Next: Tags >
Name: SSMRole (or as per company standards) > Next: Review > Role Name > SSMRole-for-EC2-sessions (or any) > Create Role
Setup Systems Manger
Get started with quick setup for “Customize Host Management configuration options” get to the end with default value and Create. (It might take up to 30 minutes)
On the System Manager Console > Node Management > Session Manager > Start Session
You will now see the EC2 instance that has IAM role attached and you can start the session to connect to the EC2
Go bak to EC2 console > right click the instance > connect > Session Manger > Connect. You are able to connect via session manager
That’s all folks !!
[…] the instance is Private, it is not accessible via internet (or normal methods). To overcome this use SSH Agent forwarding to securely connect to the Private Linux Instance via […]