- 论坛徽章:
- 0
|
本帖最后由 wdong_2001 于 2014-06-20 11:14 编辑
hi,all
我现在需要写一个脚本,去check ssh remote ip权限。我的想法是这样的,如下:
#remotessh.sh
ssh -o StrictHostKeyChecking=no ${ip} "echo" >/dev/null #第一次访问服务器时不用输入yes
#checkremote.sh
sh remotessh.sh $remoteip
if 不能直接登陆
KILL -9 PID(sh remotessh.sh $remoteip)
else
echo "ssh $remoteip is ok"
if
但遇到了点问题,如下:
判断不能登陆时,kill -9 pid 后,有异常情况如下:
[oracle@Sys-25 bin]$ for ip in 192.168.9.{31,32,33};do echo "ip=$ip";sh checkRemote.sh $ip;done
ip=192.168.9.31
[2014-06-20-10:56:35] [INFO] 192.168.9.40 ssh to 192.168.9.31 success
192.168.9.40 ssh 192.168.9.31 [OK]
ip=192.168.9.32
[2014-06-20-10:56:36] [INFO] 192.168.9.40 ssh to 192.168.9.32 success
192.168.9.40 ssh 192.168.9.32 [OK]
ip=192.168.9.33
oracle@192.168.9.33's password:
[2014-06-20-10:56:37] [ERROR] 192.168.9.40 ssh to 192.168.9.33 false
192.168.9.40 ssh 192.168.9.33 [false]
checkRemote.sh: line 139: 29260 已杀死 sh ${checkfile} $ip > /dev/null
[oracle@Sys-25 bin]$
Permission denied, please try again.
oracle@192.168.9.33's password:
Permission denied, please try again.
oracle@192.168.9.33's password:
Permission denied (publickey,gssapi-with-mic,password).
[oracle@Sys-25 bin]$
[oracle@Sys-25 bin]$ #这行开始再输入就不能正常显示了
###回车后如下
[oracle@Sys-25 bin]$ [oracle@Sys-25 bin]$ [oracle@Sys-25 bin]$ [oracle@Sys-25 bin]$ |
|