さくらVPSにmoshいれてみた

moshいれてみました。ロックのライブでやるアレではなくmobile shellのことです。
伊藤直也さんいわく「快適なssh」とのことで、回線が不安定な所でもエコー遅延など全く気にせず使えるし、Mac をスリープさせて復帰させたときもリモートホストにそのまま繋がりっぱなしのように見せかけてくれたりする。らしいです。

近頃の開発環境 : Mosh、z、tmux、Emacs、Perl について

まずmoshのインストール

Mosh
クライアントとサーバー両方に入れる。クライアントはmacなのでpkgファイルで一発。
問題はサーバー。centosだとrpm用のパッケージが用意されていないのです。

$ git clone https://github.com/keithw/mosh
$ cd mosh/
$ ./autogen.sh

autoconfがないと怒られたのでいれる

$ cd /usr/local/src/
$ wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
$ sudo wget http://ftp.gnu.org/gnu/autoconf/autoconf-2.69.tar.gz
$ sudo tar zxvf autoconf-2.69.tar.gz
$ cd autoconf-2.69
$ ./configure --prefix=/usr
$ sudo ./configure --prefix=/usr
$ sudo make
$ sudo make check
$ sudo make install

再度moshを入れようとすると今度はprotobufがないといわれたのでいれる

$ sudo wget https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz
$ sudo tar zxvf protobuf-2.5.0.tar.gz
$ cd protobuf-2.5.0
$ sudo ./configure --prefix=/usr
$ sudo make
$ sudo make check
$ sudo make install

こんどこそmosh

$ ./configure
$ make
$ sudo make install

入った!

でもってサーバー側のポート60000と60001を開ける。

サーバー側でmoshを立ち上げる。

$ mosh-server
mosh-server: error while loading shared libraries: libprotobuf.so.8: cannot open shared object file: No such file or directory

といわれる。どうやらライブラリのパスが通ってないらしい。
bashrcにexport LD_LIBRARY_PATH=/usr/libを追加(そろそろzshにしたい…)。

$ mosh-server
MOSH CONNECT 60002 2ul5ETtQSA0Us3as+x9v5g

mosh-server (mosh 1.2.4a)
Copyright 2012 Keith Winstein
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 = 21414]

いけた!でもこのサーバは60secアクセスしないと自動的に終了するそう。次にクライアントからmosh-clientでアクセスする。

$ MOSH_KEY=Sb4Lamc77YvSivMZWmMt1A mosh-client xxx.xxx.xxx.xxx 60001

入れた!
けど冗長すぎる…。
公式には

$ mosh chewbacca.norad.mil

で入れるって書いてあるけど、やると「mosh-server: error while loading shared libraries: libprotobuf.so.8: cannot open shared object file: No such file or directory」がでちゃうのよね…
ライブラリのパス通したのになぜだ…

追記

ldconfig打ったらできました!共有ライブラリを認識させるためには/etc/ld.so.confに追記するだけではなくldconfigコマンド打たなきゃいけなかったのですね…。
id:matsuboboさんありがとうございます!