通过 SSH 进入 Ubuntu MAAS

通过 SSH 进入 Ubuntu MAAS

我正在测试 MAAS。我在 vCenter 中通过 PXE 启动了虚拟机以安装 ubuntu 18.04。机器启动并获取了 IP 地址。

问题是,我似乎无法通过 SSH 进入它。我已确保通过以下方式导入 SSH 密钥:

john john-lnx ~ $ cat ~/.ssh/id_rsa.pub
# Copy the output, and paste it in the MAAS webgui for SSH keys. (I've done that in the MAAS installation but again now for troubleshooting)

当我尝试通过 SSH 进入机器时,我得到的结果是:

john john-lnx ~ $ ssh [email protected] -v
OpenSSH_7.6p1 Ubuntu-4ubuntu0.3, OpenSSL 1.0.2n  7 Dec 2017
debug1: Reading configuration data /home/john/.ssh/config
debug1: /home/john/.ssh/config line 2: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to 172.24.25.232 [172.24.25.232] port 22.
debug1: Connection established.
debug1: identity file /home/john/.ssh/id_rsa type 0
debug1: key_load_public: No such file or directory
debug1: identity file /home/john/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/john/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/john/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/john/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/john/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/john/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/john/.ssh/id_ed25519-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.6p1 Ubuntu-4ubuntu0.3
debug1: match: OpenSSH_7.6p1 Ubuntu-4ubuntu0.3 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 172.24.25.232:22 as 'ubuntu'
debug1: SSH2_MSG_KEXINIT sent
Connection reset by 172.24.25.232 port 22

这是由key_load_public它似乎在寻找的引起的吗?我做错了什么?

答案1

请检查文件的权限,/home/john/.ssh/id_rsa因为已建立连接但未找到文件。在我上次遇到的情况中,这是权限错误。

目录.ssh权限应为 700 ( drwx------)。公钥(.pub文件)应为 644 ( -rw-r--r--)。客户端主机上的私钥 (id_rsa) 和authorized_keys服务器上的文件应为 600 ( -rw-------)。

答案2

中的条目/var/log/auth.log将显示更多信息。像Could not load host key: /etc/ssh/ssh_host_rsa_key和这样的通知No supported key exchange algorithms [preauth]表明密钥文件存在问题。

之后的掉落SSH2_MSG_KEXINIT很可能也与钥匙有关。

因此,请执行dpkg-reconfigure openssh-server并再次检查连接。

如果此方法无效,请发表评论,我将删除此评论:)

相关内容