How to fix the problem that Raspberry Pi cannot use the root user for SSH login All In One

如何修复树莓派无法使用 root 用户进行 SSH 登录的问题

应用场景

修改树莓派默认的密码和用户名后,使用 root 用户 SSH 登录,对 pi/home 文件夹进行备份,复制到新用户下 xgqfrms/home

errors

#  pi 用户切换到 root 用户
$ sudo su # 设置 root 用户的密码
root@raspberrypi:/home/pi# passwd
新的 密码:
重新输入新的 密码:
passwd:已成功更新密码 # 退回到 pi 用户
root@raspberrypi:/home/pi# exit
exit
# pi 用户退出 SSH 登录
$ logout # pi 用户 SSH 登录正常
$ ssh pi@raspberrypi.local # 密码没有错误,但是 root 用户一直无法 SSH 登录
$ ssh root@raspberrypi.local
root@raspberrypi.local's password:
Permission denied, please try again.
root@raspberrypi.local's password:
Permission denied, please try again.
root@raspberrypi.local's password:
root@raspberrypi.local: Permission denied (publickey,password).

solution

  1. 要给 root 设置登录密码,默认 root 没有密码

  2. 要开启 root 的 SSH 登录权限,默认是不允许 root 进行 SSH 访问的

# 修改
$ sudo vim /etc/ssh/sshd_config
# 重启 sshd 服务
$ systemctl restart sshd
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ===
重新启动“ssh.service”需要认证。
Authenticating as: ,,, (pi)
Password:
==== AUTHENTICATION COMPLETE ===

prohibit-password => yes

# Authentication:
# 临时打开 ️
LoginGraceTime 2m
PermitRootLogin yes
StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
# Authentication:
+ # 临时打开 ️
+ LoginGraceTime 2m
+ PermitRootLogin yes
+ StrictModes yes
- # LoginGraceTime 2m
- # PermitRootLogin prohibit-password
- # StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

demos

SSH & /etc/ssh/sshd_config

$ cat /etc/ssh/sshd_config
#	$OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information. # This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/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. 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 yes
StrictModes yes
#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)
ChallengeResponseAuthentication 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 ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication 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 ChallengeResponseAuthentication 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 /var/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

( 反爬虫测试!打击盗版️)如果你看到这个信息, 说明这是一篇剽窃的文章,请访问 https://www.cnblogs.com/xgqfrms/ 查看原创文章!

refs

https://www.cnblogs.com/xgqfrms/p/17446689.html#5181665



xgqfrms 2012-2021

www.cnblogs.com/xgqfrms 发布文章使用:只允许注册用户才可以访问!

原创文章,版权所有️xgqfrms, 禁止转载 ️,侵权必究️!


How to fix the problem that Raspberry Pi cannot use the root user for SSH login All In One的更多相关文章

  1. Raspberry Pi 摄像头模块入门

    目录 一.摄像头模块安装 二.使用命令控制摄像头 三.使用Python程序控制摄像头 四.基于vlc的Raspberry Pi摄像头实时监控 参考资料 Raspberry Pi提供了摄像头模块的接口, ...

  2. Raspberry Pi 4B 安装 CentOS 8

    最近新入手一块Raspberry Pi 4B 8G的板子,想在这块板子上搭建CentOS 8的环境.经过数次采坑终于安装成功. 准备条件: 1.Raspberry Pi 4B 板子 +  SD卡 2. ...

  3. raspberry pi使用笔记

    1.raspberry pi系统vim问题 习惯了Linux的vim的使用,但是在raspberry pi中,用apt-get install vim后,vim变得很难用,进入编辑模式,输入字母时会莫 ...

  4. [quote ]ffmpeg, gstreamer, Raspberry Pi, Windows Desktop streaming

    [quote ]ffmpeg, gstreamer, Raspberry Pi, Windows Desktop streaming http://blog.pi3g.com/2013/08/ffmp ...

  5. Raspberry Pi Kernel Compilation 内核编译官方文档

    elinux.org/Raspberry_Pi_Kernel_Compilation#Use_the_provided_compiler Software & Distributions: S ...

  6. Roomblock: a Platform for Learning ROS Navigation With Roomba, Raspberry Pi and RPLIDAR(转)

      What is this? "Roomblock" is a robot platform consists of a Roomba, a Raspberry Pi 2, a ...

  7. How to emulate a Raspberry Pi on your PC

    How to emulate a Raspberry Pi on your PC I am very interested in trying simulators and emulators for ...

  8. RASPBERRY PI 外设学习资源

    参考: http://www.siongboon.com/projects/2013-07-08_raspberry_pi/index.html Raspberry Pi         Get st ...

  9. Raspberry Pi Resources-Using the UART

    参考:RPi Serial Connection 本文来自:http://www.raspberry-projects.com/pi/programming-in-c/uart-serial-port ...

  10. Adding an On/Off switch to your Raspberry Pi

    http://www.raspberry-pi-geek.com/Archive/2013/01/Adding-an-On-Off-switch-to-your-Raspberry-Pi#articl ...

