Mosh — the mobile shell — is a great alternative to SSH when you have a flimsy connection or when you are moving around with your laptop. The default installation needs sudo rights on the server side, but you can install it without privileges in a Conda environment.
First, install Mosh on your server (the machine you want to SSH into):
conda install -c conda-forge mosh -y
You should be able to start the server executable from your environment:
❯ mosh-server
MOSH CONNECT 60001 1/xxx/xx
mosh-server (mosh 1.3.2) [build mosh 1.3.2]
Copyright 2012 Keith Winstein <[email protected]>
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
[mosh-server detached, pid = 710188]
However, the Mosh executable on your client might not be able to find the server executable if it is not in the path. Some dotfiles are just ignored by the initial SSH command Mosh uses to connect to the server, giving this kind of error on the client:
❯ mosh host
bash: mosh-server: command not found
Connection to host.example.com closed.
/usr/bin/mosh: Did not find mosh server startup message. (Have you installed mosh on your server?)
The solution is to provide Mosh with the exact path for mosh-server
. First, find where is the executable on your server:
❯ which mosh-server
/home/me/.conda/envs/myenv/bin/mosh-server
Then, connect from the client with:
❯ mosh --server=/home/me/.conda/envs/myenv/bin/mosh-server host
Bonus: to connect with Mosh from a Windows machine I recommend using Windows Subsystem for Linux.