Issue
Our team is working on AWS, where we have lots of instances, which we keep adding and removing. Each instance has a logical name, which helps us know what it does as well as finding it.
When we want to connect to one, though, we either need to update the ~/.ssh/config
file all the time, or go to the web console, find the instance by its name, copying its IP and only then we can run it using:
ssh -i ~/.aws/my-pem-file.pem [email protected]
I was wandering whether there is an easier way to do it, where you could specify the machine name, and EC2 would do the rest?
Something like
ssh-aws my-machine-name
Solution
I wrote a little bash script which uses aws-cli
(thanks @Ryan Parman) to find the correct machine IP and PEM from the machine name:
To use it simply call
sash <machine-name>
I've also added more features to it like upload
, download
, and multiplex connect...
Answered By - Uri Agassi Answer Checked By - Timothy Miller (WPSolving Admin)