Iftikhar Hossain Iftikhar Hossain - 8 months ago 57
Bash Question

AWS multiple instance connect through ssh from command line (without remembering keypairname and user)

I have four AWS accounts with more than 50 instances. Daily I have to connect most of them. So every time when I want to connect instances through ssh, have to login AWS accounts first and then have to find the keypair name and IP. Because it's very difficult to remember all IP's and keypair. So I want tools or scripts to make it easily done without remembering the keypair name and user.

Notes: I have downloaded keypair
connect via ssh from command line: ssh -i kepairname user@IP


You can use ~/.ssg/config options. Someting like that:

Host server1
User user1
IdentityFile kepairname1

Host server2
User user2
IdentityFile kepairname2

After that you will be able to connect to your hosts just with

ssh server1
ssh server2

If you use any other options, any of them can be added to that config. As always, full info in man ssh_config.