Skip to content

Instantly share code, notes, and snippets.

@jufemaiz
Created July 9, 2019 01:30
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 jufemaiz/46b359863fa5dde2a99c416371cf2cd0 to your computer and use it in GitHub Desktop.
Save jufemaiz/46b359863fa5dde2a99c416371cf2cd0 to your computer and use it in GitHub Desktop.
Bastion the easy way!
# bastion-the-easy-way.sh
#
# Allowing you to easily bastion into a remote location! So nice!
#
# $ bastion path_to_target_key path_to_bastion_key target_ip_address bastion_ip_address target_user bastion_user
function bastion {
__message='Welcome to bastion the easy way!'
ssh -f -i ${2:-$__bastion_key} -L 6969:${3:-$__target_ip_address}:22 ${6:-ec2-user}@${4:-$__bastion_address} echo $__message
ssh -i ${1:-$__target_key} ${5:-ec2-user}@localhost -p 6969 -o "UserKnownHostsFile /dev/null"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment