证书登陆的脚本.sh
#!/bin/bash
mkdir -p ~/.ssh && cd ~/.ssh
# id_rsa.pub authorized_keys SSH 跳板机公钥
authorized_keys(){
cat <<EOF >> authorized_keys
ssh-rsa 把你的公钥放这行 root ##################################
EOF
}
no_use_passwd(){
# 禁用密码登陆
sed -i "s/PasswordAuthentication.*/PasswordAuthentication no/g" /etc/ssh/sshd_config
sed -i "s/#PasswordAuthentication.*/PasswordAuthentication no/g" /etc/ssh/sshd_config
# 只能SSH2访问,这个安全性高.
sed -i '/Protocol/d' /etc/ssh/sshd_config
echo "Protocol 2" >> /etc/ssh/sshd_config
# 重启ssh服务
systemctl restart ssh
}
## 启用功能
authorized_keys
no_use_passwd
本原创文章自由转载,转载请注明本博来源及网址 | 当前页面:
兰雅sRGB个人笔记 »
证书登陆的脚本.sh