Short how-to for creating a reverse ssh tunnel to a remote server. Useful for breaking NATted connection for example.
- At OpenWrt:
opkg update
opkg install sshtunnel
- At remote server: create client ssh keys
ssh-keygen -b 2048 -t rsa
Move the resulting private key to OpenWrt /root/.ssh/id_rsa
, and assign chmod 600
.
-
At remote server: Authorize OpenWrt client at remote server (
authorized_keys
) -
At OpenWrt: Store remote host public key as known host
ssh MYUSER@REMOTEHOST
# accept yes, and press ctrl + c
- At OpenWrt: Enable service (Start on bootup)
/etc/init.d/sshtunnel enable
- At OpenWrt: Start service
/etc/init.d/sshtunnel start
- At OpenWrt: configure sshtunnel
See https://wiki.openwrt.org/doc/uci/sshtunnel for more information
Example configuration
config server myremote
option user myuser
option hostname remotehost
option IdentityFile /root/.ssh/id_rsa
option retrydelay 5
option ServerAliveInterval 30
option ServerAliveCountMax 3
option LogLevel DEBUG1
config tunnelR sshtunnel
option server myremote
option remoteport 44423
option remoteaddress *
option localport 22
option localaddress 127.0.0.1
/etc/init.d/sshtunnel reload
For Ubuntu and other desktop Linux I created the https://github.com/yurt-page/sshtunnel