登錄遠程服務器一直都在使用ssh,當網絡延遲比較嚴重時,操作非常卡頓,而且經常容易斷掉,鬱悶煩躁抓狂!!
還好發現了一款工具可以解決該問題,實測效果也確實不錯,這款工具是 mosh.
該工具類似ssh,同樣需要客戶端(mosh-client)和服務端(mosh-server)。
官網:https://mosh.org/#getting
安裝
各平臺安裝方法(我只列出主流的):
fedora:
sudo dnf install mosh
ubuntu / debian:
sudo apt-get install mosh
centos:
yum install mosh
windows:
安裝Chrome的Mosh插件
如果有些平臺沒有,可以源碼編譯(例如windows下可用cygwin編譯):
<code>$ git clone https://github.com/mobile-shell/mosh
$ cd mosh
$ ./autogen.sh
$ ./configure
$ make
$ make install/<code>
安裝完成後, 通常會生成三個文件: mosh, mosh-client, mosh-server
使用
前提:mosh服務端 默認使用 udp端口60000-61000.使用前要確保防火牆對這些端口開放。
通常我們主要使用 mosh,使用起來很簡單:
1. 類ssh的方式使用。
直接用mosh替代ssh,它將自動通過ssh連接到服務器,並啟動服務器上的mosh-server, 並關閉ssh連接。然後再自動的啟動客戶端的mosh-client, 連接到剛剛新啟動的mosh-server. 整個過程沒有人工干預、一氣呵成,受用起來非常簡單。
<code>mosh remote-ip
mosh user@remote-ip/<code>
2. 獨立操作服務端和客戶端
step1. 啟動服務器端(假設ip: 29.43.111.33)
<code>$ mosh-server
MOSH CONNECT 60004 4NeCCgvZFe2RnPgrcU1PQw
mosh-server (mosh 1.1.3)
Copyright 2012 Keith Winstein <mosh-devel>
License GPLv3+: GNU GPL version 3 or later <http>.
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 = 30261]/<http>/<mosh-devel>/<code>
step2. 客戶端連接服務端
<code>// $ MOSH_KEY=key mosh-client remote-IP remote-PORT
$ MOSH_KEY=4NeCCgvZFe2RnPgrcU1PQw mosh-client 29.43.111.33 60004/<code>
客戶端和服務端分別有些參數,根據自己需要選擇是否使用。
閱讀更多 老羅筆記 的文章