SVX日記

2004|04|05|06|07|08|09|10|11|12|
2005|01|02|03|04|05|06|07|08|09|10|11|12|
2006|01|02|03|04|05|06|07|08|09|10|11|12|
2007|01|02|03|04|05|06|07|08|09|10|11|12|
2008|01|02|03|04|05|06|07|08|09|10|11|12|
2009|01|02|03|04|05|06|07|08|09|10|11|12|
2010|01|02|03|04|05|06|07|08|09|10|11|12|
2011|01|02|03|04|05|06|07|08|09|10|11|12|
2012|01|02|03|04|05|06|07|08|09|10|11|12|
2013|01|02|03|04|05|06|07|08|09|10|11|12|
2014|01|02|03|04|05|06|07|08|09|10|11|12|
2015|01|02|03|04|05|06|07|08|09|10|11|12|
2016|01|02|03|04|05|06|07|08|09|10|11|12|
2017|01|02|03|04|05|06|07|08|09|10|11|12|
2018|01|02|03|04|05|06|07|08|09|10|11|12|
2019|01|02|03|04|05|06|07|08|09|10|11|12|
2020|01|02|03|04|05|06|07|08|09|10|11|12|
2021|01|02|03|04|05|06|07|08|09|10|11|12|
2022|01|02|03|04|05|06|07|08|09|10|11|12|
2023|01|02|03|04|05|06|07|08|09|10|11|12|
2024|01|02|03|04|

2005-11-22(Tue) モバイルcvs環境・改

  昨日、cvsの設定をサクッと終わらせてホクホクのオイラである。早速、朝の通勤電車の中で、現在ボツボツと進めているsar情報をグラフ化するRubyスクリプトをcvs登録しだすオイラである……

  「……早朝早々だめじゃん」

  Windows側の権限やら、coLinux側のパーミッションやらが絡まって、coLinuxの一般ユーザからマトモにcvsを使うことができない。うぅ……coLinuxの中だから常にrootで作業してもいいけど、常にrootで開発するのはチョット気持ち悪い。いやね、そりゃLinuxのサポートやりだす前は、rootでの作業率は3%くらいだったけど、最近は一般ユーザでの作業率が3%と逆転してますよ。でも、トラブルシューティングの時は特別だと思うのよ、やっぱ。

  で、結局、どのユーザでもcvsを手軽に使えるようにするには、sshを通すのがいい。sshを使うということは、どういうことか。coLinux側をcvsクライアント、Cygwin側をcvsサーバにするというコトだ。なんだ、昨日せっかく設定したsmbmountはいらなくなっちゃうのか。まぁ、いいけど。

  まずは、Cygwing側でsshdを立ち上げてみよう。えーっと、よく考えたら、今までCygwin側はsshクライアントでしか使ったことがない。どうやんだ? service……ない? /etc/init.d/sshd……ない? /usr/sbin/sshdで起動。なんだ? sshd_configがない? touch /etc/sshd_config。ダメだ……rsaキーがないとかいわれる。

  こうなりゃ、coLinux側の/etc/init.d/sshdを参考にキーを用意してやれ……

/usr/bin/ssh-keygen -q -t rsa1 -f /etc/ssh/ssh_host_key -C '' -N ''
chmod 600 /etc/ssh/ssh_host_key
chmod 644 /etc/ssh/ssh_host_key.pub

  ……ちがう!! こんなに面倒な作業が必要な状態になっているワケがない!! なんか、設定するためのスクリプトとかあるに違いない。ふと、/etc/setupの下にopenssh.lst.gzというファイルを見つけた。読む。なんだか、中にそれっぽいスクリプトが入ってるじゃん。/usr/bin/ssh-host-configってヤツ。fileしたらシェルスクリプトと判明。中を確認する……これだ!! これに違いない!! 実行!!

$ /usr/bin/ssh-host-config
Generating /etc/ssh_host_key
Generating /etc/ssh_host_rsa_key
Generating /etc/ssh_host_dsa_key
Generating /etc/ssh_config file
Privilege separation is set to yes by default since OpenSSH 3.3.
However, this requires a non-privileged account called 'sshd'.
For more info on privilege separation read /usr/share/doc/openssh/README.privsep.
 
