Scenario:
- At my desk with laptop plugged in to ethernet and connected to remote server over SSH
- 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
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.
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.
Old thread, I know, but for sake of completeness since I was looking for the same thing...
In Windows 7 or newer you should simply be able to select both your wifi adapter and Ethernet adapter and choose "Bridge Connection". This will give you a single IP address for both, and you will now be able to disconnect and reconnect Ethernet at will (given continuous wifi coverage).
I manage this in two ways:
Start the session from a terminal server in your datacenter (RDP/Windows/etc)
OR
Install GNU screen or tmux and start them after login.
I prefer
tmux
becausescreen
is pretty old school, but if you are only allowed to install supported packages,screen
is in the RHEL repo.OR
Do both.
The problem is probably that your source IP address changes when you switch between cabled and wifi. This will prevent ssh sessions from coming back.
I handled this in linux by connecting over a vpn and making sure that the vpn connection always gives the same ip to your account (not difficult to enforce, but chance is high that you will receive the same ip over vpn already by default anyway if it's available, but better enforce it to be sure). I mostly use vtun, but openvpn is ok too. Make sure your connections go over the vpn (correct routing, pushed prefixes,...)
I've been able to be offline from the cable for even as long as 5 minutes and then connect to wifi and still be able to stay connected to all my ssh sessions. Ongoing ping, mtr, htop,... just continue when the vpn is restored as if nothing happened.
You can bond the Ethernat and Wifi connections.
This is how I do it on RHEL:
This should allow you to roam between your Wifi and Ethernet connections, and keep your current SSH, VPN, etc. sessions connected.
Credits to: https://fedoramagazine.org/bond-wifi-and-ethernet-for-easier-networking-mobility/
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.
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.
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.
ssh -L 10022:remote.server.example.com:22
ssh 192.168.56.3 -p 10022
let me know if it works.