How to Login to AWS Ec2 instances without using SSH keypair

      Comments Off on How to Login to AWS Ec2 instances without using SSH keypair

Whenever we launch an instance into amazon ec2, we should create one keypair before the instance launches. So that we can ssh into the instance using that key.

==> Usually we would login to aws ubuntu server using the following command,

$ ssh -i bigin.pem [email protected]ec2-YY-YY-YY-YY.ap-northeast-1.compute.amazonaws.com

$ ssh -i bigin.pem [email protected]ec2-YY-YY-YY-YY.ap-northeast-1.compute.amazonaws.com

==> But in this case we need to give ssh keypair everytime, it would be little difficult to select the correct path and key everytime

==> To make ssh connection to ec2 instances without keypair we can send our ssh public key[id_rsa.pub] to the remote ec2 instance, for that

=> we should make sure we have the ssh-agent running in our system to establish secure communication to remote instance,

$ eval $(ssh-agent)

Agent pid 10538

=> Then we should add our keypair,

$ ssh-add /home/user/Downloads/zzz.pem

Identity added: /home/user/Downloads/zzz.pem (/home/user/Downloads/zzz.pem)

=> Then use the normal ssh-copy-id command

:~/.ssh$ ssh-copy-id -i id_rsa.pub [email protected]

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "id_rsa.pub"

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

Number of key(s) added: 1

Now try logging into the machine, with: "ssh '[email protected]'"

and check to make sure that only the key(s) you wanted were added.

=> After copy our key to ec2 instance using that command we can login to instance without keypair.

$ ssh [email protected]

Welcome to Ubuntu 14.04.3 LTS (GNU/Linux 3.13.0-74-generic x86_64)

* Documentation: https://help.ubuntu.com/

System information as of Sun Oct 2 05:40:18 UTC 2016

System load: 0.02 Processes: 99

Usage of /: 10.0% of 7.74GB Users logged in: 0

Memory usage: 5% IP address for eth0: ZZ.ZZ.ZZ.ZZ

Swap usage: 0%

Graph this data and manage this system at:

https://landscape.canonical.com/

Get cloud support with Ubuntu Advantage Cloud Guest:

http://www.ubuntu.com/business/services/cloud

0 packages can be updated.

0 updates are security updates.

New release '16.04.1 LTS' available.

Run 'do-release-upgrade' to upgrade to it.

Last login: Sun Oct 2 05:37:06 2016 from AA.AA.AA.AA

[[email protected] ~]$

==> You can also use IP address of the instance to login to instance..

Sharing is caring!

About Dinesh Sobitharaj C

An IT professional having multiple years of experience in IT Infrastructure planning, System integrations, Project implementation and delivery. Devops Enthusiast skilled with broad ranges of technology adoption. Well versed with Cloud Computing and Application Service Offerings such as SaaS/PaaS/IaaS. Expert in aligning business goals, mission and process to architect innovative solutions and strategies.