11

This is on linux, connecting to linux servers:

I love mosh, but it doesn't support port forwarding, and likely won't for a while since it's been almost a year now and it hasn't happened yet.

port forwarding over ssh is great, but because my laptop moves between networks several times a day, my ssh sessions die, and so do the port forwards.

I could script/hack something to detect hung ssh and reconnect to get my port forwards back, but before I do this, is there another way to do long lasting port forwards when your source IP changes several times daily (because you go on different networks)?

I'm thinking an ssh over UDP would do the trick but of course ssh is over TCP.

Marc Merlin
  • 241
  • 2
  • 6
  • Get a static IP address. Get Mobile IPv6. – Michael Hampton May 29 '14 at 04:26
  • 2
    I have a static IP at home, but I just move around to other places, so that won't work. Mobile IPv6 will work when it's available most places I go. It's not yet. – Marc Merlin May 29 '14 at 14:37
  • In that case the long-term answer is Mobile IPv6, but it will be a while before you can use that everywhere. – Michael Hampton May 29 '14 at 14:37
  • 1
    you're right, although having a mosh like solution that includes port forwarding, would work today. Effectively that would be a mobile IPv4 tunnel. – Marc Merlin May 29 '14 at 14:39
  • This looks to be a duplicate of http://superuser.com/questions/37738/how-to-reliably-keep-an-ssh-tunnel-open. The answer there is [autossh](http://www.harding.motd.ca/autossh/) which restarts a slave ssh when it fails. – elifiner Mar 27 '16 at 08:12

2 Answers2

1

You could try tinc: http://www.tinc-vpn.org/ which would let you connect directly despite the changing IPs.

bowertech
  • 11
  • 2
1

MOSH will never have PortForwarding because it does not work at the same level, it synchronizes the display of the client console with the server console with SSP (State Synchronization Protocol), it does not transmit real data

but you can use AutoSsh instead of SSH, is the same goes with connection monitoring and automatic reconnection

and if you want limit bandwith you can add trickle

sudo trickle -d 10 -u 10 -- autossh -F /path/to/config-file site1

like an open project : MAST (warning is very old!)

Alban
  • 297
  • 2
  • 7