All Projects → h3poteto → zsh-ec2ssh

h3poteto / zsh-ec2ssh

Licence: MIT license
zsh plugin to list up EC2 instances and ssh login the instances.

Programming Languages

shell
77523 projects

Projects that are alternatives of or similar to zsh-ec2ssh

Kitchen Ec2
A Test Kitchen Driver for Amazon EC2
Stars: ✭ 211 (+2010%)
Mutual labels:  ec2
amazon-cloudwatch-auto-alarms
Automatically create and configure Amazon CloudWatch alarms for EC2 instances, RDS, and AWS Lambda using tags for standard and custom CloudWatch Metrics.
Stars: ✭ 52 (+420%)
Mutual labels:  ec2
dog
A firewall management system.
Stars: ✭ 67 (+570%)
Mutual labels:  ec2
Keymaker
Lightweight SSH key management on AWS EC2
Stars: ✭ 221 (+2110%)
Mutual labels:  ec2
Aws Toolkit Eclipse
AWS Toolkit for Eclipse – an open-source plugin for developing, deploying, and managing AWS applications.
Stars: ✭ 252 (+2420%)
Mutual labels:  ec2
tumult.plugin.zsh
Tumult is a collection of macOS-specific functions and scripts for your shell environment. It is packaged as a ZSH plugin, but can be used with other shells as well.
Stars: ✭ 147 (+1370%)
Mutual labels:  zsh-plugins
Aws Cost Saver
A tiny CLI tool to help save costs in development environments when you're asleep and don't need them!
Stars: ✭ 178 (+1680%)
Mutual labels:  ec2
traefik-cluster-ecs
This is a tutorial on how to deploy a Traefik Load Balancer in AWS using CloudFormation to load balancer development ECS tasks using hosts (FQDN).
Stars: ✭ 62 (+520%)
Mutual labels:  ec2
dotfiles
⚫️ ~ is where the ♥ is - my dotfiles.
Stars: ✭ 94 (+840%)
Mutual labels:  zsh-plugins
ocaml-aws
Generated OCaml bindings for Amazon Web Services
Stars: ✭ 126 (+1160%)
Mutual labels:  ec2
Aws Ssh Config
Generate SSH config files from AWS EC2 inventory
Stars: ✭ 229 (+2190%)
Mutual labels:  ec2
Laravel Aws Eb
Ready-to-deploy configuration to run Laravel on AWS Elastic Beanstalk.
Stars: ✭ 247 (+2370%)
Mutual labels:  ec2
terraform-aws-eks-workers
Terraform module to provision an AWS AutoScaling Group, IAM Role, and Security Group for EKS Workers
Stars: ✭ 82 (+720%)
Mutual labels:  ec2
Awsssmchaosrunner
Amazon's light-weight library for chaos engineering on AWS. It can be used for EC2, ECS (with EC2 launch type) and Fargate.
Stars: ✭ 214 (+2040%)
Mutual labels:  ec2
amazon-ec2-image-builder-samples
Samples for Amazon EC2 Image Builder
Stars: ✭ 103 (+930%)
Mutual labels:  ec2
Gossm
💻Interactive CLI tool that you can connect to ec2 using commands same as start-session, ssh in AWS SSM Session Manager
Stars: ✭ 192 (+1820%)
Mutual labels:  ec2
ecs-ansible-packer-terraform-wordpress
Proof of concept: Install wordpress environment using ansible, packer, docker, terraform and AWS.
Stars: ✭ 29 (+190%)
Mutual labels:  ec2
vpc-peering-operator
A Kubernetes Operator to manage the lifecycle of AWS VPC Peering Connections
Stars: ✭ 23 (+130%)
Mutual labels:  ec2
getting-into-consul
A zero to complete walk through of setting up HashiCorp Consul on AWS from scratch!
Stars: ✭ 56 (+460%)
Mutual labels:  ec2
terraform-aws-ec2
Terraform module to create an EC2 resource on AWS with Elastic IP Addresses and Elastic Block Store.
Stars: ✭ 33 (+230%)
Mutual labels:  ec2

zsh-ec2ssh

zsh-ec2ssh lists up EC2 instances on your AWS account, and you can choose an instance graphically. Then zsh-ec2ssh issues a ssh command to login that instance.

You often login EC2 instances if you are using AWS. Sometimes, you automate server generation, for example using autoscaling group; therefore, IP Addresses are not fixed. In that case, you need to look up the IP Addresses before ssh login. zsh-ec2ssh can make that work easier.

