Ubuntu22.04.01Desktop桌面版 允许root用户远程登陆 笔记221110

2023-05-16

先给root设置密码

sudo passwd root

启用远程密码登录,和允许root远程ssh登陆

进入 /etc/ssh 目录

cd /etc/ssh

ls

root@ud224:/home/z# cd /etc/ssh/
root@ud224:/etc/ssh# ls
ssh_config  ssh_config.

在这里插入图片描述
只有 ssh_config 没有 sshd_config 说明 只安装了 openssh-client , 没有安装 openssh-server

安装 openssh-server

sudo apt install -y openssh-server

/etc/ssh目录下 变为
在这里插入图片描述

moduli      ssh_config.d  sshd_config.d       ssh_host_ecdsa_key.pub  ssh_host_ed25519_key.pub  ssh_host_rsa_key.pub
ssh_config  sshd_config   ssh_host_ecdsa_key  ssh_host_ed25519_key    ssh_host_rsa_key          ssh_import_id

查看 /etc/ssh/sshd_config 文件

sudo cat /etc/ssh/sshd_config
sudo less /etc/ssh/sshd_config
sudo more /etc/ssh/sshd_config
sudo vi /etc/ssh/sshd_config
sudo nano /etc/ssh/sshd_config
sudo gedit /etc/ssh/sshd_config

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# This sshd was compiled with PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

# 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.

