Skip to content

Jinkxed/AWS.EC2.SSH.Autocomplete

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

AWS EC2 SSH Autocompletion

A couple scripts to auto-populate your .ssh/config file with a list of hosts from your AWS_EC2 Name tags.

What these scripts will do, so please becareful.

  • Overwrite your home/.ssh/config file
  • Add autocompletion on MAC OSX in terminal: ssh someserver
  • Magic

Note: I have a standard user I use on my instances whether it be my ldap user or the default ec2-user, this is set statically for all instances. You will have to modify the updateSSH.sh file if you use another user. (ie: ubuntu, root, whatever)

Installation

You need will need to have brew installed:

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install dependencies:
$ brew install bash-completion jq awscli
$ sudo easy_install pip
$ pip install boto
Clone the repo:
$ git clone https://github.com/chad-upton/AWS.EC2.SSH.Autocomplete.git
$ cd AWS.EC2.SSH.Autocomplete
Add your ec2 keypairs to your keychain
  • Browse to your ec2_keypair.pem file that you created your instance with and right click -> open with keychain app
Add your EC2 Access Key & Secret Keys

Note: One thing you can do and most have done, is add these to your ~/.bashrc with lines 12-15 so not to have them stored in multiple places. If you do that you will just need to source ~/.bashrc instead.

$ vim updateSSH.sh
Line6: Uncomment and edit: export AWS_ACCESS_KEY_ID='AK123'
Line7: Uncomment and edit: export AWS_SECRET_ACCESS_KEY='abc123'
$ :wq to save
Add Autocomplete to your home/.bashrc
vim ~/.bashrc
# Autocompletion
  if [ -f $(brew --prefix)/etc/bash_completion ]; then
    . $(brew --prefix)/etc/bash_completion
  fi
Copy ec2inventory to /usr/local/bin (optional but make note of paths in updateSSH.sh)
$ cp ec2inventory /usr/local/bin
Copy ec2.ini to /usr/local/bin (optional but again make note of paths)
$ cp ec2.ini /usr/local/bin
Run ec2inventory to make sure it's working
$ source updateSSH.sh (or ~/.bashrc)
$ ec2inventory
You should get a giant output of metadata about your ec2 environment. If no errors then run:
$ updateSSH.sh

If you do get errors, double check your paths are correct and you've added the access/secret keys.

Check your ~/.ssh/config file for new entries
$ cat ~/.ssh/config
Should now see a list of hosts setup like this:
Host some_name_tag
    HostName some_private_ip
    User some_user
Test Autocompletion
$ ssh some_name_

Notes

Line 38 to: ip_address

Development

Want to contribute? Great!

About

AWS EC2 SSH Autocompletion for Mac OSX

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published