Bounce SSH using NetCat

30 Nov

You can bounce an SSH connection using Netcat (actually you can bounce anything).

e.g. ———– ———— ————–
| internal | —–> | firewall | ——–> | external |
———— ———— ————–

You want to get from internal to external, but have to go through a firewall or something.

On Internal:
– edit ~/.ssh/config and enter in:
Host external
Hostname external
HostKeyAlias external
ProxyCommand /root/nc-tunnel firewall external.domain

Then create the /root/nc-tunnel script:

#!/bin/sh
bouncehost=$1
target=$2
ssh $bouncehost nc -w 1 $target 22

Thats it, now to connect using this from internal just:
$> ssh external

Leave a comment