解决 Xshell 无法使用 root 账户远程登录 Linux 的问题

文章目录

  • 问题描述
  • 问题原因
  • 解决办法

笔者出问题时的运行环境:

  • Red Hat Enterprise Linux 9.2 x86_64

  • Xshell 7

问题描述

笔者在新安装的 Red Hat Enterprise Linux 中发现一个问题。在 RHEL 安装完之后,无法在 Xshell 中使用 root 账户远程登录此 Linux,但用其它账户登录然后切换到 root 账户就不会有问题。

Xshell 登录失败时的报错信息如下。

在这里插入图片描述

问题原因

原来这是因为笔者在安装 RHEL 时忘记开启允许以 root 账户远程登录的功能,从而导致安装之后无法以 root 账户登录。

在这里插入图片描述

解决办法

Linux 既然已经安装了,那就没办法回到过去去纠正前面的错误。幸好 Linux 提供了另一种方法来补救。

  1. 输入如下命令切换到 root 账户,因为后续的操作需要 root 权限。

    su root

  2. 输入如下命令编辑文件 /etc/ssh/sshd_config

    vim /etc/ssh/sshd_config

    对于 RHEL,该文件的原始内容如下:

    #	$OpenBSD: sshd_config,v 1.104 2021/07/02 05:11:21 dtucker Exp $
    
    # This is the sshd server system-wide configuration file.  See
    # sshd_config(5) for more information.
    
    # This sshd was compiled with PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin
    
    # The strategy used for options in the default sshd_config shipped with
    # OpenSSH is to specify options with their default value where
    # possible, but leave them commented.  Uncommented options override the
    # default value.
    
    # To modify the system-wide sshd configuration, create a  *.conf  file under
    #  /etc/ssh/sshd_config.d/  which will be automatically included below
    Include /etc/ssh/sshd_config.d/*.conf
    
    # If you want to change the port on a SELinux system, you have to tell
    # SELinux about this change.
    # semanage port -a -t ssh_port_t -p tcp #PORTNUMBER
    #
    #Port 22
    #AddressFamily any
    #ListenAddress 0.0.0.0
    #ListenAddress ::
    
    #HostKey /etc/ssh/ssh_host_rsa_key
    #HostKey /etc/ssh/ssh_host_ecdsa_key
    #HostKey /etc/ssh/ssh_host_ed25519_key
    
    # Ciphers and keying
    #RekeyLimit default none
    
    # Logging
    #SyslogFacility AUTH
    #LogLevel INFO
    
    # Authentication:
    
    #LoginGraceTime 2m
    #PermitRootLogin prohibit-password
    #StrictModes yes
    #MaxAuthTries 6
    #MaxSessions 10
    
    #PubkeyAuthentication yes
    
    # The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
    # but this is overridden so installations will only check .ssh/authorized_keys
    AuthorizedKeysFile	.ssh/authorized_keys
    
    #AuthorizedPrincipalsFile none
    
    #AuthorizedKeysCommand none
    #AuthorizedKeysCommandUser nobody
    
    # For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
    #HostbasedAuthentication no
    # Change to yes if you don't trust ~/.ssh/known_hosts for
    # HostbasedAuthentication
    #IgnoreUserKnownHosts no
    # Don't read the user's ~/.rhosts and ~/.shosts files
    #IgnoreRhosts yes
    
    # To disable tunneled clear text passwords, change to no here!
    #PasswordAuthentication yes
    #PermitEmptyPasswords no
    
    # Change to no to disable s/key passwords
    #KbdInteractiveAuthentication yes
    
    # Kerberos options
    #KerberosAuthentication no
    #KerberosOrLocalPasswd yes
    #KerberosTicketCleanup yes
    #KerberosGetAFSToken no
    #KerberosUseKuserok yes
    
    # GSSAPI options
    #GSSAPIAuthentication no
    #GSSAPICleanupCredentials yes
    #GSSAPIStrictAcceptorCheck yes
    #GSSAPIKeyExchange no
    #GSSAPIEnablek5users no
    
    # Set this to 'yes' to enable PAM authentication, account processing,
    # and session processing. If this is enabled, PAM authentication will
    # be allowed through the KbdInteractiveAuthentication and
    # PasswordAuthentication.  Depending on your PAM configuration,
    # PAM authentication via KbdInteractiveAuthentication may bypass
    # the setting of "PermitRootLogin without-password".
    # If you just want the PAM account and session checks to run without
    # PAM authentication, then enable this but set PasswordAuthentication
    # and KbdInteractiveAuthentication to 'no'.
    # WARNING: 'UsePAM no' is not supported in RHEL and may cause several
    # problems.
    #UsePAM no
    
    #AllowAgentForwarding yes
    #AllowTcpForwarding yes
    #GatewayPorts no
    #X11Forwarding no
    #X11DisplayOffset 10
    #X11UseLocalhost yes
    #PermitTTY yes
    #PrintMotd yes
    #PrintLastLog yes
    #TCPKeepAlive yes
    #PermitUserEnvironment no
    #Compression delayed
    #ClientAliveInterval 0
    #ClientAliveCountMax 3
    #UseDNS no
    #PidFile /var/run/sshd.pid
    #MaxStartups 10:30:100
    #PermitTunnel no
    #ChrootDirectory none
    #VersionAddendum none
    
    # no default banner path
    #Banner none
    
    # override default of no subsystems
    Subsystem	sftp	/usr/libexec/openssh/sftp-server
    
    # Example of overriding settings on a per-user basis
    #Match User anoncvs
    #	X11Forwarding no
    #	AllowTcpForwarding no
    #	PermitTTY no
    #	ForceCommand cvs server
    
    
  3. 将该文件的 #PermitRootLogin prohibit-password 那行改为 PermitRootLogin yes,然后保存该文件。如下图所示。

    在这里插入图片描述

  4. 输入如下命令重启 sshd。

    systemctl restart sshd.service

    或者输入如下命令直接重启 Linux。

    reboot

  5. 现在应该就可以在 Xshell 中使用 root 账户远程登录 RHEL 了。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/234180.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

ReLU(Rectified Linear Unit)和Sigmoid激活函数

ReLU(Rectified Linear Unit)和Sigmoid都是神经网络中常用的激活函数。 特点: ReLU是一种简单而有效的激活函数。它对于正数部分直接返回输入,对于负数部分返回零。这种非线性转换有助于网络学习更复杂的表示。ReLU在许多深度学习…

【开源】基于JAVA语言的数字化社区网格管理系统

项目编号: S 042 ,文末获取源码。 \color{red}{项目编号:S042,文末获取源码。} 项目编号:S042,文末获取源码。 目录 一、摘要1.1 项目介绍1.2 项目录屏 二、功能模块三、开发背景四、系统展示五、核心源码5…

scala变量与变量类型

1.6 变量与类型(重点)1.6.1 变量推断1.6.2 多变量定义1.6.3 var和val的区别 1.6.3.1 是否可变 1.6.3.2 延迟加载 1.6 变量与类型(重点) val修饰的变量,相当于Java中final修饰的变量; // 定义常量s1,使用…

阿里内部教程Jmeter 性能测试常用图表、服务器资源监控

性能测试常用图表 插件安装 步骤 1:安装插件管理器 在 Jmeter 官网上下载插件管理器 Plugins-manager-1.3.jar将 jar 包放入到 lib\ext 目录下重启 Jmeter,可以在选项下看到 Plugins Manager 选项 步骤 2:安装指定的插件 打开 Plugins Ma…

T曲线速度控制与S曲线速度控制

梯形速度控制曲线(T曲线) 所谓梯形速度曲线,也称为直线加减速或T型加减速。 其算法十分简易,规划周期耗时短,有利于缩减系统的连续运行时间,从而提高系统的运动控制速度,实施起来比较易&#x…

四元数,欧拉角,旋转矩阵,旋转向量

四元数,旋转矩阵,旋转向量,欧拉角 一、欧拉角 1、欧拉角是表达旋转的最简单的一种方式,形式上它是一个三维向量,其值分别代表物体绕坐标系三个轴(x,y,z轴)的旋转角度,默认旋转正向为逆坐标轴逆…

Unity DOTS中的baking(一) Baker简介

Unity DOTS中的baking(一) Baker简介 baking是DOTS ECS工作流的一环,大概的意思就是将原先Editor下的GameObject数据,全部转换为Entity数据的过程。baking是一个不可逆的过程,原先的GameObject在运行时不复存在&#x…

VSCode如何设置Vue前端的debug调试

vscode在调试vue.代码时,如何进行debug? 1.安装Chrome Debug插件。 2.在launch.json中,将url修改成你前端项目的路径: 1 {2 // Use IntelliSense to learn about possible attributes.3 // Hover to view descriptions of existing att…

腾讯再推互动微短剧,游戏的风吹向了短剧

当你看剧时不再拥有上帝视角,处在女主的位置上,你又会做出什么样的选择? 腾讯最新上线的短剧《摩玉玄奇2》在原版之外还推出了互动版,就给出了这样一个新玩法。 《摩玉玄奇2》原版是普通的后宫职场微短剧,互动版则是…

Linux——缓冲区与实现C库的fopen,fwrite,fclose

目录 一.缓冲区 1缓冲区的概念 2.缓冲区存在的意义 3.缓冲区刷新策略 4.什么是刷新? C语言的缓冲区在哪里? ​编辑 仿写C库里的fopen,fclose,fwrite。 mystdio.h mystdio.c main.c(向文件中写入20次msg) 一.缓冲区 1…

protobuf安装教程v21.11

Linux: 1.安装依赖库 下载ProtoBuf前⼀定要安装依赖库:autoconf automake libtool curl make g unzip如未安装,安装命令如下: Ubuntu用户: sudo apt-get install autoconf automake libtool curl make g unzip -y CentOS用户&…

盘点251个Python源码Python爱好者不容错过

盘点251个Python源码Python爱好者不容错过 学习知识费力气,收集整理更不易。 知识付费甚欢喜,为咱码农谋福利。 项目名称 链接:https://pan.baidu.com/s/1PikCn61NfHXmEzQiny8kfw?pwd6666 提取码:6666 dailyfreshpython-Dj…

MongoDB中的sort()排序方法、aggregate()聚合方法和索引

本文主要介绍MongoDB中的sort()排序方法、aggregate()聚合方法和索引。 目录 MongoDB的sort()排序方法MongoDB的aggregate()聚合方法MongoDB的索引 MongoDB的sort()排序方法 在MongoDB中,sort()方法是用来对查询结果进行排序的。sort()方法可以用于在查询语句中对指…

[NAND Flash] 1.1 闪存(NAND Flash) 学习指南

依公知及经验整理,原创保护,禁止转载。 专栏 《深入理解NAND Flash》 ​ 回首 漠然回首,从事存储芯片行业已多年,这些年宝贵的青春都献给了闪存。 我刚入行的时候,也是萌新一个,彷佛大学学的都没有和这相…

docker安装部署

1.在线安装Docker 安装Docker依赖库: yum install -y yum-utils device-mapper-persistent-data lvm2添加yum来源: yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo安装Docker: yum install doc…

[香橙派]orange pi zero 3 烧录Ubuntu系统镜像——无需HDMI数据线安装

一、前言 本文我们将介绍如何使用orange pi zero 3 安装Ubuntu系统,本文相关步骤均参考自开发手册。 二、实施准备 根据开发手册中所提到的,我们应该拥有如下配件: 1.orange pi zero 3 开发板 2.TF 卡——最小 8GB 容量的 class10 级或以上的高速闪迪卡。…

@德人合科技 | 数据透明加密防泄密系统\文件文档加密\设计图纸加密|源代码加密防泄密软件系统,——防止内部办公终端核心文件数据/资料外泄!

一款专业的数据防泄密管理系统,它采用了多种加密模式,包括透明加密、半透明加密和落地加密等,可以有效地保护企业的核心数据安全。 PC端访问地址: https://isite.baidu.com/site/wjz012xr/2eae091d-1b97-4276-90bc-6757c5dfedee …

c++新经典模板与泛型编程:标准库容器中元素类型的萃取

通过容器(数组)类型萃取元素类型 用GetEleType类模板进行常规实现 #include <iostream>#include <vector> #include <list>// 泛化版本 template<typename T> struct GetEleType;// 特化版本 template<typename T> struct GetEleType<std::v…

【rabbitMQ】模拟work queue,实现单个队列绑定多个消费者

上一篇&#xff1a; springboot整合rabbitMQ模拟简单收发消息 https://blog.csdn.net/m0_67930426/article/details/134904766?spm1001.2014.3001.5502 在这篇文章的基础上进行操作 基本思路&#xff1a; 1.在rabbitMQ控制台创建一个新的队列 2.在publisher服务中定义一个…

基于JAVA+SpringBoot+Vue的前后端分离的医院信息智能化HIS系统

✌全网粉丝20W,csdn特邀作者、博客专家、CSDN新星计划导师、java领域优质创作者,博客之星、掘金/华为云/阿里云/InfoQ等平台优质作者、专注于Java技术领域和毕业项目实战✌ &#x1f345;文末获取项目下载方式&#x1f345; 一、项目背景介绍&#xff1a; 随着科技的不断发展&a…