Giter Site home page Giter Site logo

aws.ec2.ssh.autocomplete's Introduction

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!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.