本文基于《昊鼎王五:蓝鲸智云–0.1.2.安装环境准备》
https://blog.csdn.net/haoding205/article/details/82746880
三台机器分布:
192.168.1.101 nginx,appt,rabbitmq,kafka,zk,es,bkdata,consul,fta
192.168.1.102 mongodb,appo,kafka,zk,es,mysql,beanstalk,consul
192.168.1.103 paas,cmdb,job,gse,license,kafka,zk,es,redis,consul,influxdb
机型:centos7
sshd端口自定义为23456端口,做好了SSH公钥免密
执行《昊鼎王五:蓝鲸智云–0.1.2.安装环境准备》到“7.安装前校验环境是否满足”步骤时,执行:
bash precheck.sh
报如下错误:
[root@centos-3 install]# bash precheck.sh
start <> ... [FAILED]
192.168.1.101 publickey Auth FAILED, please configure no-pass login first.
蓝鲸的脚本,比如precheck.sh中对于sshd端口读取的是默认端口,而当我们的机器自定义的SSHD端口是23456,不匹配。因此报错。
#控制ssh访问的文件为 /etc/ssh/sshd_config
将Port复原
重启服务:service restart sshd
原理请见《昊鼎王五:如何修改LINUX的SSH默认登录端口?》
https://blog.csdn.net/haoding205/article/details/82744334
cat precheck.sh
#原始的:
check_ssh_nopass () {
for ip in ${ALL_IP[@]}; do
echo -ne "$ip\t"
ssh -o 'PreferredAuthentications=publickey' -o 'StrictHostKeyChecking=no' $ip "true" 2>/dev/null
if [[ $? -eq 0 ]]; then
echo "publickey Auth OK"
else
echo "publickey Auth FAILED, please configure no-pass login first."
return 1
fi
done
return 0
}
vim precheck.sh #修改该脚本,往ssh命令中加入指定端口号“-p 23456”,结果如下:
cat precheck.sh
#修改后的:
check_ssh_nopass () {
for ip in ${ALL_IP[@]}; do
echo -ne "$ip\t"
ssh -o 'PreferredAuthentications=publickey' -o 'StrictHostKeyChecking=no' -p 23456 $ip "true" 2>/dev/null #增加了-p 23456#
if [[ $? -eq 0 ]]; then
echo "publickey Auth OK"
else
echo "publickey Auth FAILED, please configure no-pass login first."
return 1
fi
done
return 0
}
[root@centos-3 install]# bash precheck.sh -r
start <> ... [OK]
start <> ... [OK]
start <> ... ssh: connect to host 192.168.1.103 port 22: Connection refused
[FAILED]
[root@centos-3 install]#
原因同上,也是端口不匹配
继续修改precheck.sh脚本中的
原始:找到get_license_mac块:
get_license_mac () {
for ip in ${LICENSE_IP[@]}; do
ssh $ip 'cat /sys/class/net/*/address'
done
}
check_cert_mac () {
local detail=$(openssl x509 -noout -text -in ${SELF_DIR}/../src/cert/gse_server.crt 2>/dev/null)
if [[ $? -ne 0 ]]; then
echo " cert not exists."
return 1
fi
local cnt=$(grep -cFf <(get_license_mac) <(awk '/email/ { for(i=1;i<=NF;i++) print substr($i, 7, 17) }' <<<"$detail"))
[[ $cnt -eq ${#LICENSE_IP[@]} ]]
}
修改precheck.sh,给ssh命令加上指定的端口“-p 23456”
vim precheck.sh
#修改后:
cat precheck.sh
get_license_mac () {
for ip in ${LICENSE_IP[@]}; do
ssh -p 23456 $ip 'cat /sys/class/net/*/address' #增加了-p 23456#
done
}
check_cert_mac () {
local detail=$(openssl x509 -noout -text -in ${SELF_DIR}/../src/cert/gse_server.crt 2>/dev/null)
if [[ $? -ne 0 ]]; then
echo " cert not exists."
return 1
fi
local cnt=$(grep -cFf <(get_license_mac) <(awk '/email/ { for(i=1;i<=NF;i++) print substr($i, 7, 17) }' <<<"$detail"))
[[ $cnt -eq ${#LICENSE_IP[@]} ]]
}
http://docs.bk.tencent.com/bkce_install_guide/setup/get_ready.html#sshnopass
好了,聪明如你,知道了sshd端口不是默认的22端口如何实现蓝鲸安装前校验环境是否满足要求,是不是很欢喜 _