クラスタ構成にてMPIを使う際、クラスタ内の各マシンにプロセスを投げる訳だが、その時、使用するプログラムは以前はrsh
最近だとセキュアな関係からrshは煙たがれ、sshが主流なご様子。
rshなら/etc/hosts.equivを調整すればほぼ完了だったんだが.....
sshだと

のどっちかでできるみたい。

ここでは、このホストベースの認証を扱う
2014y11m29d_111458210.png

クライアント側

sshアプリケーションの動作を調整

[root@client ~]# vi /etc/ssh/ssh_config
(中略)
Host *
        GSSAPIAuthentication yes
        EnableSSHKeysign yes               *追加
        HostbasedAuthentication yes        *追加
(中略)
[root@client ~]#

サーバ側

クライアントからの要求を受ける側
sshdの設定に変更を加えてsshdを再起動させ

[root@server ~]# vi /etc/ssh/sshd_config
(中略)
HostbasedAuthentication yes                *有効にする
(中略)
[root@server ~]# /etc/init.d/sshd restart

クライアントのホストキーをサーバ側に保存します。クライアント側でsshdが稼働していればssh-keyscanで取得可能

[root@server ~]# ssh-keyscan -t rsa client.chaperone.jp >> /etc/ssh/ssh_known_hosts     *ホスト名はFQDN
 
MacOSXの場合エラーになった
対処法
mac:~ root$ sudo ssh-keyscan -t rsa client.chaperone.jp | sudo tee -a /etc/ssh/ssh_known_hosts

*「-t rsa」の他に「-t dsa」でも可。何も指定しなければ「-t rsa」で実行される。centos6のsshは標準でssh2で動いており、上記ras,dsaともssh2の公開鍵を取得している

最後に /etc/hosts.equiv (もしくは /etc/ssh/shosts.equiv )にクライアントのホスト名を加える。
どうもFQDNの他にFQDNのホスト名も入れると確実みたい....

[root@server ~]# vi /etc/hosts.equiv
client.chaperone.jp
client                                      *FQDNとhostname -sも加える
[root@server ~]#

*/etc/hosts.equiv(or /etc/ssh/shosts.equiv)は、0600でも可
これで完了

留意
上記は/etc/ssh/sshd_configUseDNS yesの場合のお話。
もしUseDNS noならssh-keyscanはipアドレス、/etc/hosts.equivもipアドレスで指定する必要があります。

テスト

[saber@client ~]$ ssh n1
The authenticity of host 'n1 (192.168.0.52)' can't be established.
RSA key fingerprint is e0:10:2b:0a:7a:23:2c:83:1b:38:12:cc:71:17:fe:8b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'n1,192.168.0.52' (RSA) to the list of known hosts.
Last login: Sat Nov 29 12:04:20 2014 from client.chaperone.jp
[saber@n1 ~]$

と初回接続なら ~/.ssh/known_hosts に相手(サーバ側)の公開鍵を記載する作業の確認を求められるが、二回目以降は問われない。

初回接続に公開鍵を記載する作業を無問答で過ごすためには-o StrictHostKeyChecking=noを加える。

[saber@client ~]$ rm .ssh/known_hosts
[saber@client ~]$
[saber@client ~]$ ssh -o StrictHostKeyChecking=no n1
Warning: Permanently added 'n1,192.168.0.52' (RSA) to the list of known hosts.
Last login: Sat Nov 29 14:13:23 2014 from client.chaperone.jp
[saber@n1 ~]$
[saber@n1 ~]$ exit
logout
Connection to n1 closed.
[saber@client ~]$
[saber@client ~]$ ls -l .ssh/known_hosts
-rw-r--r-- 1 saber fate 397 11月 29 14:14 2014 .ssh/known_hosts
[saber@client ~]$

本サイトではsamba-adによるGSSAPI認証も試しているので、本当にホストベース認証でログイン出来てるのかを
確認するには、下記のオプションを使った方がいいのかも

[saber@client ~]$ ssh -o HostbasedAuthentication=yes -o GSSAPIAuthentication=no n1

HostbasedAuthenticationをyes、GSSAPIAuthenticationをnoとかで試す
*これらの値は、/etc/ssh/ssh_configの値です

ちなみに
「HostbasedAuthentication」はホストベース
「GSSAPIAuthentication」はGSSAPI
「PasswordAuthentication」はパスワード
「PubkeyAuthentication」は公開鍵
どれも「=no」なら相手先へのssh接続はできない

