Difference between revisions of "Mosh"

From PlebNet Wiki
Jump to navigation Jump to search
(Prepared the page for translation)
(Marked this version for translation)
 
Line 1: Line 1:
<languages/>
<languages/>
<translate>
<translate>
<!--T:1-->
Two of the discomforts of using a CLI to SSH into a node are:
Two of the discomforts of using a CLI to SSH into a node are:


<!--T:2-->
* disconnections
* disconnections
* latency while typing
* latency while typing


<!--T:3-->
[https://mosh.org/ Mosh] solves these issues and provides a far superior user experience. The key differences are:
[https://mosh.org/ Mosh] solves these issues and provides a far superior user experience. The key differences are:


<!--T:4-->
* Mosh uses a persistent UDP connection, sessions remain active even between disconnections or laptop lid closes.
* Mosh uses a persistent UDP connection, sessions remain active even between disconnections or laptop lid closes.
* Mosh uses predictive typing ("local echo") so typing feels instant, even on remote lightning nodes.
* Mosh uses predictive typing ("local echo") so typing feels instant, even on remote lightning nodes.


<!--T:5-->
[https://linux.die.net/man/1/mosh Mosh man page].
[https://linux.die.net/man/1/mosh Mosh man page].


<!--T:6-->
<asciinema loop=1 poster="npt:0:15" autoplay=1 src=https://plebnet.wiki/images/1/1f/MoshCast.cast />
<asciinema loop=1 poster="npt:0:15" autoplay=1 src=https://plebnet.wiki/images/1/1f/MoshCast.cast />




== Client-side and server-side installation ==
== Client-side and server-side installation == <!--T:7-->


<!--T:8-->
On linux:
On linux:


     sudo apt-get install mosh
     <!--T:9-->
sudo apt-get install mosh


<!--T:10-->
On OSX:
On OSX:


     brew install mosh
     <!--T:11-->
brew install mosh




== Usage ==
== Usage == <!--T:12-->


<!--T:13-->
Instead of typing:
Instead of typing:


     $ ssh ubuntu@X.X.X.X
     <!--T:14-->
$ ssh ubuntu@X.X.X.X


<!--T:15-->
You can use mosh:
You can use mosh:


     $ mosh ubuntu@X.X.X.X
     <!--T:16-->
$ mosh ubuntu@X.X.X.X


<!--T:17-->
If using a pem file for authentication, instead of:
If using a pem file for authentication, instead of:


     $ ssh -i ~/.ssh/my_key.pem ubuntu@X.X.X.X
     <!--T:18-->
$ ssh -i ~/.ssh/my_key.pem ubuntu@X.X.X.X


<!--T:19-->
Use:
Use:


     $ mosh --ssh='ssh -i ~/.ssh/my_key.pem' ubuntu@X.X.X.X
     <!--T:20-->
$ mosh --ssh='ssh -i ~/.ssh/my_key.pem' ubuntu@X.X.X.X


<!--T:21-->
That's a rather long command, so you may want to consider setting up an alias, e.g
That's a rather long command, so you may want to consider setting up an alias, e.g


     $ alias m="mosh --ssh='ssh -i ~/.ssh/my_key.pem' ubuntu@X.X.X.X"
     <!--T:22-->
$ alias m="mosh --ssh='ssh -i ~/.ssh/my_key.pem' ubuntu@X.X.X.X"




== use over slow connections ==
== use over slow connections == <!--T:23-->


<!--T:24-->
If you're moshing over a slow connection, or into a very distant lightning node:
If you're moshing over a slow connection, or into a very distant lightning node:


     $ mosh --ssh='ssh -i ~/.ssh/my_key.pem' --predict=experimental ubuntu@X.X.X.X  
     <!--T:25-->
$ mosh --ssh='ssh -i ~/.ssh/my_key.pem' --predict=experimental ubuntu@X.X.X.X  


<!--T:26-->
Experimental prediction provides a totally seamless typing experience on your node, as if you were typing on your localhost's CLI.
Experimental prediction provides a totally seamless typing experience on your node, as if you were typing on your localhost's CLI.






== Firewall Settings ==
== Firewall Settings == <!--T:27-->


<!--T:28-->
Mosh uses UDP port 60001, so make sure you open this port in your firewall settings. If you close a terminal without terminating the session, the user can remain logged in, which then occupies the port. For this reason, you may also want to consider opening port 60002. Another option is to ssh in, to kill the zombie session.
Mosh uses UDP port 60001, so make sure you open this port in your firewall settings. If you close a terminal without terminating the session, the user can remain logged in, which then occupies the port. For this reason, you may also want to consider opening port 60002. Another option is to ssh in, to kill the zombie session.




== Killing Zombie Sessions ==
== Killing Zombie Sessions == <!--T:29-->


<!--T:30-->
If you have a zombie session preventing you from moshing in, simply kill it with:
If you have a zombie session preventing you from moshing in, simply kill it with:


     $ who -u
     <!--T:31-->
$ who -u
     $ ubuntu  pts/1        2021-07-21 12:40  .        22056 (X.X.X.X via mosh [22056])
     $ ubuntu  pts/1        2021-07-21 12:40  .        22056 (X.X.X.X via mosh [22056])


<!--T:32-->
Then:
Then:


     $ pkill -9 22056
     <!--T:33-->
$ pkill -9 22056
</translate>
</translate>

Latest revision as of 19:48, 2 October 2021

Other languages:
English

Two of the discomforts of using a CLI to SSH into a node are:

  • disconnections
  • latency while typing

Mosh solves these issues and provides a far superior user experience. The key differences are:

  • Mosh uses a persistent UDP connection, sessions remain active even between disconnections or laptop lid closes.
  • Mosh uses predictive typing ("local echo") so typing feels instant, even on remote lightning nodes.

Mosh man page.


Client-side and server-side installation

On linux:

   sudo apt-get install mosh

On OSX:

   brew install mosh


Usage

Instead of typing:

   $ ssh ubuntu@X.X.X.X

You can use mosh:

   $ mosh ubuntu@X.X.X.X

If using a pem file for authentication, instead of:

   $ ssh -i ~/.ssh/my_key.pem ubuntu@X.X.X.X

Use:

   $ mosh --ssh='ssh -i ~/.ssh/my_key.pem' ubuntu@X.X.X.X

That's a rather long command, so you may want to consider setting up an alias, e.g

   $ alias m="mosh --ssh='ssh -i ~/.ssh/my_key.pem' ubuntu@X.X.X.X"


use over slow connections

If you're moshing over a slow connection, or into a very distant lightning node:

   $ mosh --ssh='ssh -i ~/.ssh/my_key.pem' --predict=experimental ubuntu@X.X.X.X 

Experimental prediction provides a totally seamless typing experience on your node, as if you were typing on your localhost's CLI.


Firewall Settings

Mosh uses UDP port 60001, so make sure you open this port in your firewall settings. If you close a terminal without terminating the session, the user can remain logged in, which then occupies the port. For this reason, you may also want to consider opening port 60002. Another option is to ssh in, to kill the zombie session.


Killing Zombie Sessions

If you have a zombie session preventing you from moshing in, simply kill it with:

   $ who -u
   $ ubuntu   pts/1        2021-07-21 12:40   .         22056 (X.X.X.X via mosh [22056])

Then:

   $ pkill -9 22056