I often have to access aws hosts using ssh via a jump host. I find it convenient to use ssh with ProxyCommand like this:
Long form
ssh -i key_for_destination_host.pem -o "ProxyCommand ssh -W %h:%p -i key_for_jumpbox.pem jumpbox_user@jump.box.host" destination_user@destination.host
Short form (presumes ssh keys already added)
ssh -o "ProxyCommand ssh -W %h:%p jumpbox_user@jump.box.host" destination_user@destination.host
But I have to negotiate several different AWS accounts and several different regions within each
I would like to have a script function taking 4 arguments interactively:
- jumpbox_user (with a default value suggested)
- jump.box.host (will be an IPv4 address)
- destination_user (with a default value suggested)
- destination.host (will be an IPv4 address)
then substituting these values into the command and opening my remote shell session in my terminal.
The defaults are because generally there is a common username for the jumpbox (although this could change) and a different common username for the destination host (although this also might change).
Ideally in operation I would call the function e.g. $ jumpy
or whatever and get prompts similar to e.g. the awscli aws configure
experience.
What is the asiest way to do this and where do I begin? A BASH function? A Python script? Something else? My workstation is Ubuntu and I have local root so I can use any framework
Thanks
[link] [comments]