{"id":260342,"date":"2021-05-27T13:00:00","date_gmt":"2021-05-27T10:00:00","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/what-is-the-mosh-shell-and-how-do-you-use-it-cloudsavvy-it\/"},"modified":"2021-05-27T13:00:00","modified_gmt":"2021-05-27T10:00:00","slug":"what-is-the-mosh-shell-and-how-do-you-use-it-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/what-is-the-mosh-shell-and-how-do-you-use-it-cloudsavvy-it\/","title":{"rendered":"#What Is the Mosh Shell and How Do You Use It? \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2aa5cabecb9\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2aa5cabecb9\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/what-is-the-mosh-shell-and-how-do-you-use-it-cloudsavvy-it\/#What_Is_Mosh\" >What Is Mosh?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/what-is-the-mosh-shell-and-how-do-you-use-it-cloudsavvy-it\/#How_Secure_Is_Mosh\" >How Secure Is Mosh?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/what-is-the-mosh-shell-and-how-do-you-use-it-cloudsavvy-it\/#Install_Mosh_Server_and_Get_a_Mosh_Client\" >Install Mosh Server and\u00a0Get a Mosh Client<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#What Is the Mosh Shell and How Do You Use It? \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<img loading=\"lazy\" decoding=\"async\" class=\"type:primaryImage  alignnone wp-image-1227 size-full\" data-pagespeed-lazy-src=\"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2019\/07\/ec21e76f.png?width=1198&amp;trim=1,1&amp;bg-color=000&amp;pad=1,1\" alt=\"Mosh site.\" width=\"700\" height=\"300\" src=\"\/pagespeed_static\/1.JiBnMqyl6S.gif\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Mosh, or \u201cMobile Shell,\u201d is designed to be a replacement for SSH, specifically for mobile devices or laptops on slow connections. Mosh works over UDP, and will keep your connection alive, even if you change WiFi networks or experience fluctuating cell signal.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"What_Is_Mosh\"><\/span>What Is Mosh?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Mosh\u2019s UDP-based transfer system makes it more stable than traditional SSH, as it handles packet loss much more effectively. If your connection drops out for a bit, Mosh will reconnect you as soon as it comes back, leaving your commands in place as you were typing.<\/p>\n<p>It also significantly reduces latency; if you\u2019ve ever tried to SSH to a slow server, you\u2019ll notice even your keystrokes become slow and unresponsive. This is because the SSH client waits for a TCP response from the server before showing your typing, in case the server intercepts it for some reason. Mosh is more intelligent, and will display your typing in real-time. It even gives underlined typing predictions, which is also handy.<\/p>\n<p>If long-term persistence is all you\u2019re after, you can instead use <code>tmux<\/code>\u00a0on your server over SSH. Tmux splits your terminal into multiple panes, each with multiple tabs, that all persist on the server across SSH sessions. The benefit here is that if your SSH session gets disconnected, it doesn\u2019t affect what\u2019s going on on the server, similarly to Mosh.<\/p>\n<p>But Mosh and <code>tmux<\/code>\u00a0also play well together, as Mosh will automatically reconnect you to your tmux session if your connection drops out, without having to run <code>ssh<\/code>\u00a0and <code>tmux -a t [name]<\/code>\u00a0all over again.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"How_Secure_Is_Mosh\"><\/span>How Secure Is Mosh?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Mosh makes the initial connection over SSH, so the authentication is about as secure as SSH is. It uses\u00a0AES-128 encryption for traffic sent over UDP, so your traffic can\u2019t be sniffed.<\/p>\n<p>The main issue with Mosh is that it requires a lot of ports to be open. Mosh can use any port between\u00a060000-61000, depending on the IP address of the connection. And while you will usually use the same port for the duration of the connection, it\u2019s not guaranteed. This isn\u2019t a major issue, but opening 1000 ports isn\u2019t really good security practice.<\/p>\n<p>If you are running a firewall like iptables, you\u2019ll have to open these ports manually:<\/p>\n<pre>sudo iptables -I INPUT 1 -p udp --dport 60000:61000 -j ACCEPT<\/pre>\n<p>And if you\u2019re running a server on a service like AWS, you\u2019ll need to open the ports through their firewall as well. If you wanted it to be more secure, you could use <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/github.com\/DiegoGuidaF\/mosh-knock\">port knocking<\/a>\u00a0to close these addresses and only open them when Mosh knocks, but this also isn\u2019t ideal if the port changes during your session.<\/p>\n<p>Bottom line, if you\u2019re using Mosh and you\u2019re worried about security, you should probably make it listen on your private network and use a VPN.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Install_Mosh_Server_and_Get_a_Mosh_Client\"><\/span>Install Mosh Server and\u00a0Get a Mosh Client<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>For Mosh to work, the server needs to have Mosh binaries installed. This doesn\u2019t run a daemon like <code>sshd<\/code>; rather, it\u2019s the first command your Mosh client runs when connecting over SSH. When the connection closes, the server terminates the running Mosh server.<\/p>\n<p>The installation is quite simple, as it\u2019s <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/mosh.org\/#getting\">available on most package managers<\/a>. For Debian-based systems like Ubuntu, that would be:<\/p>\n<pre>sudo apt-get install mosh<\/pre>\n<p>This installs the client and the server, so you\u2019ll install the same package on both. Server-oriented installations will simply require you to substitute <code>apt-get<\/code>\u00a0for your distro\u2019s package manager.<\/p>\n<p>For Windows, you\u2019ll have to <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/chrome.google.com\/webstore\/detail\/mosh\/ooiklbnjmhbcgemelgfhaeaocllobloj\">install the client for Chrome<\/a>. There\u2019s no binary yet for Windows.<\/p>\n<p>For macOS, you can install the <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/mosh.org\/#getting\">package directly<\/a>, or install it using Homebrew:<\/p>\n<pre>brew install mosh<\/pre>\n<p>For iOS, you can use an <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">app<\/a> like <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/apps.apple.com\/us\/app\/termius-ssh-client\/id549039908\">Termius<\/a> or <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/apps.apple.com\/app\/id1156707581\">Blink Shell<\/a>.<\/p>\n<p>And for Android, you can use an app like <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/play.google.com\/store\/apps\/details?id=com.termux\">Termux<\/a> or <a rel=\"nofollow noopener\" target=\"_blank\" href=\"https:\/\/play.google.com\/store\/apps\/details?id=com.sonelli.juicessh\">JuiceSSH<\/a>.<\/p>\n<p>In any case, you\u2019ll connect as you would with SSH:<\/p>\n<pre>mosh user@server<\/pre>\n<p>This connects with a username and password. If this isn\u2019t ideal for you, you can also manually specify new SSH options with the <code>--ssh<\/code>\u00a0parameter:<\/p>\n<pre>mosh --ssh=\"~\/bin\/ssh -i ~\/ssh\/id_rsa\" user@port<\/pre>\n<p>This command will make use of your private key rather than a password. Note that the server will need to be configured to accept this private key, especially if it\u2019s a new one coming from a phone or other device.\n<\/p><\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/1224\/what-is-the-mosh-shell-and-how-do-you-use-it\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#What Is the Mosh Shell and How Do You Use It? \u2013 CloudSavvy IT&#8221; Mosh, or \u201cMobile Shell,\u201d is designed to be a replacement for SSH, specifically for mobile devices or laptops on slow connections. Mosh works over UDP, and will keep your connection alive, even if you change WiFi networks or experience fluctuating cell&#8230;<\/p>\n","protected":false},"author":1,"featured_media":260343,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2019\/07\/ec21e76f.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-260342","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/260342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=260342"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/260342\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/260343"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=260342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=260342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=260342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}