#!/bin/bash

if [[ -f /etc/ssh/sshd_config ]]; then
    # 先删除包含 "PasswordAuthentication no" 的行
    sed -i '/PasswordAuthentication no/d' /etc/ssh/sshd_config
    # 再添加 "PasswordAuthentication yes" 行
    echo "PasswordAuthentication yes" >> /etc/ssh/sshd_config
else
    echo "/etc/ssh/sshd_config 文件不存在！"
    exit 1
fi

systemctl restart sshd