无法通过 SSH 进入 QNX 6.5.0 VirtualBox 会话

Unable to ssh into QNX 6.5.0 VirtualBox session

我已经在 virtualbox 上重新安装了 QNX RTOS 6.5.0,我可以使用以下命令通过 ssh 进入其中:ssh root@127.0.0.1 -p 3022。我的 VirtualBox 环境中的网络设置设置为 NAT,端口转发设置为:

尝试连接 -vvv 标志时:

$ ssh -vvv root@127.0.0.1 -p 3022
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /home/main/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: resolving "127.0.0.1" port 3022
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 3022.
debug1: Connection established.
debug1: identity file /home/main/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /home/main/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/main/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/main/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/main/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/main/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/main/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/main/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
ssh_exchange_identification: Connection closed by remote host

在 QNX 上,我在 /etc/ssh/sshd_config 中修改了以下选项:

PermitRootLogin yes
PermitEmptyPasswords yes
Subsystem sftpd /usr/libexec/sftp-server

我也可以通过 vm ssh 进入我的笔记本电脑,但反之则不行。我还尝试通过 ssh 连接到我的笔记本电脑,但效果很好,然后在同一个虚拟机会话中通过 ssh 连接回虚拟机,但出现了同样的错误。

已解决。解决方案是生成新的 rsa 和 dsa 密钥:

random -t
ssh-keygen -t rsa -f /etc/ssh/ssh_host_key -b 1024
ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key

然后将 sshd 添加到 /etc/group 列表:sshd:x:6:root

然后重新运行 sshd: /usr/sbin/sshd

来源:How do you install an ssh server on qnx?

为了扩展上述解决方案,我发现在重新启动时我无法再通过 ssh 进入 VM。这是通过进入 /etc/rc.d/ 并将行 /usr/sbin/sshd 添加到 rc.local 文件来解决的。