Include /etc/ssh/sshd_config.d/*.conf

#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

# Expect .ssh/authorized_keys2 to be disregarded by default in future.
#AuthorizedKeysFile	.ssh/authorized_keys .ssh/authorized_keys2

#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 yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
KbdInteractiveAuthentication no

# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange 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'.
UsePAM yes

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
X11Forwarding yes
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
PrintMotd no
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

# override default of no subsystems
Subsystem	sftp	/usr/lib/openssh/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
#	X11Forwarding no
#	AllowTcpForwarding no
#	PermitTTY no
#	ForceCommand cvs server

其中
Include /etc/ssh/sshd_config.d/*.conf 会引入/etc/ssh/sshd_config.d/目录下的,以.conf结尾的文件,作为附加配置文件, 所以, 不要直接修改这个文件, 而是将修改的配置文件以.conf结尾,并放入/etc/ssh/sshd_config.d/目录

查看几个选项,

与远程登陆相关

  • #PasswordAuthentication yes 这个选项允许远程登陆用密码来认证, 但加了#号, 不会起作用
    将前面的#去掉, 变为 PasswordAuthentication yes 可以允许远程用密码登录认证

  • #PermitRootLogin prohibit-password 设为 PermitRootLogin yes 允许root远程登陆

与远程连接保持相关

  • #ClientAliveInterval 0 : ClientAliveInterval 多少秒测试一次远程客户端是否在线, 设为默认是0, 0不会测试
  • #ClientAliveCountMax 3: 客户端不响应的最大次数, 超过就断开连接, 默认值是3, 所可以不设置, 只设置ClientAliveInterval 就行了

PasswordAuthentication
Specifies whether password authentication is allowed. The default is yes.
指定是否允许密码身份验证。默认值为“yes”。

PermitRootLogin
Specifies whether root can log in using ssh(1). The argument must be yes, prohibit-password, forced-commands-only, or no. The default is prohibit-password.
If this option is set to prohibit-password (or its deprecated alias, without-password), password and keyboard-interactive authentication are disabled for root.

If this option is set to forced-commands-only, root login with public key authentication will be allowed, but only if the command option has been specified (which may be useful for taking remote backups even if root login is normally not allowed). All other authentication methods are disabled for root.

If this option is set to no, root is not allowed to log in.
指定 root 是否可以使用 ssh(1) 登录。参数必须是 [ yes , prohibit-password(禁止密码) , forced-commands-only(仅强制命令) , no ] 其中之一。默认值为prohibit-password
如果此选项设置为prohibit-password(或其已弃用的别名,without-password),则会为 root 禁用密码和键盘交互式身份验证。
prohibit-passwordwithout-password的新名字
如果此选项设置为 forced-commands-only,则将允许使用公钥身份验证进行root登录,但前提是指定了命令选项(即使通常不允许root登录,这对于进行远程备份也很有用)。所有其他身份验证方法都禁用 root 用户。
如果此选项设置为 no,则不允许 root 登录。

ClientAliveCountMax
Sets the number of client alive messages which may be sent without sshd(8) receiving any messages back from the client. If this threshold is reached while client alive messages are being sent, sshd will disconnect the client, terminating the session. It is important to note that the use of client alive messages is very different from TCPKeepAlive. The client alive messages are sent through the encrypted channel and therefore will not be spoofable. The TCP keepalive option enabled by TCPKeepAlive is spoofable. The client alive mechanism is valuable when the client or server depend on knowing when a connection has become unresponsive.
The default value is 3. If ClientAliveInterval is set to 15, and ClientAliveCountMax is left at the default, unresponsive SSH clients will be disconnected after approximately 45 seconds. Setting a zero ClientAliveCountMax disables connection termination.
设置在 sshd(8) 接收到客户端返回的任何消息的情况下可以发送的客户端活动消息的数量。如果在发送客户端活动消息时达到此阈值,sshd 将断开客户端的连接,从而终止会话。需要注意的是,客户端活动消息的使用与 TCPKeepAlive 非常不同。客户端活动消息通过加密通道发送,因此不会是可欺骗的。由 TCPKeepAlive 启用的 TCP 保持连接选项是可欺骗的。当客户端或服务器依赖于知道连接何时变得无响应时,客户端活动机制很有价值。
默认值为 3。如果 ClientAliveInterval 设置为 15,并且 ClientAliveCountMax 保留为默认值,则无响应的 SSH 客户端将在大约 45 秒后断开连接。设置零 ClientAliveCountMax 将禁用连接终止。

ClientAliveInterval
Sets a timeout interval in seconds after which if no data has been received from the client, sshd(8) will send a message through the encrypted channel to request a response from the client. The default is 0, indicating that these messages will not be sent to the client.
设置一个超时间隔(以秒为单位),如果客户端没有收到任何数据, sshd(8) 将通过加密通道发送消息请求客户端响应。默认值为 0,表示这些消息不会发送到客户端。


不直接修改/etc/ssh/sshd_config, 而是在 /etc/ssh/sshd_config.d 下建立一个 Mysshd.conf 配置文件
并重启sshd.service服务

echo '
PasswordAuthentication yes
PermitRootLogin yes
ClientAliveInterval 666
' | sudo tee /etc/ssh/sshd_config.d/Mysshd.conf
sudo systemctl restart sshd.service

因为 PasswordAuthentication 的默认值就是 yes , 所以可以不设置

echo '
PermitRootLogin yes
ClientAliveInterval 666
' | sudo tee /etc/ssh/sshd_config.d/Mysshd.conf
sudo systemctl restart sshd.service

来个进入 /etc/ssh/sshd_config.d/ 文件夹 的命令, 方便复制

cd  /etc/ssh/sshd_config.d/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Ubuntu22.04.01Desktop桌面版 允许root用户远程登陆 笔记221110 的相关文章

  • Tomcat中文乱码解决方案【亲测有效】

    场景一 xff1a SpringBoot项目 xff0c 在IDEA中启动 xff0c 访问接口 xff0c 无乱码 场景二 xff1a SpringBoot项目 xff0c 打成war包 xff0c 发到本地tomcat下 xff0c 启
  • 【Python】How to center an image in canvas Python Tkinter

    https www tutorialspoint com how to center an image in canvas python tkinter https www tutorialspoint com how to insert
  • [python]使用pyinstaller打包带界面的Pytorch程序的多个问题

    1 opencv兼容性问题 1 1 现象 打包为一个exe完成后 xff0c 在执行exe时 xff0c 报错 xff1a ImportError ERROR recursion is detected during loading of
  • VS2019下载与安装

    下载 xff0c 这里有一个说明 xff0c 下载说明 不再赘述 补充一下 xff0c 上面的地址中 xff0c 是VS2022的 xff0c 应该放的最新的 老的版本在这里下载 xff1a https visualstudio micro
  • Ubuntu下QtCreator的C++工程调用python

    目录 1 概述1 1 参考1 2 库引用1 3 初始与善后 2 函数调用3 类调用4 参数传递4 1 传递数值类型4 2 传递字符串4 3 传递bool4 4传递图片 5 解析放回的参数5 1 调用方法5 2 数值解析5 3 字符串解析5
  • Ubuntu的QTCreator中c++调用opencv方法

    注意 xff1a 这里用的是opencv 4 0以上版本 如果是4 0下的版本 xff0c 配置不同 xff0c 4 0在这个头文件之类的有变化 QTCreator下创建工程 xff0c 在工程文件 pro中增加配置 xff1a span
  • Ubuntu Qtcreator c++调用python报错

    调用时候 xff0c 报错 xff1a modpython 13107 Gtk ERROR 20 32 18 627 GTK 43 2 x symbols detected Using GTK 43 2 x and GTK 43 3 in
  • [Ubuntu, Ajax Nx]C++调用python报from import错误

    1 现象描述 c 43 43 调用python程序 调用的main函数 xff0c 该main函数中有如下代码 xff1a span class token keyword from span matching span class tok
  • Linux下c++串口编程

    1 NX串口管理 参见https blog csdn net weixin 42447868 article details 109051005 spm 61 1001 2014 3001 5506 2 串口权限管理 2 1 串口权限 xf
  • Jetson Nx 串口接收数据丢失首字节问题

    1 问题描述 I write a uart program using c 43 43 on Jetson Nx Jetpack 4 6 1 Ubuntu version 18 04 LTS to communicate with a PC
  • Linux下的一些基础功能

    1 关于命令行输出到文件 xff1a https www iplayio cn post 6296803 2 kz 64 JetsonNx ls l dev ttyS dev ttyUSB dev ttyTHS dev ttyCUDA ls
  • SpringBoot ☞ logback日志配置【屏蔽第三包中日志输出】

    一 项目配置文件如下 二 场景 项目启动时 xff0c 控制台无缘无故输出很多error级别的日志 xff0c 让人看着很不舒服 xff0c 断点调试 43 跟踪 xff0c 发现原来是第三方jar包里设置了日志输出 xff0c 如下 xf
  • 通过Xshell操作Jetson Nx

    1 Jetson Nx Nx留有Uart2 口 xff0c 便于使用xshell等进行操作 串口有三根线 链接后使用 2 XShell 软件 2 1 XShell软件介绍 XShell 软件是一个Windows上运行的终端模拟器 xff0c
  • Nx C++程序使用spdlog库进行日志存储

    1 spdlog简介 spdlog是一个开源的日志库 xff0c 在github上有 代码见这里 xff0c 文档这里 C 43 43 语言的 xff0c 支持Linux windows等系统 csdn上也有许多介绍 xff0c 这里列举两
  • C++下的Boost库

    1 介绍 xff08 引子网络 xff09 Boost库是为C 43 43 语言标准库提供扩展的一些C 43 43 程序库的总称 xff0c 由Boost社区组织开发 维护 Boost库可以与C 43 43 标准库完美共同工作 xff0c
  • Opencv之边界跟踪

    问题描述 一般是将二值化后的图像进行边界的提取 需要说明的是这个提取不是简单的找到边界 xff0c 而是按照顺序的找出来 即边界上的点是按照邻接关系依次给出 相关算法 xff08 1 xff09 这里解释 xff1a https blog
  • OpenCV之滤波

    图像滤波 xff0c 指在尽量保留图像细节特征的条件下对目标图像的噪声进行抑制 xff0c 是图像预处理中不可缺少的操作 xff0c 其处理效果的好坏将直接影响后续图像处理和分析的准确性 这里有个概述 xff0c 很好的 xff1a Ope
  • C++文件读写

    这个不错 xff1a C 43 43 文件读写详解 xff08 ofstream ifstream fstream xff09 C 43 43 文件读写详解 xff08 ofstream ifstream fstream xff09 c 4
  • python及其工具

    目录 1 conda xff1a 包管理器2 Anoconda xff1a 开源的包 环境管理器3 labelme4 tensorflow5 cuda和cudnn6 使用yml文件创建环境并安装文件6 1 yml文件由来6 2 如何获得ym
  • C++之文件操作移动、复制、重命名

    1 C 43 43 笔记之CopyFile和MoveFile的使用 2 删除和重命名 include lt fstream gt include lt windows h gt 与opencv的命名空间CV有冲突 xff0c 不能在一个文件

随机推荐

  • (转)C#数字转固定长度的字符串

    转 C 数字转固定长度的字符串
  • 进程监视工具

    Process Monitor 搜索能下到 xff0c 记下 xff0c 以后用 Process Monitor分析某个应用行为 Process Monitor 系统进程监视器 介绍教程 Using Process Monitor 帮助文档
  • UML建模工具Enterprise Architect(EA) -- 安装及简单使用

    目录 一 什么是EA xff1f 二 安装EA 三 为什么要学会用EA 四 创建EA工程 五 创建类视图 xff0c 构建类和接口 六 选中模型目录 xff0c 自动检出Java代码 七 构建内部类 八 趁热打铁 xff0c 构建数据表视图
  • SVN目录结构与分支等

    TortoiseSVN打分支 合并分支 切换分支 SVN创建分支 合并分支 切换分支
  • WPF上下标

    这里有个介绍的文章 xff1a 定义显示的上标和下标 里面介绍了三种方法 我之前有的是这个方法 xff1a Typography Variants 61 Superscript xff0c 如下所示 xff1a lt TextBlock g
  • [WPF] HamburgerMenu

    有两个库支持的 xff1a Metro App库中的 VS自己的控件 xff1a https docs microsoft com zh cn windows communitytoolkit archive hamburgermenu
  • 面积误差三种计算表达的比较

    引自 xff1a 面积误差三种计算表达的比较 有三种理论 xff0c 最基本的经典的 xff0c 引用一个吧 xff1a 网上有个题目 xff0c 求桌面面积的测量结果 桌面为矩形 用米尺测量 xff0c 长L为100 0 cm xff0c
  • 【转】WPF:Canvas中元素的定位

    概述 xff1a Canvas中的元素的大小和位置都是相对于Canvas容器的 xff0c 他的左上角为原点 xff0c 长度也是相对于他的 WPF xff1a Canvas中元素的定位 https blog csdn net chz cs
  • 【转】C#中计时

    一般可以用Environment TickCount xff0c 但是25天后会翻转 有很多 xff0c 见下面两个转的 C 中精确计时的一点收获 https www cnblogs com jintianhu archive 2010 0
  • 利用python分析微信聊天记录

    文章目录 前言一 任务分析二 工具三 步骤1 数据获取获取DB计算密码导出数据库 2 数据清洗 xff08 具体方法以后补充 xff09 3 数据分析 前言 昨天跟女朋友讨论谁给对方发的消息比较多 xff0c 两人各执一词 xff0c 事实
  • C++学习之模板

    文章目录 xff1a 一 模板 二 函数模板 三 类模板 一 模板 模板 也称泛型编程 泛型编程 xff1a 编写与类型无关的通用代码 xff0c 是代码复用的一种手段 模板是泛型编程的基础 在这之前我们可以利用C 43 43 的函数重载来
  • ROS2 创建python包

    1 创建python包 ros2 pkg create build type ament python span class token string 39 demo 39 span dependencies rclpy 以上指令为创建一个
  • Springboot集成SpringSecurity过程中遇到的问题

    Spring Security 开发文档 xff1a https www springcloud cc spring security zhcn html 一 配置的免登录访问接口不生效 span class token annotatio
  • 在sublime text3中配置c/c++运行环境

    在参考网上诸多大神配置sublime text3后 xff0c 自己也想写一篇有关在sublime中配置c c 43 43 的运行环境的文章 xff0c 顺便总结一下 安装sublime text3 xff1a 下载地址 xff08 官方地
  • STM32CubeMX 新建工程详细步骤

    STM32CubeMX 新建工程详细步骤 1 MPU CPU选择step1 打开CubeMX 软件 xff0c 在主页面上 点击如下按钮 xff0c 进入芯片选择界面step2 在Part Number Search 栏搜索我们需要用到的芯
  • macOS 10.11、macOS 10.12、macOS 10.13、macOS 10.14、macOS 10.15 制作可用于虚拟机安装的 CDR/ISO 系统镜像指导教程

    开篇说明 xff1a 不论是用 UltraISO xff0c 或者是用 MacOS 系统中的 磁盘工具 的格式转换功能进行 原版 DMG 61 61 gt CDR ISO 转换出来的 CDR ISO 文件只是进行了格式 xff08 容器 x
  • win10安装wsl2

    一 环境准备 1 确保bios开启虚拟化支持 各品牌主板进入bios的方式可百度或看主板说明书 2 查看当前win10版本是不是最新版 xff0c 如果不是则升级到最新版 查看当前版本 xff0c win 43 r打开运行窗口输入 34 w
  • snprintf 函数用法心得

    前人挖坑 xff0c 后人种树 不能对同一段内存 xff08 同一个buf 或是两个重叠的内存使用snprintf xff0c 换句等方面说 xff0c 在使用snprintf 时 xff0c 就确保内存不重叠 先来看看一段问题代码的执行结
  • VMware改变虚拟机文件在真实机的位置2208262201

    VMware 改变虚拟机文件位置 1 查看打开i虚拟机文件目录2 关闭虚拟机 将虚拟机文件夹复制或剪切到想要的位置3 用VMware打开复制的文件夹下的 vmx 文件 生成一个新的同名的虚拟机4 开启这个新生成的虚拟机 出现对话框选择意图
  • Ubuntu22.04.01Desktop桌面版 允许root用户远程登陆 笔记221110

    先给root设置密码 span class token function sudo span span class token function passwd span root 启用远程密码登录 和允许root远程ssh登陆 进入 etc