解决Xshell连接服务器失败:Could not connect to ‘192.168.191.128‘ (port 22): Connection failed.

前言:今天用Xshell连接虚拟机(Liunx)时,发生了这一项错误。翻阅了好多资料,终于解决了,于是记录一下,分享给大家,避免大家遇到同样的问题。

一、问题描述

  1. 首先我们使用ifconfig在Liunx(Ubuntu)中查询下网络ip,经查询为:192.168.191.128
  2. 下来,我们打开Xshell,配置相关信息,进行连接:
    解决Xshell连接服务器失败:Could not connect to ‘192.168.191.128‘ (port 22): Connection failed.
  3. 测试连接,报错如下:
    解决Xshell连接服务器失败:Could not connect to ‘192.168.191.128‘ (port 22): Connection failed.

二、解决问题

  1. 首先我们在Liunx(Ubuntu)中通过ps -e|grep ssh命令判断是否安装ssh服务:
    解决Xshell连接服务器失败:Could not connect to ‘192.168.191.128‘ (port 22): Connection failed.
    这里显示:只有客户端安装了,服务端没有安装。
  2. 接下来我们安装ssh服务器,命令:apt-get install openssh-server,如下:
    解决Xshell连接服务器失败:Could not connect to ‘192.168.191.128‘ (port 22): Connection failed.
    此处等待即可,ssh自会下载完成。
  3. 安装成功之后,启动ssh服务,命令:/etc/init.d/ssh start
    解决Xshell连接服务器失败:Could not connect to ‘192.168.191.128‘ (port 22): Connection failed.
    由上图可以看到:ssh服务启动成功。
  4. 接下来我们通过ps -e|grep ssh命令再次判断是否正确启动:
    解决Xshell连接服务器失败:Could not connect to ‘192.168.191.128‘ (port 22): Connection failed.
    此时,ssh服务端与客户端都启动成功了。

三、测试连接

  1. 经过步骤二的操作,ssh已经安装、启动成功了。

  2. 此时我们返回Xshell再次进行连接,就可以成功连接了。

友情链接:ssh(安全外壳协议)_百度百科