ssh-keysign

fedra16のマシンをホストベース認証の輪に加えたのだが、下記文言が出てきてパスワード認証が求められた

could not open any host key
ssh_keysign: no reply
key_sign failed

原因を調べてみると ssh-keysign の実行権が

# ls -l /usr/libexec/openssh/ssh-keysign
---x--s--x 1 root ssh_keys 245408  2月 22  2012 /usr/libexec/openssh/ssh-keysign
#

と ssh_keys なるグループに setuid がある。っで、マシン自体の秘密鍵は

# ls -l /etc/ssh/ssh_host_*key
-rw-------. 1 root root 672  6月 21  2006 /etc/ssh/ssh_host_dsa_key
-rw-------. 1 root root 515  6月 21  2006 /etc/ssh/ssh_host_key
-rw-------. 1 root root 883  6月 21  2006 /etc/ssh/ssh_host_rsa_key
#

とrootのみが取り扱える。これではマシンのホスト鍵が読めない。それ故のエラーみたい。
っで、解決のために ssh-keysign のパーミッションを変更した

# cp -arp /usr/libexec/openssh/ssh-keysign /usr/libexec/openssh/ssh-keysign.orig
# chown root:root /usr/libexec/openssh/ssh-keysign
# chmod 755 /usr/libexec/openssh/ssh-keysign
# chmod u+s /usr/libexec/openssh/ssh-keysign
#
# ls -l /usr/libexec/openssh/ssh-keysign
-rwsr-xr-x 1 root root 245408 Feb 22  2012 /usr/libexec/openssh/ssh-keysign
#

一応これでホストベース認証の輪に加われた

MacOSX 10.7.5も ssh-keysign のパーミッションに於いて

lion:~ supervisor$ ls -l /usr/libexec/ssh-keysign
-rwx--x--x  1 root  wheel  403216 11 15  2014 /usr/libexec/ssh-keysign
 
lion:~ supervisor$

setuidが抜けている。なので

lion:~ supervisor$ sudo cp -ap /usr/libexec/ssh-keysign /usr/libexec/ssh-keysign.160123
 
lion:~ supervisor$ sudo chmod u+s /usr/libexec/ssh-keysign
 
lion:~ supervisor$ ls -l /usr/libexec/ssh-keysign*
-rws--x--x  1 root  wheel  403216 11 15  2014 /usr/libexec/ssh-keysign
-rwx--x--x  1 root  wheel  403216 11 15  2014 /usr/libexec/ssh-keysign.160123
 
lion:~ supervisor$

と対処を施した。また、ssh_config は /etc/ssh/ssh_config に存在しているが、前述と同じように

lion:~ supervisor$ sudo vi /etc/ssh/ssh_config
 Host *
   SendEnv LANG LC_*
   EnableSSHKeysign yes
   HostbasedAuthentication yes
   GSSAPIAuthentication yes
 
lion:~ supervisor$

とする。これでMacOSXともホストベース認証で接続が可能になります。
MacOSX El capitanだと、Rootlessの関係で ssh-keysign に setuid を付けるのは面倒です...

(めも)

UseDNSが有効なら /etc/hosts.equiv に FQDN が使える。無効ならIPを使用する

[root@c ~]# vi /etc/ssh/sshd_config
 :
UseDNS yes
 :

ホストキー登録を無効にする

ログインノードから計算ノードにジョブを投入、sshでログインする際にそのホストキーの登録をしますか?と問われる
っでこれを無効にする方法が .ssh/ssh_configに

Host *
        StrictHostKeyChecking no
        UserKnownHostsFile=/dev/null

を入れればいいみたい。ログインノードの /etc/ssh/ssh_config に入れる方がいいのかもしれない

最新の60件
2025-06-18 2025-06-17 2025-06-15 2025-06-14 2025-06-11 2025-06-09 2025-06-08 2025-06-07 2025-06-05 2025-06-02 2025-06-01 2025-05-31 2025-05-30 2025-05-25 2025-05-22 2025-05-21 2025-05-20 2025-05-18 2025-05-17 2025-05-14 2025-05-13 2025-05-12 2025-05-11 2025-05-08 2025-05-07 2025-05-06 2025-05-05 2025-05-04 2025-05-03 2025-04-27 2025-04-26 2025-04-25 2025-04-24

edit


トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2025-05-13 (火) 06:06:44