证书登陆的脚本.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
0 条评论