Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Scenario:

  1. At my desk with laptop plugged in to ethernet and connected to remote server over SSH
  2. Want to move to other side of office with laptop and change to WiFi without interrupting SSH connection

I've tried: connecting to WiFi first then disconnecting ethernet; and also disconnecting ethernet first then connecting to WiFi. Neither approach works. Also tried when using Ubuntu and OS X servers along with both OS options as well for the client. No luck.

It seems like I need some way of telling my SSH connection that it should begin using the newly connected network interface instead of the old disconnected interface. Any ideas?

I realize that I could just stay on WiFi the whole day, but I don't want to do that. I also realize that I can just work from within a screen session on the remote server and then re-connect to that screen session after changing interfaces, but I don't want to do that either. For example, I might be piping some big command like a database dump over SSH or I might have files open through SSHFS, or I might just want to avoid the nuisance of re-connecting

share|improve this question
3  
If you get the same IP address both ways, then this should Just Work. If not, it's pretty much impossible. –  Alan Curry Aug 15 '12 at 20:28

5 Answers 5

up vote 1 down vote accepted

I suspect that this solution will not work for SSHFS, etc, but you could take a look at Mosh which provides roaming support for at least the shell itself.

share|improve this answer

It can't be done easily.

I can point you at a number of very expensive applications that allow you to keep a telnet or SSH session when moving between IPs or APs, or even for periods of extended periods network disconnection, but they basically achieve this by creating an always-open server-side session for the client machine so the server doesn't know the connection's different or dropped.

I suppose you could code up such a thing, but I imagine that if it was easy to do, my clients wouldn't be getting raped with 5 figure costs for keeping their terminal connections open on wireless handheld scanners.

Though, I did stumble across screen, which claims to create persistent SSH sessions, which may actually work... give it a shot.

share|improve this answer

I'm afraid you cannot do this, by definition. An SSH session runs over a TCP connection, which is defined by the four-tuple (source address, source port, destination address, destination port). You cannot shift the existing connection to a different address on the client (aside from the fact that the OS will tear down the connection when the interface goes down).

NAT may complicate this picture, but not in any way that will help you.

share|improve this answer

Try being only on wifi when you first start the ssh session. Then plug your ethernet in. That should allow new connections to go over the ethernet, but the established connection will remain on wifi. At least I have seen it work like this with OSX, so OS/hardware may vary.

share|improve this answer

I'm pretty sure you can do this with some silly amount of hacking w/ VMs and Tunneling.

This is untested, but let me know if it does indeed work.

  1. Create a guest VM that has 2 interfaces, 1 bridged adapter (to wifi) and 1 host only networking
  2. Lets say the VM has 192.168.0.25 for the bridged adapter to the wife and 192.168.56.5 to the host only.
  3. Within the vm create the ssh connection w/ a tunnel to the remote side's port 22 ssh -L 10022:remote.server.example.com:22
  4. Now connect through the tunnel. ssh 192.168.56.3 -p 10022
  5. When you lose your wifi connection, change the adapter on the VM over to the ether net adapter .
  6. Hopefully it doesnt hup or screw up the routing table

let me know if it works.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.