Created
March 7, 2015 04:54
-
-
Save jamesandariese/c9a099d54fd1ee8db718 to your computer and use it in GitHub Desktop.
Quick rockin' ssh tunnel!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
You have a VPN to work. | |
You have a gateway host you're required to ssh through. | |
You have a mac. | |
You want SSHing to be fast, if possible. | |
10.0.0.10 is a fill in for the bastion host. | |
My name is James. Your name probably isn't. | |
10.11.12.13 is a fill in for my desktop. | |
If you're not connected to the VPN, it will just try and connect directly. | |
The ControlPersist stuff is pretty important to make things nice and fast. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!/bin/bash | |
# change IPSec and WORK-VPN to match your VPN settings. | |
# WORK-VPN is the name of the interface in your config | |
# IPSec or PPTP or whatever. You can also use the UUID. | |
if scutil --nc list|grep IPSec|grep -F '"WORK-VPN"'|grep -q Connected ;then | |
# The VPN is online. Let's connect through ssh-gateway! | |
ssh -q -oHostKeyAlias=ssh-gateway -W $1:$2 -l james 10.0.0.10 | |
else | |
ssh -q -oHostKeyAlias=james-desktop -W $1:$2 -l james 10.11.12.13 | |
fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Host * | |
ControlPath ~/.ssh/controlmasters/%r@%h:%p | |
ControlMaster auto | |
ControlPersist 0 | |
Host james2 | |
ProxyCommand ~/bin/ssh-to-work %h %p | |
User james |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment