Git Product home page Git Product logo

aws_ssh_commander's Introduction

AWS_SSH_commander

A bash script for running bash commands through ssh to AWS EC2 instances. Output is displayed on the host box and is seperated by a line of equal signs. Tested on instances using Amazon linux AMI and Centos 6.

Getting started

First, clone the repository using git (recommended):

git clone https://github.com/DdPerna/AWS_SSH_commander.git

or download the script manually using this command:

curl "https://raw.githubusercontent.com/AWS_SSH_commander/ssh_commander.sh" -o ssh_commander.sh

Then give the execution permission to the script and run it:

 $chmod +x ssh_commander.sh
 $./ssh_commander.sh

Credentials

In order to make API calls to AWS you will need the appropriate authenication credentials.

  1. If running the script from an instance in AWS it is recommended to assign an IAM role to that instance at launch.
  2. Or pass the credentials into the ~/.aws/credentials file

Creating an IAM Role

Setting up local credentials

  • Located in the user's home directory. Create the file ~/.aws/credentials
[default]
aws_access_key_id = ACCESS_KEY_ID
aws_secret_access_key = ACCESS_KEY

Setup

The script is setup to accept a region and two tag values followed by the bash commands, or a flag to indicate a file location. This can be customized to your specific needs by customizing the filters section of the aws api call.

  • For Example: to limit your search to instances with a tag called "Environment" that equals the value of the user's second input

ENVIR=$2

--filters "Name=tag:Environment,Values=$ENVIR"

Keys

The ssh connection is established with the ec2-user account and requires passing the required key for authenication. The script looks at which region is passed in to select the key, but this can be changed to your use case.

Considerations

Sending Bash Commands over ssh can be strict and take some troubleshooting. for example, using cd and executing a script on a remote instance

./ssh_commander us-east-1 Stage APP 'sudo /bin/sh -c "cd /home/example && ./script.sh"'

aws_ssh_commander's People

Contributors

ddperna avatar

Watchers

 avatar

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.