2012年12月31日月曜日

ServersMan@VPS テザリングでssh接続

VPSに、スマホのテザリングでssh接続すると、ブチブチ切れまくり。
回線速度が遅いからかなぁ??とか、相性の問題かなぁ??とか、しばらく悩んだ。

ネットで調べてみると、どうも、テザリングのNATが怪しい。

ちなみに、動作環境は、以下の通り。

スマホ: MEDIAS N-04C (root化済み)
回線  : イオンSIM
アプリ: Barnacle Wifi Tether
ローカルPC: LaVie Ligth BL100/S (Xubuntu 12.04)

いろいろな回避方法があるみたいだけど、とりあえず、サーバ側の設定を変更してみた。

/etc/ssh/sshd_config に、2行追加。
ClientAliveInterval 15
ClientAliveCountMax 3

こちらを参考にさせて頂きました。
http://hnw.jp/documents/unixmemo/ssh-keepalive.html

しかし、これでもダメなので、Mosh を使ってみることに。

Mosh とは
http://mosh.mit.edu/

1.ローカルPC(Xubuntu12.04)へ Mosh インストール

L:$ sudo apt-get install mosh

2.ServersMan@VPS(Ubuntu10.04)へ Mosh インストール

R:# apt-get install python-software-properties
R:# add-apt-repository ppa:keithw/mosh
R:# apt-get update
R:# apt-get install mosh
R:# apt-get install language-pack-ja

※ ロケールを設定しておかないと、接続できませんでした。

3.ServersMan@VPS(ubuntu10.04)のsshポート変更

デフォルトの 22 に戻しておきます。

R:# vi /etc/ssh/sshd_config

Port 22

4.ローカルPC から、VPSに接続

L:$ mosh USERNAME@xxx.xxx.xxx.xx

実際に使ってみると、レスポンスも良くって、とても快適です。
でも、Port 22 は、リスクがあるので、本番環境では使えないなぁ。残念。

おまけ

# vi mosh.sh
--
#!/bin/sh
sed -i".bak" -e 's/Port 3843/Port 22/g' /etc/ssh/sshd_config
/etc/init.d/ssh reload
sed -i".bak" -e 's/archive.ubuntu.com/jp.archive.ubuntu.com/g' /etc/apt/sources.list
apt-get update
apt-get install python-software-properties
add-apt-repository ppa:keithw/mosh
apt-get update
apt-get install mosh language-pack-ja
--

追記 2013/1/6

クライアントから接続する時のsshポート番号を指定出来ました。

L:$ echo "Port 3843" > ~/.ssh/config

こちら -> http://pspfour.blog106.fc2.com/blog-entry-1069.html

0 件のコメント:

コメントを投稿