随机推荐

  1. 快速带你复习html(超详细)

    此内容包含: html基础 列表.表格 媒体元素 表单(重点) 1.HTML 基础 目标: 会使用HTML5的基本结构创建网页 会使用文本相关标签排版文本信息 会使用图像相关标签实现图文并茂的页面 会 ...

  2. git 从本地仓库提交至远程仓库 报错:error: failed to push some refs to "xxx"

    **原因**:远程库里面有个文件,但是本地没有这个文件,比如: README.md,完全提交上去会覆盖之前的文件,所以git会提示报错警告! **解决方案**:如果只有 README.md文件,可以使 ...

  3. ES6中的解构赋值(数组,对象,嵌套,默认值)

    解构赋值 通过解构赋值,可以快速从对象或者数组中取出属性或者数值. 解构赋值 可以通过定位到数组或者对象的某一个位置,将值直接赋给一个或多个变量. const arr = ['dasha', 'ers ...

  4. 一次因生产事故与chatGpt的对话

    一次因生产事故与chatGpt的对话 前言:生产出现了一个内存溢出的事故,记录错误信息.错误日志如下 org.springframework.web.util.NestedServletExcepti ...

  5. [Linux]CentOS7搭建/配置:YUM仓库/源[本地源/Web源(Apache HTTP(D))/自建源仓库]

    若想搞懂整个配置过程和原理,就按照章节(1 / 2)一步一步地来. 若想直接一步到位,不想花过多时间,尽快配好,就直接看附件章节. 什么是yum源? Yum(全称为 Yellow dog Update ...

  6. 【牛客小白月赛70】A-F题解【小d和超级泡泡堂】【小d和孤独的区间】【小d的博弈】【小d和送外卖】

    比赛传送门:https://ac.nowcoder.com/acm/contest/53366 难度适中. 作者:Eriktse 简介:19岁,211计算机在读,现役ACM银牌选手力争以通俗易懂的方式 ...

  7. 五月二十六日jdbc算法以及数据库

    1.在PreparedStatement创建SQL对象后,调用preparedStatement()方法时,通过占位符?来按照索引进行SQL语句动态执行通过setString()方法和setInt() ...

  8. Java Heap

    堆 堆是一种基于树的数据结构,是一种完全二叉树,堆中的所有的节点都按照特定的顺序排列. 在堆数据结构中,如果任意父节点的值都大于其子节点,则会产生一个大顶堆:反之,如果任意父节点的值都小于其子节点,则 ...

  9. JUC(六)堵塞队列与线程池

    堵塞队列 简介 def:在多线程中实现高效.安全的数据传输,主要是通过一个共享的队列,使得数据能够从一端输入,从另一端输出 当队列是空的,取数据的线程就会被堵塞,直到其他线程往空的队列中添加数据 当队 ...

  10. Redis(一)五种基本数据类型

    1 NoSQl数据库 1.1 技术的发展 技术的分类: ①解决功能性问题:javase ②解决扩展性问题:框架 ③解决性能问题:redis 1.2 NoSQL数据库概述 NoSQL(Not Only ...