具体脚本如下,写入linux文本文件执行即可
#!/bin/bash
set -e
black(){
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.blk
}
update() {
sed -ri "s/(^PermitRootLogin).*/\1 yes/g" /etc/ssh/sshd_config
sed -ri "s/^#(PermitRootLogin).*/\1 yes/g" /etc/ssh/sshd_config
sed -ri "s/(^PubkeyAuthentication).*/\1 yes/g" /etc/ssh/sshd_config
sed -ri "s/(^PasswordAuthentication).*/\1 yes/g" /etc/ssh/sshd_config
sed -ri "s/(^ChallengeResponseAuthentication).*/\1 no/g" /etc/ssh/sshd_config
}
restart(){
systemctl restart sshd
}
clear(){
echo "" > $0
}
black
update
restart
clear