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. 【CS231n assignment 2022】 vscode 环境配置

    文章目录 前言 一.安装 Python 二.安装 vscode 三. cs231n 作业下载 四.配置 vscode 五.虚拟环境包安装 六.数据集 前言 今年成功考上了本校的研究生,要开始进入研究生 ...

  2. 细节讲解并实操下: 去中心化社交协议 ---- Nostr

    作者:林冠宏 / 指尖下的幽灵.转载者,请: 务必标明出处. GitHub : https://github.com/af913337456/ 出版的书籍: <1.0-区块链DApp开发实战&g ...

  3. ARM 详解

    一.ARM 的发展史 ARM 的发展历史可以追溯到 1978 年,当年克里斯·库里(Chris Currry)所任职的公司遭遇财务危机,发展每况愈下,库里在和创始人深入沟通后,决定离职.当时的库里对微 ...

  4. pysimplegui之进度表one_line_progress_meter

    我们的代码中都有循环.'等待,看着文本窗口中滚动过去的计数器不是很快乐吗?一行代码如何获得一个进度表,其中包含有关您的代码的统计信息? one_line_progress_meter(title, c ...

  5. [ElasticSearch] ES集群状态由非正常状态(red)恢复为正常状态(green)的思路与实践

    1 场景描述 1.1 资源与原规划 三台主机组成ES集群的规划: 集群名: xxx_elastic 172.15.3.7 es1 master 172.15.3.8 es2 (非master) 172 ...

  6. 3.@RequestParma和@PathVariable的用法和区别

    前言 我相信很多程序员都会在自己的项目中使用到Restful风格来安全便捷地进行接口的编写,因此本文这篇博客来简要介绍一下controller方法中的两个注解:@RequestParma和@PathV ...

  7. 在smt贴片加工中手工焊接和机器焊接的区别

    在smt贴片加工领域,都需要将电子元件贴装在pcb板表面并进行焊接的,常用的焊接方式分为两种:手动焊接和全自动机器焊接,而常用的焊接机器有回流焊机和波峰焊机,那你知道他们的区别是什么吗?安徽英特丽带你 ...

  8. php正则表达式大全/php正则表达式使用方法整理集合

    匹配数字 "^\d+$" //非负整数(正整数 + 0) "[1][1-9][0-9]$" //正整数 "^((-\d+)|(0+))$" ...

  9. 去中心化金融-Lec3

    区块链 (什么是区块链?)区块链提供了一种无需可信的参与方,能够让多个参与方实现合作的方式(若存在可信的第三方,则不需要区块链:但是金融系统中往往没有可信的第三方) 终端用户工具:user inter ...

  10. RabbitMQ详解(下)

    一:序 通过<RabbitMQ详解(上)>一文中,我们可以知道RabbitMQ的一些基本的原生用法,如交换机的创建及消息的投递,但是在企业中我们大部分都是把RabbitMQ集成到Sprin ...