How To Install and Use Mosh on a VPS
mhrsntrk / August 10, 2021
mosh is a very powerful ssh extender, especially when you are accessing your VPS over mobile network or different public access points. I will only cover how to install it on a Ubuntu VPS and how to use it effectively.
In order to use mosh you need to first install it on both the client and the server.
brew install mosh
Installing mosh on Ubuntu is pretty straightforward you can use below commands to install it on your server.
sudo apt-get update sudo apt-get install mosh
You probably setup a basic firewall on your server using UFW. In order to use mosh you need to open UDP ports from the range of 6000 to 6100. You can use below command to do that.
sudo ufw allow 60000:61000/udp
mosh work on UTF-8. So in order to connect to a server using mosh you need to set your
en_US.UTF-8. You can check it using below command.
If it is set to
en_US.UTF-8 you can jump to other section if it is not you can add below command to your
.bashrc and reload.
Since mosh is an extender for ssh, as you can imagine it has a very similar usage. You can use below command to access your server using mosh.
mosh connection stays connected until you close it so in order to close to connection just write
exit and hit enter!