Demo

demo

I used shortcut key in the first half of this demo. And next, I wrote zsh-ec2ssh command to call the function.

Install

zplug

After you setup zplug, write this line in your ~/.zshrc:

zplug "h3poteto/zsh-ec2ssh"

and, install.

$ zplug install

Manually

Cloning from GitHub, and source in your ~/.zshrc:

$ git clone https://github.com/h3poteto/zsh-ec2ssh.git

Requirements

After you install myaws, please set your AWS credentials in ~/.aws/credentials:

[default]
aws_access_key_id = XXXXXX
aws_secret_access_key = XXXXXX

Usage

Login an instance

Please write shortcut setting in your ~/.zshrc:

AWS_PROFILE_NAME=default
AWS_DEFAULT_REGION=ap-northeast-1
SSH_USER=h3poteto
SSH_PRIVATE_KEY_PATH=$HOME/.ssh/id_rsa
SSH_PORT=22

function zsh-ec2ssh-default() { zsh-ec2ssh $AWS_PROFILE_NAME $AWS_DEFAULT_REGION $SSH_USER $SSH_PRIVATE_KEY_PATH $SSH_PORT }
zle -N zsh-ec2ssh-default
bindkey '^t' zsh-ec2ssh-default # Ctrl + t

Using proxy server

If you prepared proxy server in AWS to login the instance, you can use zsh-ec2ssh-with-proxy. At the first, this function lists up EC2 instances to choose the proxy server. Next, this function lists up instances once again to choose the login target server.

Please write shortcut setting in your ~/.zshrc:

AWS_PROFILE_NAME=production
AWS_DEFAULT_REGION=ap-northeast-1
SSH_USER=h3poteto
SSH_PRIVATE_KEY_PATH=/var/opt/keys/.ssh/private.pem
SSH_PORT=22
AWS_PROXY_PROFILE=proxy
SSH_PROXY_USER=proxy-login-user
SSH_PROXY_PRIVATE_KEY_PATH=$HOME/.ssh/id_rsa
SSH_PROXY_PORT=22

function zsh-ec2ssh-production-proxy() { zsh-ec2ssh-with-proxy $AWS_PROFILE_NAME $AWS_DEFAULT_REGION $SSH_USER $SSH_PRIVATE_KEY_PATH $SSH_PORT $AWS_PROXY_PROFILE $SSH_PROXY_USER $SSH_PROXY_PRIVATE_KEY_PATH $SSH_PROXY_PORT }
zle -N zsh-ec2ssh-production-proxy
bindkey '^p' zsh-ec2ssh-production-proxy # Ctrl + p

Your machine --(ssh using SSH_PROXY_USER, SSH_PROXY_PRIVATE_KEY_PATH and SSH_PROXY_PORT)--> proxy server --(ssh using SSH_USER, SSH_PRIVATE_KEY_PATH and SSH_PORT)--> target server

Arguments

zsh-ec2ssh

Argument Description Default
AWS_PROFILE_NAME AWS profile name which instances are located. AWS_DEFAULT_PROFILE environment variables
AWS_DEFAULT_REGION AWS region name which instances are located. AWS_DEFAULT_REGION environment variables
SSH_USER User name to login the server. USER environment variables
SSH_PRIVATE_KEY_PATH Private key path of ssh. $HOME/.ssh/id_rsa
SSH_PORT Port to use ssh. 22

zsh-ec2ssh-with-proxy

Argument Description Default
AWS_PROFILE_NAME AWS profile name which target instances are located. AWS_DEFAULT_PROFILE environment variables
AWS_DEFAULT_REGION AWS region name which target instances are located. AWS_DEFAULT_REGION environment variables
SSH_USER User name to login target server. USER environment variables
SSH_PRIVATE_KEY_PATH Private key path which is used login to target server. $HOME/.ssh/id_rsa
SSH_PORT Port which is used login to target server. 22
AWS_PROXY_PROFILE AWS profile name which proxy server are located. AWS_DEFAULT_PROFILE environment variables
SSH_PROXY_USER User name to login proxy server. USER environment variables
SSH_PROXY_PRIVATE_KEY_PATH Private key path to login proxy server. $HOME/.ssh/id_rsa
SSH_PROXY_PORT Port which is used ssh login to proxy server. 22

License

The application is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].