以root登录nagios客户端: 192.168.2.80
-bash-3.00# grep nagios /etc/shadow
nagios:*LK*:::::::
-bash-3.00# su - nagios
Sun Microsystems Inc. SunOS 5.10 Generic January 2005
为nagios用户产生ssh rsa key:
$ /usr/bin/ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/usr/local/nagios/.ssh/id_rsa):
Created directory '/usr/local/nagios/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /usr/local/nagios/.ssh/id_rsa.
Your public key has been saved in /usr/local/nagios/.ssh/id_rsa.pub.
The key fingerprint is:
69:d5:16:3a:e7:0d:0d:df:fe:26:96:08:f3:a4:55:f3 nagios@acs00mlcprc01
$ cd /usr/local/nagios/.ssh
$ ls
id_rsa id_rsa.pub
$ more id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAvryQqyhFPzcXzSJiIM9JWm0jl3igF8MgJQAUMZCj6YTa
jXNMZOfrjY/OO0gjmGyz/t+I4EJDsVw4g8bvbYvsolp7acE6eJ43wCQ+5Gx/rjqxwE7LYnwGBPxDLtuS
XIjwwwroLbjNMe0cbYjmA04HHnX58yu+Ne+TOvcqttXzVN0= nagios@acs00mlcprc01
以上是rsa public key的内容。
测试用户nagios是否能够通过identity_file在XSCF上执行命令 (192.168.2.80)
$ ssh -l mlc -i /usr/local/nagios/.ssh/id_rsa 192.168.3.80 showdomainstatus -a
The authenticity of host '192.168.3.80 (192.168.3.80)' can't be established.
RSA key fingerprint is d1:83:1b:b7:eb:f3:70:f2:b8:f5:e2:43:5c:af:a1:e9.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.3.80' (RSA) to the list of known hosts.
DID Domain Status
00 Running
01 -
02 -
03 -
$ more /usr/local/nagios/.ssh/known_hosts
192.168.3.80 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAIEAyRYZFTYrKzK/XYSnxUe8lvTEErvy2LV6F
0vIBjiwUwEKYh8KIFTeUdkiJbt4yn0UkjN3UDP16Ao8n53xRKRXqXlkWFmrqeY4NCY5ahG4FFayNBWVJ
0MVrL9wRak1d6il9XEv8iN3k3xayb8O22S/SID238/TbDYj9YebIkpLVpc=
第一次执行时先把xscf的地址加入到known_hosts里。
$ ssh -l mlc -i /usr/local/nagios/.ssh/id_rsa 192.168.3.80 showdomainstatus -a
DID Domain Status
00 Running
01 -
02 -
03 -
第二次执行时直接就输出命令执行结果了。