3 ms·
host *%* proxycommand ssh $(echo %h | cut -d%% -f1) nc $(echo %h | cut -d%% -f2) %p usage: ssh gateway%target
by yycom 15y ago
host *%*
proxycommand ssh $(echo %h | cut -d%% -f1) nc $(echo %h | cut -d%% -f2) %p
usage:
ssh gateway%target
- a3_nm 15y agoAwesome. Here is another version to support chaining multiple gateways: Host *%* Proxycommand ssh $(echo %h | rev | cut -d%% -f2- | rev) nc $(echo %h | rev | cut -d%% -f1 | rev) %p usage: ssh gateway1%gateway2%target (Not very clean, improvements welcome.)
- vidarh 15y agoThat syntax gave me flashbacks to good old bang paths...
- deleted 15y ago[deleted]
- a3_nm 15y agoA shorter version of the same thing: Host *%* Proxycommand bash -c "h=%h; ssh \${h%%\\%%*} nc \${h##*%%} %p" It would be shorter and cleaner if I knew a way to apply string operators on a constant string rather than defining the intermediate variable $h.
- haridsv 15y agoVery cool! Is there any security risk in running nc on the gateway this way?
- ryan-c 15y agoA more featureful version of that hack: https://github.com/ryancdotorg/ssh-chain https://github.com/ryancdotorg/ssh-chain