我正在尝试通过 ssh 连接到本地环境中的 raspberry pi 3 上的 ubuntu 服务器 22.04。起初我只是使用了命令,但出现了错误!所以我修改了文件并取消注释了和行。再次尝试后,我收到了错误(我被告知这是在您输入错误密码时显示的,但我输入了正确的密码)。有趣的是,我能够从 ubuntu 服务器通过 ssh 连接到 myPC,但反之则不行。我终于能够使用 puclickey 进行 ssh,但对于我和我的同事来说,使用密码验证连接到 raspberry pi 要容易得多,特别是因为它在本地网络环境中。ssh [email protected]
premission denied (publickey)
sshd_config
PasswordAuthentication yes
PublickeyAuthentication no
premission denied()
有人知道如何使用密码进行 ssh 吗?
编辑:这是 ssh -vvv 命令输出的重要部分
amir@amirux:~$ ssh -vvvv [email protected]
OpenSSH_8.9p1 Ubuntu-3ubuntu0.10, OpenSSL 3.0.2 15 Mar 2022
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug2: resolve_canonicalize: hostname 192.168.179.15 is address
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts' -> '/home/amir/.ssh/known_hosts'
debug3: expanded UserKnownHostsFile '~/.ssh/known_hosts2' -> '/home/amir/.ssh/known_hosts2'
debug3: ssh_connect_direct: entering
debug1: Connecting to 192.168.179.15 [192.168.179.15] port 22.
debug3: set_sock_tos: set socket 3 IP_TOS 0x10
debug1: Connection established.
.
.
.
debug1: Next authentication method: password
[email protected]'s password:
debug3: send packet: type 50
debug2: we sent a password packet, wait for reply
debug3: receive packet: type 51
debug1: Authentications that can continue:
Permission denied, please try again.
看来我输入了错误的密码,但我 100% 确定它是正确的。正如有人在评论部分提到的那样,cloud init 似乎安装在 RPi 上,这可以阻止密码验证吗?
感谢@user68186,我能够解决这个问题。
cloud init
RPi 上的 可能会干扰密码验证。我通过检查使用 cloud init 日志发现less /var/log/cloud-init.log
它正在修改 ssh 配置并覆盖其文件。/etc/ssh/sshd_config.d/50-cloud-init.conf
日志文件中的文件路径引起了我的注意。所以我打开文件并看到那里有一行passwordAuthentication no
!只需将其更改为yes
,现在使用密码的 ssh 登录就可以正常工作了。感谢大家的帮助,希望遇到同样问题的人发现此解决方案有用 <3