不安定な接続でも使えるリモート・シェルのプロトコル
Mobile Shellの名のとおり、不安定な接続でも使えるリモート・シェルのプロトコル。 接続を切っても続きを操作できるという意味では、vncを使った方が楽なのだが、 ネットワーク帯域やサーバーのメモリー資源を無駄に使ってしまうのは問題だ。
現時点でポート転送やX11の対応は無いが iPhone や iPad / Android からコンソールレベルでエディタを使って操作したりするのには使えそうだ。screenコマンドと組み合わせて使えば、vncのような使い方も可能。
$ mosh sakura-vps mosh: failed to connect to host *** port *** ssh_exchange_identification: Connection closed by remote host mosh: Did not find remote IP address (is SSH ProxyCommand disabled?).
$ mosh --ssh="ssh -v" sakura-vps OpenSSH_6.1p1, OpenSSL 1.0.1c 10 May 2012 debug1: Reading configuration data /home/otsuka/.ssh/config debug1: /home/otsuka/.ssh/config line 3: Applying options for sakura-vps debug1: /home/otsuka/.ssh/config line 8: Applying options for * debug1: Executing proxy command: exec 'mosh' --fake-proxy -- *** *** debug1: permanently_drop_suid: 1001 debug1: identity file /home/otsuka/.ssh/id_rsa type -1 debug1: identity file /home/otsuka/.ssh/id_rsa-cert type -1 debug1: identity file /home/otsuka/.ssh/id_dsa type -1 debug1: identity file /home/otsuka/.ssh/id_dsa-cert type -1 debug1: identity file /home/otsuka/.ssh/id_ecdsa type -1 debug1: identity file /home/otsuka/.ssh/id_ecdsa-cert type -1 mosh: failed to connect to host *** port *** ssh_exchange_identification: Connection closed by remote host mosh: Did not find remote IP address (is SSH ProxyCommand disabled?).
長いホスト名をキー入力する場合、TABキーで補完してくれる機能が bash completion で、Debianで有効になっている。 また、sshで一度接続したことのあるホストは ~/.ssh/known_hosts というファイルにホスト鍵と一緒に保管される。
sshに限らずシェルコマンドでホスト名が必要な個所で TAB キーを押すと /etc/hosts や known_hosts 等に書かれているホストを候補に上げてくれる。 ところが、sshのあるバージョンから、known_hostsファイルをハッシュ化して保存するのがデフォルトになってしまい、 TABキーを押した際の候補に出なくなってしまっている。 iPhone等でmoshを使って操作する際、できる限り補完機能を使いたいので、 known_hostsを候補に出してほしいところではある。
known_hostsをハッシュ化して保存しないようにするには、~/.ssh/config に HashKnownHosts no と書けばよい。 既存の known_hosts を known_hosts.hashed というように名前を変えてから config に HashKnownHosts no を加えて、 いつも使うホストに ssh で接続していけば、ハッシュ化していない known_hosts が得られる。*1 known_hostsファイルをハッシュ化しなければならない理由は調べていないが、盗み見対策なら chmod 600 ~/.ssh/known_hosts しておけば大丈夫な気がする。