nc-aws-ssh

1.0.0 • Public • Published

Introduction

This tool is used to get a list of dynamic ec2 instances and establish ssh connection to them.

Features

It uses ec2 instance tags to search for metadata, such as available users, vault otp role, vault otp mount point, instance role.

Installation

npm install -g nc-aws-ssh

Setup

AWS

You need to configure your aws profiles and credentials. You can use AWS CLI to manage profile and credentials: Configuration and Credential Files.

  • Environment variables AWS_CONFIG_FILE and AWS_SHARED_CREDENTIALS_FILE supported as well
  • Environment variable AWS_REGION are used to specify aws region fallback, if profile doesn't contain it

Config file ~/.aws/config:

[profile my_awesome_profile]
source_profile = default
role_arn = arn:aws:iam::12345678901:role/OrganizationAccountAccessRole
region = us-west-1
  • my_awesome_profile - profile name that is used as menu point
  • role_arn - arn of aws role, that will be assumed for aws api calls
  • region - aws region for aws api calls (if not specified, fallback to AWS_REGION environment variable is used)
  • source_profile - profile credentials (see below)

Credentials file ~/.aws/credentials:

[default]
aws_access_key_id = YAIAT7G7HEYH7YCQAA5Q
aws_secret_access_key = Hi0ohk8voo6RoTMPbuqdpP/Cpsa3+iekoothiC4

Vault OTP

To use Vault OTP you need to:

  • Use VAULT_ADDR environment variable, e.g. https://vault.example.com
  • Use VAULT_TOKEN environment variable or create ~/.vault-token file that contains vault token (see vault auth)
  • Install sshpass locally.
  • If you use bastion, install sshpass there, and configure ssh server with AllowTcpForwarding on option.

See vault auth (vault auth -method=ldap username=...)

Instances metadata

Tags

Role (tag: role)

If a list of instances contains bastion (role=bastion), it will be used to connect to other instance through bastion, otherwise (if role != bastion) use direct connection.

Users (nc_aws_ssh:users)

A comma-separated list of usernames that can be used to login to the instance (e.g. "ubuntu,visitor")

Vault OTP Role (nc_aws_ssh:vault_otp_role)

Vault ssh otp backend role name. See Vault OTP Role

Vault OTP Mount (nc_aws_ssh:vault_otp_mount)

Vault mount point for ssh otp backend. See Vault OTP Mount

CLI

Dry run

Generate and print to terminal ssh connection command, without executing it:

nc-aws-ssh --dry-run 
# sshpass -p ... ssh -o StrictHostKeyChecking=no  -o ProxyCommand="sshpass -p ... ssh -o StrictHostKeyChecking=no  "ubuntu@172.31.41.148" -W %h:%p" "core@172.31.48.138" 

Verbose

To retrieve extended optput, add verbose (-v) option to generated ssh connection command:

nc-aws-ssh --verbose

Readme

Keywords

none

Package Sidebar

Install

npm i nc-aws-ssh

Weekly Downloads

0

Version

1.0.0

License

ISC

Last publish

Collaborators

  • blackrabbit99
  • namecheap_npm
  • stylet