Mosh is a replacement for interactive SSH terminals. It's more robust and responsive, especially over Wi-Fi, cellular, and long-distance links. from Mosh: the mobile shell
You need your host to have mosh-server. So you need to
- install it
- made it discoverable at login stage
Installing on NERSC is slightly complicated. Options:
-
At NERSC you can use put this in your .bash_profile/.bashrc/.zshenv if you have access to
polar
:alias mosh-server=/global/common/software/polar/.conda/envs/system39-conda-forge/bin/mosh-server
-
else the easiest way to install mosh at NERSC is through conda. Create your own conda virtual environment, install mosh, find out its path by
which mosh-server
, make an alias like above and you're done. -
Another easy way is use homebrew (formerly linuxbrew). But I haven't tried it in a while as I experienced some problem after linuxbrew is merged back to homebrew.
And you can obtain mosh-client by installing mosh from your typical package manager.
- Using sshproxy for NERSC to obtain the ssh cert. first by
sshproxy.sh -u NERSC_USERNAME
- (optional) ssh to NERSC normally, the login server will load balance you to an actual node. Say cori11.
- Connect to cori11-224.nersc.gov using mosh, by replacing
ssh
bymosh
. - If you cannot connect by now,
- probably you need to file a NERSC ticket for approval. I have special approval from NERSC staff before I can use it years ago, if you cannot connect mosh, then you can open a NERSC ticket and ask for approval. It is because the libopenssl and possibly protobufs are "instrumented" at NERSC. They said they would approve me for experiment and continue to monitor my account and so far there's no security issue. See Instrumented SSH on NERSC Systems, mobile-shell/mosh#941 (comment)
- it may not discover mosh-server, alias explicitly as above can solve this
In ~/.ssh/config
, add
Host cori
HostName %h.nersc.gov
User NERSC_USERNAME
IdentityFile ~/.ssh/nersc
Host cori??
HostName %h-224.nersc.gov
User NERSC_USERNAME
IdentityFile ~/.ssh/nersc
Then you can login to NERSC in a one-liner:
sshproxy.sh -u NERSC_USERNAME; mosh $(ssh cori hostname)