Skip to content

Instantly share code, notes, and snippets.

@chunkhang
Last active May 17, 2019 08:34
Show Gist options
  • Select an option

  • Save chunkhang/08e7d1690c708ae7a48339400d0de457 to your computer and use it in GitHub Desktop.

Select an option

Save chunkhang/08e7d1690c708ae7a48339400d0de457 to your computer and use it in GitHub Desktop.
Dynamic SSH config for bastion and private hosts
# Connect to bastion host
# `ssh bastion`
Host bastion
HostName bastion.example.com
User admin
IdentityFile ~/.ssh/bastion.example.com.pem
# Connect to private host through bastion host
# `ssh bastion+ip-1-2-3-4.example.internal`
Host bastion+*
User admin
IdentityFile ~/.ssh/bastion.example.com.pem
ProxyCommand ssh bastion -W $(echo %h | cut -d+ -f2-):%p
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment