11 ms·
SSH alternatives for mobile, low-latency or unreliable connections
- dqh 5y agoOr solve at a lower layer - it’s possible to configure an IPsec VPN so that it can reconnect without dropping TCP connections. Even if you change IP address. I had great success doing this using FreeSwan to manage IPsec on a Linux server, and with the native macOS IPsec client.
- nextaccountic 5y agoThe two alternatives in the article were previously discussed in HN as well: mosh (https://news.ycombinator.com/item?id=28150287 https://news.ycombinator.com/item?id=28150287) and eternal terminal (https://news.ycombinator.com/item?id=21640200 https://news.ycombinator.com/item?id=21640200)
- bee_rider 5y agoI think whoever wrote their title messed up -- "low latency" sticks out at being the one non-problem in the title (and the article deals with high latency).
- loxias 5y agoThis jumped out at me too! It's the author's mistake, not whoever posted it here. Which makes me question how much consideration should be given to one who doesn't know what latency is. :) Assuming the best, it's a typo, we're all human. On the other hand, it's been more than a month (article was updated 2021-09-22) and he still hasn't corrected it...
- bee_rider 5y agoYeah -- in article, the author seems to pretty consistently get it right. I almost wonder if it is something where the title is written by somebody else. For example, IIRC this sort of thing has lead to a couple head-scratchers of a title at Ars Technica, a place with pretty good writing in general...
- chasil 5y agoSSH is problematic for several use cases. It is easy to future-proof the crypto for anything other than a quantum computer: Ciphers chacha20-poly1305@openssh.com KexAlgorithms curve25519-sha256@libssh.org That is also the fastest cipher for any hardware lacking AES acceleration, but clients configured this way will never talk to older servers (or vice versa). File transfer is a real problem for SSH. The scp command is being slowly excised because of its security problems. https://lwn.net/Articles/835962/ https://lwn.net/Articles/835962/ The replacement sftp protocol simply does not perform well, and the performance problems are explicitly not a development priority. https://daniel.haxx.se/blog/2010/12/08/making-sftp-transfers-fast/ https://daniel.haxx.se/blog/2010/12/08/making-sftp-transfers... Redesigns are on the table: https://www.psc.edu/hpn-ssh-home https://www.psc.edu/hpn-ssh-home At this point, if someone baked the chacha20 cipher into vsftpd (replacing TLS), I would take it for internal use. Wireguard is also an option, allowing us to simply use telnet and cleartext ftp (promiscuous mode on localhost would be a potential path to abuse). In any case, people where I work have standardized on scp and sftp for communication between many disparate architectures, and few realized the problems this would bring.
- devwastaken 5y agoSftp is also not that great. To transfer a folder with children you have to create an empty folder of the same name on the server. Only then you can transfer the client folder, but it doesn't go into the server folder of the same name. Perhaps stack overflow was just entirely incorrect, but that's how I've had to do it with limited systems in the past.
- kevincox 5y agoI've been looking for something like eternal terminal for a while. I really like using my terminal's scrollback compared to tmux and don't cancel/rejoin from other systems often. I really just want 1. Allow roaming (close laptop at one place, reopen at another) 2. Allow persistence (sleep laptop for the night). I get the Mosh advantages, but they aren't worth killing the scrollback buffer for me.
- nrclark 5y agoIf you connect to Linux servers from a Mac, you should try out iterm2's tmux integration. Iterm2 knows how to manage Tmux transparently, so you don't have to even think about it. You just get resumable SSH sessions that save your windows and tabs, and use normal scrolling. It's about as transparent/native feeling as you can get, and it works really well.
- cassianoleal 5y agoIt's shocking how exactly zero terminal emulators on Linux support tmux -CC .
- pca006132 5y agoSpeaking of SSH, I thought of vim/neovim. I frequently use neovim over SSH to company's computer for development, but the experience is horrible if the connection is unstable. If I remember correctly, other editors such as VSCode SSH plugin uses a local buffer for editing which is much better when the network is slightly unstable or high latency. Wondering if there is a way to do this for vim/neovim...
- nousermane 5y agoFor the same snappy "local buffer" experience with ssh/vi, you can mount remote repo using sshfs, then open with vi from that local mount: sshfs user@computer.company.com:/home/repo ~/repo vi ~/repo/file.py
- pca006132 5y agoThanks, I've heard of this earlier. However, I use ssh as I don't want to install some development packages on my local computer, and I need language server to work (which requires the development environment to work properly). sshfs is not an option here as the problem is the development environment rather than the files.
- des429 5y ago'vim user@computer.company.com:/home/repo' also works afaik :-). Vim has support for this built in.
- deleted 5y ago[deleted]
- dietr1ch 5y agotramp-mode does this on emacs. It's nice that it's just opening a file with only the `/ssh:user@host:` prefix, but a few things need tweaks (project tree, shell). BTW `/sudo:user@machine:` works too. It still feels like there's value in making this work simply outside of emacs so more programs can make use of the cached copies. Is there a more resilient alternative to `sshfs`?
- Bayart 5y agoI remember picking up Mosh when it was shown on HN as an MIT student project. Apparently that was back in 2012 [1]. Time flies. I've used it on and off over the years, mostly when having to work on a fast train and a flaky 4G connection. [1]: https://news.ycombinator.com/item?id=3819382 https://news.ycombinator.com/item?id=3819382
- robotmay 5y agoHadn't heard of Eternal Terminal before, but I use mosh quite regularly - for portability I remote into my home network via Wireguard on an iPad Pro, using mosh inside Blink shell (https://blink.sh https://blink.sh) to connect to my machines. Over 5G and 4G it works very smoothly, but does lag a bit if I drop down to 3G speeds. I very much do not regret getting the 5G version of the iPad as it's super useful, and I prefer this setup to carrying around a hefty workstation laptop. With the magic keyboard attached I basically have a tiny but comfortable laptop, albeit quite top-heavy. Having to use tmux isn't a hassle for me as I would be using it anyway, and it has the added benefit of being able to connect to my active sessions on another machine and pick up where I left off.
- codetrotter 5y agoI've been using Termius https://termius.com/ios https://termius.com/ios paired with Wireguard for a long while on my iPhone and generally I am happy with Termius as it has very pleasant to use touch interactions both for selecting text and scrolling and performing arrow keys up/down. However, the big drawback of Termius is that in the free version it will terminate the connection after quite a short while as soon as you put the app in the background. They offer a subscription to have it not behave like this but I don't want to pay a subscription for that feature. (The subscription includes additional features as well, but I don't want any of those features.) When I read about Blink shell now, I was kind of hoping that it might be a good replacement. I tried it out on my phone, but I am a bit bewildered about how to select text using Blink shell. I am wondering if maybe Blink shell is mainly suitable for use on iPad, and not as great to use on iPhone. At least, my initial impression is that it is probably fine for use with a keyboard but that it is not made for touch interactions to the same degree that Termius is. Edit: I figured out how to select text with Blink shell; double tap and drag [1]. Unfortunately it feels quite clumsy and awkward to me compared to Termius. Not just the motion itself, but also how the resulting selection is handled. I will keep trying to use Blink shell for a while though. After all, Blink shell is open source and so if I like it a lot I could maybe rewrite the touch interactions to be more in line with what I'd like them to be. [1]: https://github.com/blinksh/blink/issues/1116 https://github.com/blinksh/blink/issues/1116
- est 5y agoThe only thing missing in Mosh is SSH tunnel support.
- m-p-3 5y agoBasically why I stay with SSH, it's my poor man's VPN.
- NoGravitas 5y agoFor me, it's agent forwarding.
- brunoqc 5y ago> Guardian Agent: SSH forwarding means you can remotely connect on to other systems over SSH without needing to install Mosh on every one of them. What? Isn't guardian just an agent? You can use ssh forwarding without it. Guardian does look nice but seems abandoned.
- eminence32 5y ago> The main downside with Mosh is that it emulates the terminal remotely and only sends the visible state of the terminal back to the client. This means if you have a lot of output from a command, you will only be able to see the result that would have been visible in the terminal. This is known as the scrollback buffer. It’s a known limitation in Mosh because it focuses on efficiency and solving issues with poor connectivity, so it makes sense to only send the visible portion of the terminal. This is indeed one of the biggest downsides to mosh, and is a very often requested feature. But I am pleased that this article framed the lack of scrollback as an explicit design decision, and didn't simply call it a "missing feature".
- gsich 5y agoThis can also be solved with programs like screen and tmux. Requires some work though if you want the seemless scroll function.
- Johnny555 5y agoIt's also a feature since if you accidentally send a lot of output to your screen, you don't need to wait for the buffer of incoming data to clear before your Ctrl-C will stop the data. You can Ctrl-C and stop it immediately.
- loxias 5y agoOne person's "bug" is another person's feature. In my usage, and opinion of mosh, the remote terminal emulation is at least half the point. It lets you be functional with minuscule amounts of bandwidth, and makes your sessions more responsive when you have plenty of it. It's efficient (enlightened even...) to solve an engineering problem using the appropriate distribution of resources (bandwidth, cpu, memory). A remote terminal that wasted resources sending things that would be invisible anyway strikes me as not just less useful, but really mediocre/lazy design. (IMHO, of course!)
- jwong_ 5y agoI love Mosh and use it every day. One area it's failed on me however, is that I always thought it was supposed to self-recover in connection failures. In practice, it means that every time my laptop goes to sleep, or loses wifi for an extended period of time, I need to do an interrupt sequence and re-start it. Not the biggest deal, but things would be so much better if there was a way to configure it to re-try every so often instead. > mosh: Last contact 9:45:19 ago. [To quit: Ctrl-^ .] I'm not sure what the use of this message is -- surely you would think after 9 hours, trying again would be worth it.
- ikornaselur 5y agoHm, strange! I've had it recover from my laptop being asleep for hours at a time. I've seen the last contact message tick up until it suddenly manages to make a connection and spring back to life! I do just use default settings (just always set up mosh server on my remote servers and forget about it), but is it possible that there's some timeout on the other end you could be experiencing? If for any reason you kill the session on the other side, then of course it doesn't work, but for me it's always magically connected again. I've used Mosh for multiple years, always loved it, until recently when I started using tmux more. For some reason I had loads of problems with colours and the only solution I could find was to manually build it from source with some flags, or even potentially it was a fork or something like that. Just started SSH-ing again (usually have a stable and fast connection) and if I lose the connection, I'll just re-attach the tmux session anyway.
- jwong_ 5y agoInteresting, maybe there's something up with my config. I also run a default setup but the backend is a macintosh, so that may be related. It would be really nice to have it magically reconnect! I actually use tmux in combo and don't see any color issues that I notice. I wonder if it's something about the colors in your tmux config?
- quesera 5y agoI run ssh/mosh on a Linux laptop to my Mac desktop all day every day. I suspend the laptop every night, and when I open it in the morning, it immediately reconnects. I run tmux (locally, nesting another session on the Mac) but I don't think that would make a difference here. I'm not aware of any special config, but I've been using this setup for several years with no major adjustments.
- neilk 5y agoPerhaps a tangent, but I found this exchange between Bradley Fitzgerald & Dewitt Clinton fascinating. Tailscale manages to not drop ssh connections even while the remote machine is being updated, with vanilla TCP. https://twitter.com/dewitt/status/1329104663975587840 https://twitter.com/dewitt/status/1329104663975587840 I too remember the era of ssh connections feeling strangely robust. I don't know enough about networking to fully understand how this works though. But if that's possible at a networking level and all we need is a stable IP, then could an appropriately configured VPN solve these issues?
- exabrial 5y agoDoes ssh require TCP transport? Wonder if you could do MPTCP... or if QUIC actually offered an un-encrypted mode, could be an option too.
- rostayob 5y agoI've been using this script for years, and it works great: https://mazzo.li/posts/autoscreen.html https://mazzo.li/posts/autoscreen.html It's very much like eternal terminal, but requires no upfront setup apart from having screen installed on the server.
- steve_gh 5y agoI have a related question to the OP. What security would you recommend to run on an unreliable connection? To be specific, I have IoT devices which connect to the cloud using MQTT-SN. We use MQTT-SN because the underlying connection is NB-IoT (required for high penetration into difficult to reach areas). The latency on NB-IoT is quite high, which can lead to problems with TCP timeouts - so we have been recommended by the network operator to use UDP not TCP, which in turn leads to MQTT-SN, as it supports QoS 0 (unacknowledged). But we are also very aware of security issues - so how would you put something like TLS onto a UDP datastream?
- walrus01 5y agoI am not the OP but openvpn in its default UDP mode, with long timeouts and frequent keepalives set on both client and server side, works quite well on unreliable connections. All of the crypto available in whatever is the latest version of openssl is available for use. If setting it up in a new config these days you would want to limit it to TLS1.3 and associated cipher suites only.
- afics 5y agoFor TLS over UDP there's DTLS [0] which is probably still problematic for your use case since it still requires the typical TLS handshake. [0] https://datatracker.ietf.org/doc/html/rfc6347 https://datatracker.ietf.org/doc/html/rfc6347
- Skunkleton 5y agowireguard might be a good solution for you. https://www.wireguard.com/protocol/ https://www.wireguard.com/protocol/
- Karrot_Kream 5y agoIn addition to what others have said, NNCP [1] is an interesting way forward also. Though NNCP may not be stable enough for your purposes. [1]: http://www.nncpgo.org/ http://www.nncpgo.org/
- walrus01 5y agono mention of gnu screen or termux to maintain a persistent session when your ssh link drops over a very flaky connection? those are, in my opinion, essential tools to know how to use.
- opan 5y agoThe multiplexer is called "tmux", "termux" is a terminal emulator for android.
- loxias 5y agoIs there any answer other than "mosh, duh"? Keithw (who's now a prof at Stanford) wrote mosh for that use case (high loss high latency), if memory serves correctly. (which it might not! being as apparently an entire decade has passed since "what feels like last month") Also, there's some terminal cleverness, which I admit, to great embarrassment, I still haven't bothered to deeply understand (my "sensai", who offered to help me grok it if I ever got stuck, left this world too soon). Mosh's ability to preserve interactive responsiveness, even through the most high latency, low bandwidth, high packet loss environments is unparalleled! You know, for all those times when you're on a cross country flight, your only network access is a IP-over-DNS tunnel, and you simply MUST ~zephyr~ chat with your friends. Uh, I mean, do mission critical work... ;)
- hosh 5y agoI agree. I'm not sure what this author is talking about with tmux + mosh and adding the latency back in. Maybe because I run the tmux on the remote server and I mosh in. I don't miss native windowing or mouse controls at all, and still have scrollback. I modified the keybindings so it is easier for me (as a vim user) to remember -- including window splits, layout changes, and adjusting pane sizes. I don't just use mosh in high latency, low bandwidth. The fact that mosh will reconnect even after I close the laptop (and put it in suspension), move from wifi network to cell and back, it's all fairly seamless. That makes it practical for my primary dev and ops environment on a remote server. I have had this setup for about 5 years now and use it every day. I used to use something like autossh, and it did not work as well.
- evilos 5y agoProbably just a typo but you likely meant "sensei" which is mentor/teacher/senior where "sensai" is detergent.
- minikomi 5y agoProbably just a typo but you likely meant "senzai" which is soap/detergent where "sensai" is "delicate" or "sensitive".
- 5y ago
- aofeisheng 5y agoThe idea behind Mosh is almost perfect. Unfortunately, it's just a proof-of-concept project that has not been maintained for years. Although it has met my daily needs, I'm still looking for a better alternative because of some known bugs. I had hoped on draft-bider-ssh-quic [1], but unfortunately it was marked as "no longer active". [1]: https://datatracker.ietf.org/doc/draft-bider-ssh-quic/ https://datatracker.ietf.org/doc/draft-bider-ssh-quic/
- NoGravitas 5y agoEmail the author? It does seem like ssh-over-quic would be a reasonable way forward.
- ViViDboarder 5y agoWhat bugs? Mosh isn’t a proof of concept. It’s a stable project. https://github.com/mobile-shell/mosh https://github.com/mobile-shell/mosh
- kapilvt 5y agoIt’s stable, but that doesn’t mean feature complete, no release in over four years in spite of various fixes / github commit activity. Additionally the support for jumpbox/bastion pass through have been languishing even longer than that (https://github.com/mobile-shell/mosh/pull/696 https://github.com/mobile-shell/mosh/pull/696)
- eminence32 5y agoI'm curious: what bugs are keeping mosh from meeting your daily needs?
- loxias 5y agoMosh isn't proof of concept. And it's not not maintained either. It's just "done" (in my opinion). Not all software needs to continually change. There is the concept of software that does one thing, and does it well. THAT BEING SAID... if your complaint is regarding the SSH agent forwarding, I might be convinced to maintain a fork with that, and only that problem being addressed. :) That one's personal to me, and I've been meaning to poke at it since... well before it was released to the outside MIT community.
- acd 5y agoCan you replace ssh with http/3 and websockets?
- shim__ 5y agoUsing Wireguard is also an good option to prevent the connection from being dropped when switching networks
- tomxor 5y ago> The client will also disconnect if your IP address changes, or there is a temporary loss of connectivity. Not to mention CGNAT doesn't have large enough memory to respect TCP keepalive, it will drop your connection in a heartbeat if you even look at the session funny. I only have mobile internet at home and it was a pain until I wrapped it up in wiregaurd permanently. Using SSH is now bliss... TCP keepalive is respected, an idle prompt will actually stay alive for the full 2 hours, which is basically impossible on any consumer internet connection today. I can switch physical connections without worrying about it dropping too... even when packet loss is crazy high wiregaurd ensures SSH doesn't know enough to drop the connection. I no longer worry about losing connections enough to usually not bother with tmux until I actually need multiplexing. My internet experience in general has improved ever since using wiregaurd.
- mfontani 5y agoIf only mosh had ssh key forwarding, I'd use it more :/
- aftbit 5y agoI'd love to see something that used TCP so I could route it over Tor but offered local prediction like Mosh.
- ViViDboarder 5y ago> However, tmux waits for the remote server to send the new screen contents which somewhat defeats the purpose of Mosh. Mosh removes any latency by not waiting for the remote server, but using scrollback through tmux adds that latency back in. I don’t follow. Is this user running mosh inside a tmux session rather than running tmux inside the remote shell? I don’t see how tmux adds latency back in.
- deleted 5y ago[deleted]
- gorgoiler 5y agoIs there a way to reconcile the duality of tmux and i3wm fighting over terminal/window management? I am very frequently logged into remote systems, running tmux, and multiple terminals. At the same time I have multiple window manager windows running multiple of these tmux sessions. Different types of window arrangement. Different types of clipboard. Different keybindings. Different support for focus follows mouse. It’s janky af. This article alludes to an iterm2 specific solution to the problem. I would dearly love to figure out a general one for my window manager of choice. Help.