微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

无法在 Google Coral 开发板上更改 sshd_config

如何解决无法在 Google Coral 开发板上更改 sshd_config

所以我在本周早些时候拿到了我的开发板。我试图开始使用并且能够重新刷新它,并且当我执行“mdt 设备”时,我的 Chromebook 能够看​​到该设备,但是当我执行“mdt shell”时,出现错误。我直接尝试了 ssh,详细信息如下所示。我的 Chromebook 无法看到使用 USB-C 数据连接的设备,但后来我能够通过 USB 串行连接连接到它,并使用 nmtui 将开发板连接到 WiFi(与 Chromebook 相同的网络)连接的)。从我在 Stackoverflow 和其他地方可以看到的问题是与板上的 sshd 配置有关,需要禁用 PAM 或启用密码身份验证。我试图这样做,但后来我发现我(用户 mendel)无法编辑 /etc/ssh/sshd_config 文件,因为 mendel 不在 sudoers 中,这很奇怪,因为 runonce.d 中有一个 99-mendel-sudo这正是这样做的(请参阅 https://coral.googlesource.com/mendel-minimal/+/refs/heads/master/etc/runonce.d/99-mendel-sudo,我已验证此文件存在于我的开发板上)。

那么,有没有人知道这个问题的解决方法(root 密码?)。我读过几个人在谈论 ssh 问题,所有解决方案都涉及编辑 sshd_config,这当然是有道理的。唯一的问题是这些页面(在 Medium、Stackoverflow、GitHub 上)都没有提到需要先将 Mendel 添加到 /etc/sudoers 的特殊内容。似乎是我遗漏了某些东西,或者关于将孟德尔添加到 sudoers 的某些东西已损坏。

这是我的 Mendel Linux 版本:

mendel@tuned-eft:~$ uname -a
Linux tuned-eft 4.14.98-imx #1 SMP PREEMPT Fri Jul 17 01:15:45 UTC 2020 aarch64 GNU/Linux
mendel@tuned-eft:~$ cat /etc/mendel_version
5.0
mendel@tuned-eft:~$

以下是来自我的 Chromebook 的 ssh 消息:

amiarora@penguin:~$ ssh -v amiarora@tuned-eft c i eth i

OpenSSH_7.9p1 Debian-10+deb10u2,OpenSSL 1.1.1d  10 Sep 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to tuned-eft [10.55.1.187] port 22.
debug1: Connection established.
debug1: identity file /home/amiarora/.ssh/id_rsa type -1
debug1: identity file /home/amiarora/.ssh/id_rsa-cert type -1
debug1: identity file /home/amiarora/.ssh/id_dsa type -1
debug1: identity file /home/amiarora/.ssh/id_dsa-cert type -1
debug1: identity file /home/amiarora/.ssh/id_ecdsa type -1
debug1: identity file /home/amiarora/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/amiarora/.ssh/id_ed25519 type -1
debug1: identity file /home/amiarora/.ssh/id_ed25519-cert type -1
debug1: identity file /home/amiarora/.ssh/id_xmss type -1
debug1: identity file /home/amiarora/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9p1 Debian-10+deb10u2
debug1: Remote protocol version 2.0,remote software version OpenSSH_7.9p1 Debian-10+deb10u2
debug1: match: OpenSSH_7.9p1 Debian-10+deb10u2 pat OpenSSH* compat 0x04000000
debug1: Authenticating to tuned-eft:22 as 'amiarora'
debug1: SSH2_MSG_KEXINIT sent
Connection closed by 10.55.1.187 port 22
amiarora@penguin:~$

在开发板上输出组命令。

mendel@tuned-eft:~$ groups
mendel adm sudo audio video plugdev staff games users netdev input render i2c systemd-journal bluetooth apex
mendel@tuned-eft:~$ sudo sudosh
>>> /etc/sudoers: Syntax error near line 28 <<<
sudo: parse error in /etc/sudoers near line 28
sudo: no valid sudoers sources found,quitting
sudo: unable to initialize policy plugin
mendel@tuned-eft:~$ 

任何帮助将不胜感激。

解决方法

我建议仍然使用密钥对身份验证,但使用 USB 串行连接进行设置。

  • 生成密钥对(例如 ssh-keygen)
  • 在您的 Chromebook 上,运行 mdt setkey [private key]
  • 将公钥复制到剪贴板
  • 在您的设备上(通过 USB 串行),编辑 ~/.ssh/authorized_keys(您可能会 需要同时制作 .ssh 和授权密钥)。复制您的公钥。
  • MDT 现在应该可以正常工作(我喜欢使用 mdt set 优选设备 [ip addr] 所以我不需要将 ip 地址添加到 命令)。

至于 sudoers 的问题,听到 Mendel 没有 sudo 访问权限令人惊讶。检查我的电路板:

mendel@elusive-dog:~$ groups
mendel adm sudo audio video plugdev staff games users netdev input render i2c systemd-journal bluetooth apex

你能验证吗?

,

我觉得很奇怪的一件事是您的 mendel 用户没有 sudoer 访问权限,但它确实应该是默认设置。没有它,就没有太多选项可以更改 sshd_configsudoers 文件。我最好的建议是继续使用以下说明重新刷新电路板: https://coral.ai/docs/dev-board/reflash/#flash-the-board

代替 mdt reboot-bootloader,您可能只需要手动重新启动板并在启动后的前 3 秒内输入任何内容以进入 u-boot 模式并在 u-boot 提示符中输入进入快速启动模式:

fastboot 0

作为参考,这就是我的 /etc/sudoer 的样子:

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.
#
Defaults        env_reset
Defaults        mail_badpass
Defaults        secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification

# User alias specification

# Cmnd alias specification

# User privilege specification
root    ALL=(ALL:ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL:ALL) ALL

# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d
mendel ALL=(ALL) NOPASSWD: ALL

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。