All Projects → danihodovic → Generate Ssh Configs

danihodovic / Generate Ssh Configs

Licence: mit
Automatically generate ssh config files for your cloud servers

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to Generate Ssh Configs

Control
Control manages the lifecycle of clusters on your infrastructure and allows deployment of applications via HELM. Its deployment and configuration workflows will help you to get up and running with Kubernetes faster.
Stars: ✭ 680 (+400%)
Mutual labels:  aws, digitalocean
Xiringuito
SSH-based "VPN for poors"
Stars: ✭ 969 (+612.5%)
Mutual labels:  aws, ssh
Opscloud
运维管理平台(阿里云),自动同步阿里云配置信息,堡垒机(容器),批量运维,Kubernetes,Zabbix管理等功能
Stars: ✭ 788 (+479.41%)
Mutual labels:  aws, ssh
Bastillion Ec2
A web-based SSH console to execute commands and manage multiple EC2 instances simultaneously running on Amazon Web Services (AWS).
Stars: ✭ 410 (+201.47%)
Mutual labels:  aws, ssh
Black.box
Plug-and-Play VPN router and unblocker
Stars: ✭ 89 (-34.56%)
Mutual labels:  aws, digitalocean
Gbt
Highly configurable prompt builder for Bash, ZSH and PowerShell written in Go.
Stars: ✭ 457 (+236.03%)
Mutual labels:  aws, ssh
Caprover
Scalable PaaS (automated Docker+nginx) - aka Heroku on Steroids
Stars: ✭ 7,964 (+5755.88%)
Mutual labels:  aws, digitalocean
Engine
Deploy your apps on any Cloud provider in just a few seconds
Stars: ✭ 1,132 (+732.35%)
Mutual labels:  aws, digitalocean
Sshremotekeys
Managing SSH keys remotely to control access to hosts
Stars: ✭ 70 (-48.53%)
Mutual labels:  aws, ssh
Module Security Public
The public documentation for the gruntwork-io/module-security repo, which contains packages for setting up best practices for managing secrets, credentials, and servers
Stars: ✭ 67 (-50.74%)
Mutual labels:  aws, ssh
Bridgy
cloud inventory + ssh + tmux + sshfs
Stars: ✭ 374 (+175%)
Mutual labels:  aws, ssh
Typhoon
Minimal and free Kubernetes distribution with Terraform
Stars: ✭ 1,397 (+927.21%)
Mutual labels:  aws, digitalocean
Aws Gate
Better AWS SSM Session manager CLI client
Stars: ✭ 294 (+116.18%)
Mutual labels:  aws, ssh
Porter
Kubernetes powered PaaS that runs in your own cloud.
Stars: ✭ 498 (+266.18%)
Mutual labels:  aws, digitalocean
Cloudscraper
CloudScraper: Tool to enumerate targets in search of cloud resources. S3 Buckets, Azure Blobs, Digital Ocean Storage Space.
Stars: ✭ 276 (+102.94%)
Mutual labels:  aws, digitalocean
Aws Ec2 Ssh
Manage AWS EC2 SSH access with IAM
Stars: ✭ 796 (+485.29%)
Mutual labels:  aws, ssh
Komiser
☁️ Cloud Environment Inspector 👮🔒 💰
Stars: ✭ 2,684 (+1873.53%)
Mutual labels:  aws, digitalocean
Bless
Repository for BLESS, an SSH Certificate Authority that runs as a AWS Lambda function
Stars: ✭ 2,627 (+1831.62%)
Mutual labels:  aws, ssh
Ec2connect
Stars: ✭ 53 (-61.03%)
Mutual labels:  aws, ssh
S3 Beam
🚀 direct-to-S3 uploading using ClojureScript
Stars: ✭ 91 (-33.09%)
Mutual labels:  aws, digitalocean

generate-ssh-configs

Description

generate-ssh-configs reads cloud providers API and generates ssh config files for you. This is especially useful when dealing with tens or hundreds of servers.

The program writes to stdout. Using shell redirection we can write persistent config files and include them using the ssh Include directive.

Examples

Prerequisites

Install generate-ssh-configs

go get github.com/danihodovic/generate-ssh-configs

Ensure your ssh config includes all the config files in the ssh directory.

cat ~/.ssh/.config
# ...at the bottom of the file...
Include ~/.ssh/config-*

Ensure your AWS credentials have been configured if using AWS

See https://docs.aws.amazon.com/sdk-for-go/v1/developer-guide/configuring-sdk.html

Ensure $DIGITAL_OCEAN_TOKEN is set if using DigitalOcean

See https://www.digitalocean.com/docs/api/create-personal-access-token/

Generate ssh configs for all AWS instances

Uses the current AWS region (AWS_DEFAULT_REGION) and generates all configs using the EC2 API.

generate-ssh-configs aws --prefix myservers --user myuser > ~/.ssh/config-myservers

AWS multi-region, multi-environment setup

Using multiple regions, environments and jumphosts for each region and environment. This works if all of your environments are contained in a single AWS account and separated by VPC and tags.

# Generate configs for dev,test,prod in eu-west-1
AWS_DEFAULT_REGION=eu-west-1 generate-ssh-configs aws \
    --prefix myorg-dev-eu-west-1 \
    --filters 'Name=tag:Environment,Values=dev'
    --jumphost jumphost --user dani \
    > ~/.ssh/config-myorg-dev-eu-west-1

AWS_DEFAULT_REGION=eu-west-1 generate-ssh-configs aws \
    --prefix myorg-prod-eu-west-1 \
    --filters 'Name=tag:Environment,Values=prod' \
    --jumphost jumphost \
    --user dani  \
    > ~/.ssh/config-myorg-prod-eu-west-1


# Generate configs for dev,test,prod in ap-south 1
AWS_DEFAULT_REGION=ap-south-1 generate-ssh-configs aws \
    --prefix myorg-dev-ap-south-1 \
    --filters 'Name=tag:Environment,Values=dev' \
    --jumphost jumphost \
    --user dani \
    > ~/.ssh/config-myorg-dev-ap-south-1

AWS_DEFAULT_REGION=ap-south-1 generate-ssh-configs aws \
    --prefix myorg-prod-ap-south-1 \
    --filters 'Name=tag:Environment,Values=prod' \
    --jumphost jumphost \
    --user dani  \
    > ~/.ssh/config-myorg-prod-ap-south-1

Usage with FZF

SSH configs work beautifully with FZF since the servers are essentially a list. Using some bash magic we can quickly to select the server we want to ssh to.

Here is an example of using fzf and zsh to quickly select a server. Pressing Ctrl+s in a terminal launches fzf-ssh. Place the script in your ~/.zshrc

stty stop undef
function fzf-ssh {
  all_matches=$(grep -P -r "Host\s+\w+" ~/.ssh/ | grep -v '\*')
  only_host_parts=$(echo "$all_matches" | awk '{print $NF}')
  selection=$(echo "$only_host_parts" | fzf)
  echo $selection

  if [ ! -z $selection ]; then
    BUFFER="ssh $selection"
    zle accept-line
  fi
  zle reset-prompt
}
zle     -N     fzf-ssh
bindkey "^s" fzf-ssh

Features

  • AWS
    • Uses name tags to identify instances.
    • Works with jumphosts or bastion hosts.
    • Uses the public IP if
      • the instance is in a public subnet
      • the security group allows ingress port 22 from the public internet
      • the security group allows ingress port 22 from subnet provided via --subnet flag
    • Otherwise it uses the private IP and routes through the jumphost if one is configured.
  • DigitalOcean
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].