• 安装软件

    dnf install openssh-server -y
  • 验证是否已安装 SSH 服务#

    ls /etc | grep ssh
    如果没有这个文件夹说明系统未安装 SSH 服务,你需要通过包管理工具安装 openssh 软件包
  • 设置允许 Root 用户登录#

    cat /etc/ssh/sshd_config | grep -Eq "^[# ]?PermitRootLogin " ; [ $? -eq 0 ] && sed -i 's/^[# ]\?PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config || echo -e "\nPermitRootLogin yes" >> /etc/ssh/sshd_config
  • 设置密码认证#

    cat /etc/ssh/sshd_config | grep -Eq "^[# ]?PasswordAuthentication " ; [ $? -eq 0 ] && sed -i 's/^[# ]\?PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config || echo -e "\nPasswordAuthentication yes" >> /etc/ssh/sshd_config
  • 启动/重启 SSH 服务#

    ps -ef | grep -q ssh ; [ $? -eq 0 ] && systemctl restart sshd || systemctl enable --now sshd
最后修改:2023 年 07 月 08 日
如果觉得我的文章对你有用,请随意赞赏