Failed to restart sshd.service: Unit sshd.service not found

Failed to restart sshd.service: Unit sshd.service not found.出现这个问题以及远程链接mobaxterm出现 Network error: Connection refused的解决方案如下

其实出现问题二就是kail2018里面的ssh服务未开启,和问题一是同样的,故汇集写在一篇帖子中,希望对广大学者有所启发。

首先第一步,直接ping主机,是可以ping通的,说明网络此时是正常的
root@kali:~# ping 10.32.6.117
PING 10.32.6.117 (10.32.6.117) 56(84) bytes of data.
64 bytes from 10.32.6.117: icmp_seq=1 ttl=64 time=0.025 ms
64 bytes from 10.32.6.117: icmp_seq=2 ttl=64 time=0.072 ms
64 bytes from 10.32.6.117: icmp_seq=3 ttl=64 time=0.072 ms
第二步,检查sshd的安装情况,(以下界面表面已安装)
root@kali:~# ps -e | grep ssh
  1421 ?        00:00:00 ssh-agent
  
第三步,ss -ntl 查询22端口是否开启,此处没有22端口
root@kali:~# ss -ntl
State   Recv-Q    Send-Q        Local Address:Port         Peer Address:Port 

此时我们需要修变量,执行vim /etc/ssh/sshd_config, 显示没有被修改,如果没被修改加入PermitRootLogin yes

在第三步中,需要修改的环境变量图片细节如下
这里我们可以按 i 键插入文字,按 Esc 键退出编辑,按 :wq 保存编辑内容
Failed to restart sshd.service: Unit sshd.service not found_第1张图片

第四步,重启sshd服务,(我这里失败了,所以接下来继续执行命令),
到这里如果问题已经解决的小伙伴,可以去查看一下端口号,确定无误可以连接。
root@kali:~# sudo service sshd restart
Failed to restart sshd.service: Unit sshd.service not found.

第五步,执行重启命令
root@kali:~# systemctl enable ssh.service
Synchronizing state of ssh.service with SysV service script with /lib/systemd/systemd-sysv-install.
Executing: /lib/systemd/systemd-sysv-install enable ssh
Created symlink /etc/systemd/system/sshd.service → /lib/systemd/system/ssh.service.

第六步以及第七步,查看端口号
root@kali:~# service sshd start
root@kali:~# ss -ntl
State    Recv-Q    Send-Q        Local Address:Port        Peer Address:Port    
LISTEN   0         128                 0.0.0.0:22               0.0.0.0:*       
LISTEN   0         128                    [::]:22                  [::]:*    

文章就写到这里,如果有误,欢迎批评指正!!

你可能感兴趣的:(笔记,linux)