Sash is a Secure Shell wrapper which uses
aws-cli to find an instance's IP and PEM file by its name*
- Install AWS Unified CLI (make sure you have installed version 1.3.8 or later)
- Make sure you have
AWS_DEFAULT_REGIONset in your environment
- Put all your PEM files under
git clone email@example.com:uriagassi/sash.git cd sash make install echo "source ~/.local/bin/sash.sh" >> ~/.bashrc source ~/.bashrc
git clone firstname.lastname@example.org:uriagassi/sash.git cd sash make install echo "source ~/.local/bin/sash.sh" >> ~/.bash_profile echo "export LC_ALL=en_US.UTF-8" >> ~/.bash_profile echo "export LANG=en_US.UTF-8" >> ~/.bash_profile source ~/.bash_profile
Also supports auto-complete (press
TAB to get available machine names)
Any extra parameters will be passed to the
> sash my-machine-name -A + ssh -i ~/.aws/my.pem email@example.com -A
To refresh the machine name cache for the autocomplete run
If you use VPN to connect to your instances, which means you connect via the machines private IP.
sash will automatically try to connect to a machine's private IP when it has no public IP.
Multiple instances with the same name
If there are multiple instances with the same name, the first instance returned will be selected. If you want to select another, you can do it by indicating the instance's appearance index (starting from one) as a second parameter.
sash my-machine-name 3
will connect to the third instance listed with the name
To see which instances are listed, and in what order, add
list as the second parameter:
> sash my-machine-name list 1) my-machine-name (126.96.36.199) 2) my-machine-name (188.8.131.52) 3) my-machine-name (184.108.40.206)
You can call
sash with wildcards (
*). This will select all instances matching the pattern, and connect to the one in the index indicated
(or the first by default).
> sash my-*-name list 1) my-new-machine-name (220.127.116.11) 2) my-old-machine-name (18.104.22.168) 3) my-machine-name (22.214.171.124) > sash my-*-name 2 Connecting to my-old-machine-name (126.96.36.199) ...
Connect to multiple machines at once
> sash my-machine-name all Connecting to 3 machines (188.8.131.52 184.108.40.206 220.127.116.11)
Any extra parameters will be passed to the
cssh command. To pass arguments to the underlying
ssh - pass it under
--ssh_args as a first argument:
> sash my-machine-name --ssh_args -A -p 44 + cssh -o '-i ~/.aws/my.pem -A' -p 44 firstname.lastname@example.org ubuntu@...
Note: All machines are expected to have the same PEM file to connect correctly
Add the keyword
upload to upload files to the remote machine. The next parameter should be the file to upload, and the one after that the target directory (if not declared - defaults to
> sash my-machine-name upload my_file.json + scp -i ~/.aws/my.pem my_file.json email@example.com:/home/ubuntu > sash my-machine-name upload my_file.json /tmp/my_directory + scp -i ~/.aws/my.pem my_file.json firstname.lastname@example.org:/tmp/my_directory
Use the keyword
download to download files from the remote machine (target defaults to
> sash my-machine-name download my_file.json + scp -i ~/.aws/my.pem email@example.com:my_file.json .
Optional parameters of machine index or
all are supported for patterns matching more than one machine:
> sash my-machine-name upload all my_file.json + scp -i ~/.aws/my.pem my_file.json firstname.lastname@example.org:/home/ubuntu + scp -i ~/.aws/my.pem my_file.json email@example.com:/home/ubuntu + scp -i ~/.aws/my.pem my_file.json firstname.lastname@example.org:/home/ubuntu
Sash assumes the username on your machines is
ubuntu. To change that globally, set the
SASH_DEFAULT_USER environment variable.
If you have a machine whose username is not the default username, you can change it by using the
sash my-machine-name set_user ec2_user
This command uses EC2 Tags to set a Tag to that machine (named
SashUserName) whose value will be used for that specific machine. To unset it, use
sash my-machine-name unset_user
Find machine name from private IP
Newrelic's server monitoring names the instances it monitors by their private IPs by default (
ip-10-0-0-12), which is practically useless.
This API finds the instance which has this private IP, and returns the instance's name tag:
Amazon CLI tools let you manage multiple profiles. To set/change the default profile you want to use, you should set the
AWS_DEFAULT_PROFILE environment variable: