欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

sshd_config无密访问的处理

程序员文章站 2022-07-12 16:15:37
...
#!/bin/bash
ip=$1
currpath=$2
hostip=$3 //本机ip
if [ -z "$hostip" ] || [ "$ip" != "$hostip" ];then
ssh ${ip} $currpath/base/annotationCol.sh "/etc/ssh/sshd_config" "AuthorizedKeysFile\ "
ssh ${ip} $currpath/base/annotationCol.sh "/etc/ssh/sshd_config" "RSAAuthentication\ "
ssh ${ip} $currpath/base/annotationCol.sh "/etc/ssh/sshd_config" "PubkeyAuthentication\ "
ssh ${ip} $currpath/base/annotationCol.sh "/etc/ssh/sshd_config" "PasswordAuthentication\ "
ssh ${ip} $currpath/base/annotationCol.sh "/etc/ssh/sshd_config" "PermitEmptyPasswords\ "
ssh ${ip} $currpath/base/addOrUpdateMark.sh "/etc/ssh/sshd_config" "StrictModes" "\ " "no"
ssh ${ip} $currpath/base/addOrUpdateMark.sh "/etc/ssh/sshd_config" "GSSAPIAuthentication" "\ " "no"
ssh root@${ip} /sbin/service sshd restart
else
sh $currpath/base/annotationCol.sh "/etc/ssh/sshd_config" "AuthorizedKeysFile "
sh $currpath/base/annotationCol.sh "/etc/ssh/sshd_config" "RSAAuthentication "
sh $currpath/base/annotationCol.sh "/etc/ssh/sshd_config" "PubkeyAuthentication "
sh $currpath/base/annotationCol.sh "/etc/ssh/sshd_config" "PasswordAuthentication "
sh $currpath/base/annotationCol.sh "/etc/ssh/sshd_config" "PermitEmptyPasswords "
#sh $currpath/base/addOrUpdateMark.sh "/etc/ssh/sshd_config" "StrictModes" " " "no"
#sh $currpath/base/addOrUpdateMark.sh "/etc/ssh/sshd_config" "GSSAPIAuthentication" " " "no"
sh /sbin/service sshd restart
fi