Should privilege separation be used? (yes/no)

  なんだ? privilege separationを使うかって? 特権分離? 指示されたドキュメントを読むがよくわからない。ググるが、表面的には今までと変化なさそうだ。スクリプトでインストールしてるんだし、お任せしてみるか。yes!!

Warning: The following function requires administrator privileges!
Should this script create a local user 'sshd' on this machine? (yes/no) yes
Generating /etc/sshd_config file
Added ssh to C:\WINNT\system32\drivers\etc\services
Added ssh to /etc/inetd.conf
 
Warning: The following functions require administrator privileges!
 
Do you want to install sshd as service?
(Say "no" if it's already installed as service) (yes/no) yes
 
Which value should the environment variable CYGWIN have when
sshd starts? It's recommended to set at least "ntsec" to be
able to change user context without password.
Default is "ntsec".  CYGWIN=
 
The service has been installed under LocalSystem account.
To start the service, call `net start sshd' or `cygrunsrv -S sshd'.
 
Host configuration finished. Have fun!

  怒涛のyes&Default攻撃で乗り切ったら、net start sshdしろと出たので、素直に指示に従う。あっけなく、サービスは起動した。

  Cygwin側はとりあえずここまで。次はcoLinux側の設定。まずは鍵ペアを作ろう。

[furuta@colinux furuta]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/furuta/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/furuta/.ssh/id_rsa.
Your public key has been saved in /home/furuta/.ssh/id_rsa.pub.
The key fingerprint is:
35:0e:01:f2:92:3f:8e:a7:df:84:35:87:ef:e4:bf:b5 furuta@colinux

  公開鍵を表示させてクリップボードにコピる。

[furuta@colinux furuta]$ cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEA7QpG1JtPtlBuoygHdKK8N+SWf/ab2pM9hYOlPaBzNRn9slkjkrz7kW8+ptQUZfQn/aYsOtjAIDfiICA9SmeojLd5FELxeXb7/LWu0s3Cni9TaltflKasuALtMtXK8RPzGRtQh4DNX7MIedZhjBKlM5GY14uAOTnWZkpJNA0nVWU= furuta@colinux

  coLinux側から、Cygwin側にsshでログインする。最初はパスワードログインだ。

[furuta@colinux furuta]$ ssh jyokusyu -l Administrator
The authenticity of host 'jyokusyu (192.168.0.1)' can't be established.
RSA key fingerprint is 21:63:89:39:6b:56:64:55:a2:91:2c:d2:d4:ec:1c:a4.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'jyokusyu,192.168.0.1' (RSA) to the list of known hosts.
Administrator@jyokusyu's password:
Last login: Tue Nov 22 09:05:57 2005 from jyokusyu
Fanfare!!!
You are successfully logged in to this server!!!

  ログインできた。公開鍵を登録してやる。

$ vi .ssh/authorized_keys

  2度目のログインはノーパスワードである。ウホウホ。

[furuta@colinux furuta]$ ssh jyokusyu -l Administrator

  ここまできたら、coLinux側からCygwin上のcvsのリポジトリを指定してやる。

[furuta@colinux furuta]$ export CVSROOT=:ext:Administrator@jyokusyu:/cygdrive/u/cvs
[furuta@colinux furuta]$ export CVS_RSH=/usr/bin/ssh

  ssh接続なので、環境変数CVS_RSHの設定も忘れないようにする。ここまで設定が終わったら、Cygwin側に戻って、リポジトリを初期化してやる。

Administrator@jyokusyu ~
$ mkdir /cygdrive/u/cvs
$ export CVSROOT=/cygdrive/u/cvs
$ cvs init

  初期化完了。こっちは普段からAdministrator権限で作業しているので、ssh経由でなく読み書きする設定にしてある。

  あとは職場のPCの設定。こっちもダイレクト書き込みでもよかったが、自分のPCをcvsサーバに設定しておくと、接続先ホストで開発を行う時にも使えて便利である。自分のPCがWindowsXPの場合、ファイアウォールの22番ポートに穴をあけておくことも忘れずに。

m-furuta@1TL1NE ~
$ export CVSROOT=:ext:Administrator@localhost:/cygdrive/u/cvs
$ export CVS_RSH=/usr/bin/ssh

  職場のPCでは普段Administratorで作業してないので、PC自らがアクセスする場合にもsshでログインするように設定した。以上でめでたくモバイルcvs環境の構築完了である。