侧边栏壁纸
博主头像
Auok Blog

行动起来,活在当下

  • 累计撰写 108 篇文章
  • 累计创建 207 个标签
  • 累计收到 60 条评论

目 录CONTENT

文章目录

让Ubuntu Server使用root登陆ssh

faonecze
2025-01-04 / 0 评论 / 3 点赞 / 157 阅读 / 0 字
温馨提示:
部分素材来自网络,若不小心影响到您的利益,请联系我们删除。

背景

由于Ubuntu自身问题,默认不支持使用root用户登陆ssh,个人使用习惯问题,这里记录修改方案,但存在安全隐患自己衡量.

环境

系统:Ubuntu Server 22.04

设置

1.给root用户添加一个密码

sudo passwd root

2.在sshd_config配置参数

sudo vim /etc/ssh/sshd_config

找到以下行

#PermitRootLogin prohibit-password

将其更改为

PermitRootLogin yes

确保以下行也存在,将 PasswordAuthentication 设置为 no 可以增强安全性,但这意味着你将不能通过密码登录 SSH

PasswordAuthentication no

3.给root用户使用密钥登陆,将pub密钥复制root目录下的

sudo vim ~/.ssh/authorized_keys

4.禁用公钥认证,确保密码登录已启用

PubkeyAuthentication no
PasswordAuthentication yes

5.重启 SSH 服务以应用更改

sudo systemctl restart ssh

3
SSH
  1. 支付宝打赏

    qrcode alipay
  2. 微信打赏

    qrcode weixin
广告 广告
    1. 支付宝打赏

      qrcode alipay
    2. 微信打赏

      qrcode weixin

评论区