mosh

 

介紹

mosh 全名是 mobile shell, 故名思意, 就是為 shell 提供了 mobile 的能力. 功能及優點如下:

  • roaming
  • supports intermittent connectivity (UDP)
  • Same login method (ssh)
  • No privileged code.
  • No daemon. (run after ssh)
  • sets the frame rate based on network conditions.

原理:

ssh 後, 再啟動 mosh-server

mosh-server 之後會用 UDP(60000-61000) 與 mosh-client 建立加密(AES-128)的連線, 再在上面通訊(SSP)

 


安裝

Debian:

apt-get install mosh

Centos6:

epel:

yum install mosh

Program:

/usr/bin/mosh-client        <--- client-side helper for mosh

/usr/bin/mosh-server       <--- server-side helper for mosh
                                             It will exit if no client has contacted it within 60 seconds.
                                             -p PORT         # UDP port number to bind

mosh client: /usr/bin/mosh

mosh [options] [--] [user@]host [command...]

# 指定一個 UDP Port
-p 1234

# 指定 ssh port
--ssh="ssh -p 2222"

# path to server helper on remote machine (default: "mosh-server")
--server=PATH

predict

-a     Synonym for --predict=always

-n     Synonym for --predict=never
 


使用

 

Server Testing:

mosh-server

MOSH CONNECT 60001 ???????????   <--  22-byte base64 session key  (Client side: MOSH_KEY)

mosh-server (mosh 1.1.3)
Copyright 2012 Keith Winstein <[email protected]>
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
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 = 11247]

Checking

netstat -nlup

Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
udp        0      0 0.0.0.0:60001           0.0.0.0:*                           18988/mosh-server

當 timeout 時

root@ubuntu:~# No connection within 60 seconds.

[mosh-server is exiting.]

-p PORT                  # UDP port number to bind

Client:

$ mosh USER@YOUR_SERVER

 


Client

Android Client:

JuiceSSH

Window Client:

Chrome

https://chrome.google.com/webstore/detail/mosh/ooiklbnjmhbcgemelgfhaeaocllobloj

Start:

"C:\Program Files\Google\Chrome\Application\chrome.exe" --show-app-list

chrome://apps/

                         OR

Create shortcut

"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"  --profile-directory=Default --app-id=ooiklbnjmhbcgemelgfhaeaocllobloj

 


Troubleshoot

 

問題1: UTF-8

root@ubuntu:/etc/network# mosh-server

mosh requires a UTF-8 locale.

原因: mosh 只支援 UTF-8 (both sides) !!

mosh remotehost --server="LANG=en_US.UTF-8 mosh-server"

問題2: scrollback

Mosh 1.3 will have complete scrollback support

 


 

 

 

Creative Commons license icon Creative Commons license icon