无法 SSH 本地主机

无法 SSH 本地主机

我无法通过 SSH 连接本地主机。我也在 Ubuntu 12.04 LTS(32 位)上安装了 OpenSSH 服务器。

连接到网络(ip:192.168.1.2)安装hadoop,在本地机器上运行hadoop。

以下是我得到的结果:

root@kunal-Extensa-4620:/# ssh -vvv localhost
OpenSSH_5.9p1 Debian-5ubuntu1.1, OpenSSL 1.0.1 14 Mar 2012
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to localhost [127.0.0.1] port 22.
debug1: Connection established.
debug1: permanently_set_uid: 0/0
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.9p1 Debian-5ubuntu1.1
debug1: match: OpenSSH_5.9p1 Debian-5ubuntu1.1 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_5.9p1 Debian-5ubuntu1.1
debug2: fd 3 setting O_NONBLOCK
debug3: load_hostkeys: loading entries for host "localhost" from file "/root/.ssh/known_hosts"
debug3: load_hostkeys: loaded 0 keys
debug1: SSH2_MSG_KEXINIT sent
Read from socket failed: Connection reset by peer

答案1

评论您的 OpenSSH 服务器配置文件 ( ) 似乎为/etc/ssh/sshd_config空。通过清除并重新安装来重新安装配置文件:

  1. 删除配置文件:

    sudo rm /etc/ssh/sshd_config
    
  2. 清除:

    sudo apt-get purge openssh-server
    
  3. 安装:

    sudo apt-get install openssh-server
    

可能不起作用,请按照以下步骤操作:我如何恢复配置文件?

答案2

在您的日志中我看到以下消息 debug3: load_hostkeys: loading entries for host "localhost" from file "/root/.ssh/known_hosts"

所以这意味着机器正在尝试寻找主机,并且已经尝试了更多连接,检查 ssh 日志并在此处发布(这将揭示是否有任何连接到达本地主机)

还要检查你这边的 22 端口是否对传入连接开放,因为你这边的 22 端口似乎对传入连接关闭了,顺便检查一下你是否运行了某种防火墙(IPTABLES)等,阻止了它

当你执行 ssh user@localhost 时,屏幕上显示的具体消息是什么?你输入的ssh -vvv localhost它没有任何意义,ssh -vvv user@localhost应该是

答案3

使用以下命令进行连接

ssh [email protected]

将用户名更改为该计算机上可用的任何用户

相关内容