寻求帮助。我在Macbook中安装了virtualbox,但无法通过ssh连接到virtualbox中的ubuntu。

系统是MacOS Sierra,virtualbox中的ubuntu是ubuntu16.04。我使用端口转发使mac上的端口2233映射到ubuntu中的端口22。

日志如下。

zhouyajingdeMacBook-Pro:~ yarkeezhou$ ssh -v -p 2233 -i ~/.ssh/id_rsa [email protected]
OpenSSH_7.3p1, LibreSSL 2.4.1
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 20: Applying options for *
debug1: Connecting to 127.0.0.1 [127.0.0.1] port 2233.
debug1: Connection established.
debug1: identity file /Users/yarkeezhou/.ssh/id_rsa type 1
debug1: key_load_public: No such file or directory
debug1: identity file /Users/yarkeezhou/.ssh/id_rsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.3
debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu2.1
debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu2.1 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 127.0.0.1:2233 as 'yarkee'
debug1: SSH2_MSG_KEXINIT sent
Connection closed by 127.0.0.1 port 2233

最佳答案

我知道了。 Ubuntu错过了ssh密钥。然后修复

ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
ssh-keygen -t dsa  -f /etc/ssh/ssh_host_dsa_key

10-04 23:38