kali@kali:~$ ssh 192.168.246.165
Connection closed by 192.168.246.165 port 22
首先看一下ubuntu有没有安装openssh-server软件
root@ubuntu:~# dpkg -l | grep ssh
ii openssh-client 1:7.9p1-10 amd64 secure shell (SSH) client, for secure access to remote machines
ii openssh-server 1:7.9p1-10 amd64 secure shell (SSH) server, for secure access from remote machines
ssh服务有没有active或者进程有没有sshd
root@ubuntu:~# systemctl status ssh
root@ubuntu:~# ps -e | grep ssh
2083 ? 00:00:00 ssh-agent
3522 ? 00:00:00 sshd #有sshd说明ssh服务已经启动
如果没有可以运行命令启动ssh服务
root@ubuntu:~# /etc/init.d/ssh start #启动ssh服务
或者
root@ubuntu:~# systemctl start ssh #启动ssh服务
如果ssh服务启动了,还是不能访问要看一下配置文件
root@ubuntu:~# vim /etc/ssh/sshd_config #注意这里是sshd_config,不是ssh_config。
PermitRootLogin yes
PasswordAuthentication yes #打开密码认证,这个应该是可选 的
看一下22号端口有没有开放
root@ubuntu:~# netstat -tunlp | grep 22
查看/hosts.deny文件里面有没有禁止sshd
root@ubuntu:~# cat /etc/hosts.deny
重启ssh服务
root@ubuntu:~# /etc/init.d/ssh stop
root@ubuntu:~# /etc/init.d/ssh start
或者
root@ubuntu:~# systemctl restart ssh
调试ssh连接,V是输出debug信息
kali@kali:~$ ssh 192.168.246.165 -vv
查看一下/etc/passwd 里面的root用户的bin是不是设置成了/usr/sbin/nologin
用nmap扫描一下192.168.246.165的22号端口发现是开的
kali@kali:~$ nmap 192.168.246.165
Starting Nmap 7.80 ( https://nmap.org ) at 2021-07-25 01:31 EDT
Nmap scan report for 192.168.246.165
......
22/tcp open ssh
80/tcp open http
也是能ping通192.168.246.165的
折腾了半天,实现没有招了,重新安装openssh-server好了
安装的时候,覆盖现有的配置文件
查看一下配置文件,vim /etc/ssh/sshd_config
其实就是一项PermitRootLogin yes
备注:
root@ubuntu:~# lsb_release -a
Description: Ubuntu 19.04
本文暂时没有评论,来添加一个吧(●'◡'●)