MercurialのためのSSHの設定と実験 (続き)
サーバー側hgを実行してみる。
C:\Documents and Settings\Hiyama>ssh caty@caty-sites.net hg version
plink.exe -ssh -i "C:\Documents and Settings\Hiyama\Work\.ssh\caty.ppk" caty@caty-sites.net hg version
Passphrase for key "imported-openssh-key":
bash: hg: command not found
C:\Documents and Settings\Hiyama>
http://sh1.2-d.jp/b/2007-10-18-00-05.html によると:
色々調べてたら、sshでリモートからコマンドを実行する時には、 $HOME/.xxxファイル は読み込んでくれないんだね。hgコマンドは、 $HOME/local/bin/hg に置いてあって .zshrcにてPATHに追加してるので、そんなん知らないって言われちゃってると。
sshd_configのmanとか見ると、PermitUserEnvironmentが有効なら、 $HOME/.ssh/environment とかにPATHを追加したらいけそうなことが書いてあったので試してみたけど、どうやら駄目っぽい。まぁレンタルサーバだし有効じゃぁないわな。 /etc/ssh/sshd_config はPermission deniedで見れなかったのでわからんけど。
で、じゃあどのPATHなら有効なんだろうと思って、下記コマンドを実行してみたところ、うちのレンタルサーバでは、 $HOME/bin がユーザ用のPATHとして設定されていた。...(以下略)...
パスを調べてみる。
C:\Documents and Settings\Hiyama>ssh caty@caty-sites.net echo $PATH
plink.exe -ssh -i "C:\Documents and Settings\Hiyama\Work\.ssh\caty.ppk" caty@caty-sites.net echo $PATH
Passphrase for key "imported-openssh-key":
/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin
C:\Documents and Settings\Hiyama>
サーバー側のSSHD設定。
$ sudo cat /etc/ssh/sshd_config | grep Permit
#PermitRootLogin yes
PermitEmptyPasswords no
# PasswordAuthentication, PermitEmptyPasswords, and
# "PermitRootLogin without-password". If you just want the PAM account and
#PermitUserEnvironment no$
PermitUserEnvironment yes にする。
$ printenv | egrep '^PATH='
PATH=/home/caty/python2.6.4/bin:/home/caty/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/usr/X11R6/bin$ printenv | egrep '^PATH=' > ~/.ssh/environment
environmentファイルを作った。X11R6は編集して消した。
SSHDに設定を読ませる。
$ sudo /sbin/service sshd status
sshd (pid 22770 4769 4767) is running...$ sudo /sbin/service sshd reload
Reloading sshd: [ OK ]$
パスをもう一度確認。
C:\Documents and Settings\Hiyama>ssh caty@caty-sites.net echo $PATH
plink.exe -ssh -i "C:\Documents and Settings\Hiyama\Work\.ssh\caty.ppk" caty@caty-sites.net echo $PATH
Passphrase for key "imported-openssh-key":
/home/caty/python2.6.4/bin:/home/caty/bin:/usr/kerberos/bin:/usr/local/bin:/bin:
/usr/bin
C:\Documents and Settings\Hiyama>
C:\Documents and Settings\Hiyama>ssh caty@caty-sites.net hg version
plink.exe -ssh -i "C:\Documents and Settings\Hiyama\Work\.ssh\caty.ppk" caty@caty-sites.net hg version
Passphrase for key "imported-openssh-key":
Mercurial Distributed SCM (version 1.4.3)Copyright (C) 2005-2010 Matt Mackall
and others
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
C:\Documents and Settings\Hiyama>
動いた。