/sshaws

SSH Helper for AWS

Primary LanguageGoMIT LicenseMIT

SSHAWS

sshaws is a helper to simplify the AWS instances ssh access.

It will show a list of instances depending on some specified tags and help you to ssh on it.

Getting Started

usage: sshaws [--silent true] [--region xx_yy_j] [-l user ] [-ssh true] [-k true] [instance_name]

Examples

# List all the instances from eu-west-1
> sshaws

Name: *   Region: eu-west-1
---------------------------------------------------------

[0] front-prod-1 - 172.16.31.12 (i-0978df6a92b39d434, t2.nano)
[1] front-prod-2 - 172.16.24.226 (i-0b3914e83516392378, t2.nano)
[2] front-staging - 172.16.39.121 (i-0b3914e89237829ad1, t2.micro)
[3] back-prod - 172.16.33.21 (i-0b3914421237829ad1, t3.large)
[4] back-staging - 172.16.19.93 (i-0b391351e237829ad1, t3.micro)

Which one do you want to ssh in?
# WAITING INPUT FROM USER
3
>> Starting a new ssh session to 172.16.33.21
[...] Stablishing SSH connection with the desired server
# List all the instances with front on name, from eu-west-1
> sshaws front

Name: front   Region: eu-west-1
---------------------------------------------------------

[0] front-prod-1 - 172.16.31.12 (i-0978df6a92b39d434, t2.nano)
[1] front-prod-2 - 172.16.24.226 (i-0b3914e83516392378, t2.nano)

Which one do you want to ssh in?
# WAITING INPUT FROM USER
0
>> Starting a new ssh session to 172.16.31.12
[...] Stablishing SSH connection with the desired server

Usage in depth

Download the binary in this repository and execute it, or compile by yourself following the next steps.

sshaws
  --name | -n
        Instance Name (default "*")
  --k true
        Push a temporary private key to a desired instance
  -l string
        SSH login name (default "")
  --region
        AWS Region (default "eu-west-1")
  --silent | -s
        Show only matching instances IPs
  --ssh true
        By default the connection is with ssm, the option ssh true, allow you connect with it.
  --version | -v
        Show sshaws version
  --help | -h
        Show this text

Diagram

The flow to connect EC2:

Prerequisites

Client requirements

There are some basic prerequisites :

  • AWS CLI tool

  • Configure your credentials ~/.aws/ with the correct keys.

  • ~/.aws/config

[default]
region = eu-west-1
  • ~/.aws/credentials
[default]
aws_access_key_id = AKIAXXXXXXXXXXXXX
aws_secret_access_key = xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
  • [OPTIONAL] Session Manager Plugin. If you want to connect using ssm.
  • SSH: You will need ssh, and, if necessary, configure the ssh connection (The configuration in ~/.ssh/configuration will be applied to awssh).
  • [OPTIONAL] Golang: If you want to compile sshaws you will need the golang executable.

Server requirements

  • [OPTIONAL] ec2-instance-connect: If you want to copy the keys to the server, you will need to install ec2-instance-connect package in the server
Installing

From binary

For Linux

# Download latest version from https://github.com/uritau/sshaws/releases/latest
sudo wget -O /usr/local/bin/sshaws https://github.com/uritau/sshaws/releases/latest/download/sshaws

# Give it execution permissions
sudo chmod +x /usr/local/bin/sshaws

For MAC

# Download latest version from https://github.com/uritau/sshaws/releases/latest
sudo wget -O /usr/local/bin/sshaws https://github.com/uritau/sshaws/releases/latest/download/sshaws.mac

# Give it execution permissions
sudo chmod +x /usr/local/bin/sshaws

From source code

After downloading this repository:

# Enter repository folder
cd sshaws

# Build the binary
go build -o sshaws cmd/sshaws/main.go

# Move to a desired folder
sudo mv sshaws /usr/local/bin/sshaws

Running the tests

# Run the test recursively
go test ./...

Built With

Contributing

Please create a fork and create a PR! It would be awesome to have new proposals!

Versioning

Travis is configured to automatically build and update the version. (You can change the current version on version.go).

Authors

License

This project is licensed under the MIT License - see the LICENSE.md file for details