anyterm ブラウザでリモートコンソール2


  • CentOS5.4に入れる
    • CentOSにはanytermのRPMがないっぽい
    • ぐぐるfedoraならある。じゃあそこからRPMの種となるspecファイルを拾うか。
$ wget http://ftp.riken.jp/Linux/fedora/development/13/source/SRPMS/anyterm-1.1.29-8.fc13.src.rpm
$ rpm2cpio  anyterm-1.1.29-8.fc13.src.rpm | cpio -id   # 展開
$ ls 
anyterm-1.1.29.tbz2              anyterm-libpbe-fix.patch  anytermd.init
anyterm-change-url-prefix.patch  anyterm.conf              anytermd.sysconfig
anyterm-cmd                      anyterm.spec

// ビルドには boost-devel が必要らしい。
$ su - -c "yum install boost-devel"

// とりあえず make してみる→エラー
$ make
Anyterm.o: In function `int pbe::atomic_post_dec<int>(int volatile&, int)':
Anyterm.cc:(.text._ZN3pbe15atomic_post_decIiEET_RVS1_S1_[int pbe::atomic_post_dec<int>(int volatile&, int)]+0x14): undefined reference to `__sync_fetch_and_sub_4'
collect2: ld returned 1 exit status
make[1]: *** [anytermd] Error 1
make[1]: Leaving directory `/tmp/mio/remote/anyterm-1.1.29/build'
make: *** [anytermd] Error 2

// MakefileのGCC_FLAGSに-march=i686を付ければいけるらしい
// ということでRPMを作成する


# RPMビルドローカル設定
$ echo "%_topdir $HOME/rpm" > ~.rpmmacros
$ mkdir -p ~/rpm/{RPMS,SRPMS,SPECS,BUILD,SOURCES}

// SOURCESにデータをコピー
$ cp -a * ~/rpm/SOURCES/

// spec ファイル内で書き換えてしまう
$ diff -Naur anyterm.spec{.o,}
--- anyterm.spec.o      2010-07-17 14:00:11.000000000 +0900
+++ anyterm.spec        2010-07-17 15:52:48.000000000 +0900
@@ -53,6 +53,9 @@
 %patch1 -p0

 %build
+# **** common.mk modify build arch start ****
+perl -p -i.bak -e 's/^(GCC_FLAGS.*)/$1 -march=i686/' common.mk
+# **** common.mk modify build arch end   ****
 export CFLAGS="$RPM_OPT_FLAGS"
 export CXXFLAGS="$RPM_OPT_FLAGS"
 %{__make} %{?_smp_mflags} CFLAGS="$CFLAGS" CXXFLAGS="$CXXFLAGS"

// 書き換えた spec ファイルを元にビルト → 成功
$ rpmbuild -ba anyterm.spec 

// 出来上がったrpm
$ ll ~/rpm/RPMS/i386/
合計 1672
-rw-r--r-- 1 mio mio  178393  7月 17 15:53 anyterm-1.1.29-8.i386.rpm
-rw-r--r-- 1 mio mio  481692  7月 17 15:53 anyterm-debuginfo-1.1.29-8.i386.rpm
-rw-r--r-- 1 mio mio    3421  7月 17 15:53 anyterm-httpd-1.1.29-8.i386.rpm

// anyterm-httpd ってなんでしょう? → あー設定ファイルね。
$ rpm -qpl ~/rpm/RPMS/i386/anyterm-httpd-1.1.29-8.i386.rpm
/etc/httpd/conf.d/anyterm.conf
  • インストールする
// apache いるみたい
# rpm -ivh anyterm-httpd-1.1.29-8.i386.rpm --test
エラー: 依存性の欠如:
        anyterm = 1.1.29-8 は anyterm-httpd-1.1.29-8.i386 に必要とされています
        httpd は anyterm-httpd-1.1.29-8.i386 に必要とされています
# rpm -ivh anyterm-1.1.29-8.i386.rpm anyterm-httpd-1.1.29-8.i386.rpm --test
エラー: 依存性の欠如:
        httpd は anyterm-httpd-1.1.29-8.i386 に必要とされています
# yum install httpd
# rpm -ivh anyterm-1.1.29-8.i386.rpm anyterm-httpd-1.1.29-8.i386.rpm
準備中...                ########################################### [100%]
   1:anyterm                ########################################### [ 50%]
   2:anyterm-httpd          ########################################### [100%]

// rootでログインできないようにする
# diff -Naur sshd_config{.o,}
--- sshd_config.o       2009-09-04 03:12:38.000000000 +0900
+++ sshd_config 2010-07-17 17:18:08.000000000 +0900
@@ -37,6 +37,7 @@

 #LoginGraceTime 2m
 #PermitRootLogin yes
+PermitRootLogin no
 #StrictModes yes
 #MaxAuthTries 6
    • 起動
# service httpd start
# service anyterm start
// http://xxx.xxx.xxx.xxx/anyterm/ にアクセス
  • 所見
    • ブラウザからssh使ってログインできる便利!
    • 表示の速度も全く問題なし。
    • 日本語の入力はできないけどコピペはできた。(ブラウザ画面左上にコピーとペーストアイコンがある)
    • さくらVPSでやってるシリアルポートの接続というのもman anytermd みると-dオプションとかでできたりするのか。
    • アクセス制限はapacheの設定でdenyすればよいみたい。
  • さらにメモ
    • "[close]"押して端末切るらしい。
    • さくらVPSのサーバーのプロセスにはanytermのプロセスがいない? xinetd?それともrc.localでコマンド一発呼んでるだけかしら?
    • 同じくrpmのリストにもないからrpmじゃなくてカスタマイズしたのを直インストールか。
    • daemonで起動したときのログインはここか。この辺いじればログインできるユーザー固定なんかもできるなー
$ cat /usr/libexec/anyterm/anyterm-cmd
#!/bin/bash
# Default command anyterm will run.
# Simply prompt the user for a username and
# ssh locally as that user

while : ; do
    echo -n "Username: "
    read U
    # Make sure it does not start with a "-" and only contains valid
    # username characters.
    if [[ "$U" =~ "^[A-Za-z0-9_][A-Za-z0-9_-]*\$" ]]; then
      ssh "$U@localhost"
    else
      echo "Bad username."
    fi
done