Quantcast
Channel: Sameer Shaik. B.E,M.S,M.B.A,P.M.P,C.S.M
Viewing all articles
Browse latest Browse all 191

How to connect to an AWS EC2 Instance.

$
0
0

Make sure you are able to ping the Public-DNS of the EC2 Instance.  By default you will not be able to ping the instance unless you modify the security group to allow the ICMP traffic.

shaiks@shaikslinux>ping ec2-instace-ip.us-east-2.compute.amazonaws.com
PING ec2-instace-ip.us-east-2.compute.amazonaws.com (instace-ip):
64 bytes from instace-ip: icmp_seq=0 ttl=232 time=22 ms
64 bytes from instace-ip: icmp_seq=1 ttl=232 time=20 ms
64 bytes from instace-ip: icmp_seq=2 ttl=232 time=20 ms

----ec2-instace-ip.us-east-2.compute.amazonaws.com PING Statistics----
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip (ms)  min/avg/max/med = 20/21/22/20
shaiks@shaikslinux>


Now try to connect to the Instance using the private key.

shaiks@shaikslinux>ssh -i "aws_key1.pem" ec2-user@ec2-instace-ip.us-east-2.com                          pute.amazonaws.com
Last login: Wed Oct 11 14:29:40 2017 from 64.251.40.241

       __|  __|_  )
       _|  (     /   Amazon Linux AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-ami/2017.09-release-notes/
No packages needed for security; 1 packages available
Run "sudo yum update" to apply all updates.


[ec2-user@ip-172-31-46-150 ~]$ id
uid=500(ec2-user) gid=500(ec2-user) groups=500(ec2-user),10(wheel)



update the packages:

[ec2-user@ip-172-31-46-150 ~]$ sudo yum update
Loaded plugins: priorities, update-motd, upgrade-helper
amzn-main                                                | 2.1 kB     00:00
amzn-updates                                             | 2.5 kB     00:00
Resolving Dependencies
--> Running transaction check
---> Package amazon-ssm-agent.x86_64 0:2.1.4.0-1.amzn1 will be updated
---> Package amazon-ssm-agent.x86_64 0:2.2.16.0-1.amzn1 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package              Arch       Version                 Repository        Size
================================================================================
Updating:
 amazon-ssm-agent     x86_64     2.2.16.0-1.amzn1        amzn-updates     9.1 M

Transaction Summary
================================================================================
Upgrade  1 Package

Total download size: 9.1 M
Is this ok [y/d/N]: y
Downloading packages:
amazon-ssm-agent-2.2.16.0-1.amzn1.x86_64.rpm         | 9.1 MB  00:00:01
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : amazon-ssm-agent-2.2.16.0-1.amzn1.x86_64      1/2
  Cleanup    : amazon-ssm-agent-2.1.4.0-1.amzn1.x86_64       2/2
  Verifying  : amazon-ssm-agent-2.2.16.0-1.amzn1.x86_64      1/2
  Verifying  : amazon-ssm-agent-2.1.4.0-1.amzn1.x86_64       2/2

Updated:
  amazon-ssm-agent.x86_64 0:2.2.16.0-1.amzn1

Complete!

Change to root user and modify the password for ec2-user.

[ec2-user@ip-172-31-46-150 ~]$ sudo su -
[root@ip-172-31-46-150 ~]# id
uid=0(root) gid=0(root) groups=0(root)
[root@ip-172-31-46-150 ~]# passwd ec2-user
Changing password for user ec2-user.
New password:
BAD PASSWORD: The password is shorter than 8 characters

[root@ip-172-31-46-150 ~]# passwd ec2-user
Changing password for user ec2-user.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.


[root@ip-172-31-46-150 ~]#



Viewing all articles
Browse latest Browse all 191

Trending Articles