Skip to content

Instantly share code, notes, and snippets.

@morales2k
Created May 10, 2016 16:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morales2k/5a5876d5d66f9adc60a86b897e85ccd6 to your computer and use it in GitHub Desktop.
Save morales2k/5a5876d5d66f9adc60a86b897e85ccd6 to your computer and use it in GitHub Desktop.
Bash script to ssh into an amazon or other remote host. I made this script to have a single shortcut on my desktop to use in order to load a routine that would simplify establishing an ssh pipe to our remote servers, in this snippet 2 servers are used, but as you can see, it can be scaled up easily by adding more options/cases in the code. Happy…
#!/bin/bash
# Bash script to ssh into an amazon or other remote host. I made this script to have a single shortcut on my desktop to use in order to load a routine that would simplify establishing an ssh pipe to our remote servers, in this snippet 2 servers are used, but as you can see, it can be scaled up easily by adding more options/cases in the code. Happy Coding!
# Author: Jorge Morales
#UPDATE THESE VARIABLES WHENEVER THERE ARE CHANGES
test_server="TEST_SERVER_HOST_ADDRESS"
production_server="PRODUCTION_SERVER_HOST_ADDRESS"
pathToCertificate="PATH_TO_KEYFILE"
echo "Type 1 to connect to Test server."
echo "Type 2 to connect to Production server."
echo "So..."
while true; do
read -p "Which server will you connect to today?" choice
case $choice in
[1]* ) echo "We will connect you to the test server now..."; ssh -i $pathToCertificate $test_server; break;;
[2]* ) echo "We will connect you to the production server now..."; ssh -i $pathToCertificate $production_server; break;;
* ) echo "An unrecognized input was entered. It's either 1 or 2. Those are your choices. Don't get too creative here... LOL!";;
esac
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment