While setting up a new server, I encountered a problem with mosh. If you don’t know mosh, it’s an extension to SSH which (among other features) enables instant reconnections after an internet shortage. This is especially useful if you’re frequently connecting via mobile network and constantly lose your mobile Internet connection.
However, the problem I encountered was a simple one: Mosh didn’t work. Despite opening (and testing) the needed UDP ports in IPtables the server didn’t spawn properly. After a bit of debugging I found the error while running the mosh server in verbose mode:
The “forkpty: Operation not permitted” message is the problem indicator. I have yet to find why this happens, but the solution is simple. Just add the user on the server you want to use mosh with to the
tty group, e.g. usermod:
Afterwards you should have no more issues
moshing into the server.