Bruce Blog Bruce Blog
首页
  • CentOS
  • Ubuntu-Debian
  • 系统网络
  • 系统辅助工具
  • MySQL
  • Redis
  • Mongodb
  • Docker基础
  • Container基础
  • Kubernetes

    • Kubernetes基础
    • Kubernetes辅助
  • Container-Network
  • Jenkins
  • Gitlab
  • ArgoCD
  • Ansible
  • Terraform
  • MQ
  • NGINX
  • JumpServer
  • 基础
  • 函数模块
  • 框架
  • 基础

    • Golang环境
    • 语法
    • 数据类型与运算符
    • 分支语句
    • 循环语句
    • 数组
    • 切片
    • Map
    • String
    • 函数
    • 包的管理
    • 指针
    • 结构体
    • Go语言中的OOP
    • 方法和接口
    • 错误处理
  • Go进阶

    • Go进阶
  • Go框架

    • Go框架
  • Golang辅助

    • Golang辅助
  • CSS
  • HTML
  • JavaScript
  • 前端辅助
  • 常用命令
  • 性能监控工具
  • Windows下Docker使用
  • 日常学习
  • 其他导航

Bruce Tao

运维界的该溜子
首页
  • CentOS
  • Ubuntu-Debian
  • 系统网络
  • 系统辅助工具
  • MySQL
  • Redis
  • Mongodb
  • Docker基础
  • Container基础
  • Kubernetes

    • Kubernetes基础
    • Kubernetes辅助
  • Container-Network
  • Jenkins
  • Gitlab
  • ArgoCD
  • Ansible
  • Terraform
  • MQ
  • NGINX
  • JumpServer
  • 基础
  • 函数模块
  • 框架
  • 基础

    • Golang环境
    • 语法
    • 数据类型与运算符
    • 分支语句
    • 循环语句
    • 数组
    • 切片
    • Map
    • String
    • 函数
    • 包的管理
    • 指针
    • 结构体
    • Go语言中的OOP
    • 方法和接口
    • 错误处理
  • Go进阶

    • Go进阶
  • Go框架

    • Go框架
  • Golang辅助

    • Golang辅助
  • CSS
  • HTML
  • JavaScript
  • 前端辅助
  • 常用命令
  • 性能监控工具
  • Windows下Docker使用
  • 日常学习
  • 其他导航
  • CentOS

  • Ubuntu-Debian

    • 系统命令
    • Ubuntu

      • Ubuntu20.04 系统设置
      • ubuntu22.04 LTS配置root登录ssh root登录
        • ubuntu22.04 LTS安装docker-ce
        • Ubuntu 安装MySQL(国内镜像源)
        • Win10远程桌面连接Ubuntu 20.04
    • 系统网络

    • 系统辅助工具

    • Linux
    • Ubuntu-Debian
    • Ubuntu
    Bruce
    2022-09-11
    目录

    ubuntu22.04 LTS配置root登录ssh root登录

    # Ubuntu系统信息

    • 系统在安装的时候已经默认安装了openssh-server
    $ cat /etc/os-release 
    PRETTY_NAME="Ubuntu 22.04.1 LTS"
    NAME="Ubuntu"
    VERSION_ID="22.04"
    VERSION="22.04.1 LTS (Jammy Jellyfish)"
    VERSION_CODENAME=jammy
    ID=ubuntu
    ID_LIKE=debian
    HOME_URL="https://www.ubuntu.com/"
    SUPPORT_URL="https://help.ubuntu.com/"
    BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
    PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
    UBUNTU_CODENAME=jammy
    
    $  uname -a
    Linux ubuntu22.04-go 5.15.0-47-generic #51-Ubuntu SMP Thu Aug 11 07:51:15 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
    
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17

    # 调整sshd配置文件

    # 切换到root用户下
    $ sudo -i
    $ echo "xxxxx" |passwd --stdin root  # 给root用户设置密码
    
    # 编辑sshd的配置
    $ vim cat /etc/ssh/sshd_config
    PasswordAuthentication yes
    PermitRootLogin yes
    
    # 重启sshd服务
    $ systemctl restart sshd
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    • 接下来使用客户端工具连接即可

    # 未安装openssh-server服务的配置方法

    # 切换到root用户下
    $ sudo -i
    $ echo "xxxxx" |passwd --stdin root  # 给root用户设置密码
    
    1
    2
    3
    # 修改配置
    # 01.增加配置条目`greeter-show-manual-login= true`
    $ sudo vim greeter-show-manual-login= true
    greeter-show-manual-login= true
    [Seat:*]
    user-session=ubuntu
    
    # 02.注释配置内容`auth required pam_succeed_if.so user != root quiet_success`
    $ sudo vim /etc/pam.d/gdm-autologin
    #%PAM-1.0
    auth	requisite	pam_nologin.so
    #auth	required	pam_succeed_if.so user != root quiet_success
    auth	optional	pam_gdm.so
    auth	optional	pam_gnome_keyring.so
    auth 	requited 	pam_permit.so
    @include common-account
    # SELinux needs to be the first session rule.This ensures that any
    
    
    # 03.注释配置内容`auth required pam_succeed_if.so user != root quiet_success`
    $ sudo vim /etc/pam.d/gdm-password
    #%PAM-1.0
    auth	requisite	pam_nologin.so
    #auth required pam_succeed_if.so user != root quiet_success
    @include common-auth
    auth	optional	pam_gnome_keyring.so
    @include common-account
    # SELinux needs to be the first session rule.This ensures that any
    # lingerling context has been cleared.Without this it is possible
    
    
    # 04.修改
    $ sudo vim /root/.profile
    # ~/.profile: executed by Bourne-compatible login shells.
    
    if [ "$BASH" ]; then
        if [ -f ~/.bashrc ];then
            . ~/.bashrc
        fi
     fi
    
    tty -s && mesg n || true
    mesg n || true
    ...
    
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    # 安装SSH
    # 安装openssh-server
    $ sudo apt-get install openssh-server
    
    # 修改配置文件
    $ sudo vim /etc/ssh/sshd_config
    PermitRootLogin yes     # 在#PermitRootLogin prohibit-password的下面,增加一句
    
    # 重启ssh服务
    $ systemctl restart sshd
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    上次更新: 2025/07/26, 23:30:02
    Ubuntu20.04 系统设置
    ubuntu22.04 LTS安装docker-ce

    ← Ubuntu20.04 系统设置 ubuntu22.04 LTS安装docker-ce→

    最近更新
    01
    kubernetes部署minio对象存储
    01-18
    02
    Jenkins-Argocd CICD-下
    01-17
    03
    Jenkins-Argocd CICD Rollouts金丝雀发布优化
    01-17
    更多文章>
    Theme by Vdoing | Copyright © 2019-2025 Bruce Tao Blog Space | MIT License
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式