Please submit an issue/pull request with any suggestions.
The purpose of this group of utilities is decrease the friction of switching from SSH to SSM.
ssh-into
connects to an instance over SSM either directly or by using ssh over SSM.pforward
forwards a port over SSM, providing functionality similar to the -D flag for ssh.
Instance IDs are supported, but if hostnames are provided then DNS lookups are performed using a Private Hosted Zone in Route 53.
https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager.html
- Installation of the AWS Command Line Interface
pip install awscli
- Installation of the session-manager-plugin:
https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html - Updated ~/.ssh/config file to use SSM as a proxy:
https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-getting-started-enable-ssh-connections.html - IAM permissions to access SSM session manager
- A Route 53 Hosted Zone with Private Ips
- Clone the repo locally
chmod u+x ssh-into pforward
to grant execution privilegescp {ssh-into,pforward} /usr/local/bin/
or otherwise add them to yourPATH
Add the following block to ~/.aws/cli/alias
!f() {
bash <path/to/ssh-into/installation/location> $@
}; f
Usage: ssh-into [user@]<destination> [options...]
Destination: Either a hostname (server.env) or an instance-id
Optional Arguments:
-i, --identity_file Identity file (~/.ssh/id_rsa)
-p, --profile AWS Profile (default)
-h, --help Displays this help text
ssh-into www.1strategy-sandbox.com
-> Access instance using session managerssh-into [email protected]
-> Access instance private ip using SSH and the default ssh key~/.ssh/id_rsa
ssh-into [email protected] -i ~/.ssh/1strategy.pem
-> Access instance private ip using SSH and1strategy.pem
ssh key.ssh-into i-a47461d858527dd824
-> Access instance using session managerssh-into ec2-user@i-a47461d858527dd824
-> Access instance private ip using SSH and the default ssh key~/.ssh/id_rsa
ssh-into ec2-user@i-a47461d858527dd824 -i ~/.ssh/1strategy.pem
-> Access instance private ip using SSH and1strategy.pem
ssh key.
Usage: pforward <destination> [options...]
Destination: Either a hostname (server.env) or an instance-id
Required arguments:
-r, --remote Remote port
-l, --local Local port
Optional Arguments:
-p, --profile AWS Profile (default)
-h, --help Displays this help text
pforward www.1strategy-sandbox.com -l 9999 -r 80
-> Access the remote server's web traffic onlocalhost:9999
pforward i-a47461d858527dd824 -r 80 -l 9999
-> Access the remote server's web traffic onlocalhost:9999
TODO:
- Add support for Public IPs (via DNS entry)
- Add support for IPs