更新 ssh/add_ssh_pubkey/add_ssh_pubkey.sh
This commit is contained in:
parent
4649def49f
commit
c37f857d87
@ -18,22 +18,22 @@ echo "$SSH_KEY" >> ~/.ssh/authorized_keys
|
|||||||
chmod 600 ~/.ssh/authorized_keys
|
chmod 600 ~/.ssh/authorized_keys
|
||||||
|
|
||||||
# 检查并配置sshd_config文件
|
# 检查并配置sshd_config文件
|
||||||
SSHD_CONFIG="/etc/ssh/sshd_config"
|
# SSHD_CONFIG="/etc/ssh/sshd_config"
|
||||||
if grep -q "^#PasswordAuthentication" $SSHD_CONFIG; then
|
# if grep -q "^#PasswordAuthentication" $SSHD_CONFIG; then
|
||||||
sudo sed -i 's/^#PasswordAuthentication.*/PasswordAuthentication no/' $SSHD_CONFIG
|
# sudo sed -i 's/^#PasswordAuthentication.*/PasswordAuthentication no/' $SSHD_CONFIG
|
||||||
elif grep -q "^PasswordAuthentication" $SSHD_CONFIG; then
|
# elif grep -q "^PasswordAuthentication" $SSHD_CONFIG; then
|
||||||
sudo sed -i 's/^PasswordAuthentication.*/PasswordAuthentication no/' $SSHD_CONFIG
|
# sudo sed -i 's/^PasswordAuthentication.*/PasswordAuthentication no/' $SSHD_CONFIG
|
||||||
else
|
# else
|
||||||
echo "PasswordAuthentication no" | sudo tee -a $SSHD_CONFIG
|
# echo "PasswordAuthentication no" | sudo tee -a $SSHD_CONFIG
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
if grep -q "^#PermitRootLogin" $SSHD_CONFIG; then
|
# if grep -q "^#PermitRootLogin" $SSHD_CONFIG; then
|
||||||
sudo sed -i 's/^#PermitRootLogin.*/PermitRootLogin prohibit-password/' $SSHD_CONFIG
|
# sudo sed -i 's/^#PermitRootLogin.*/PermitRootLogin prohibit-password/' $SSHD_CONFIG
|
||||||
elif grep -q "^PermitRootLogin" $SSHD_CONFIG; then
|
# elif grep -q "^PermitRootLogin" $SSHD_CONFIG; then
|
||||||
sudo sed -i 's/^PermitRootLogin.*/PermitRootLogin prohibit-password/' $SSHD_CONFIG
|
# sudo sed -i 's/^PermitRootLogin.*/PermitRootLogin prohibit-password/' $SSHD_CONFIG
|
||||||
else
|
# else
|
||||||
echo "PermitRootLogin prohibit-password" | sudo tee -a $SSHD_CONFIG
|
# echo "PermitRootLogin prohibit-password" | sudo tee -a $SSHD_CONFIG
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
# 重启ssh服务以应用更改
|
# 重启ssh服务以应用更改
|
||||||
sudo systemctl restart sshd
|
sudo systemctl restart sshd
|
||||||
|
Loading…
x
Reference in New Issue
Block a user