首先使用netstat -lnt查看一下当前kali开放的端口,如果没有开放22端口,我们需要手动开启22端口。
netstat -lnt
第一步:开启kail 远程ssh,开启办法如下:
1、配置SSH参数
修改sshd_config文件,命令为:vim /etc/ssh/sshd_config
![](http://upload-images.jianshu.io/upload_images/18666744-23e8d9224af874ae.png?imageMogr2/auto-orient/strip|imageView2/2/w/711/format/webp)
注:按 i 键开始编辑
将#PasswordAuthentication no的注释去掉,并且将NO修改为YES //kali中默认是yes
![](http://upload-images.jianshu.io/upload_images/18666744-c0793f3340eae8bd.png?imageMogr2/auto-orient/strip|imageView2/2/w/576/format/webp)
修改前
![](http://upload-images.jianshu.io/upload_images/18666744-6a5c1250ed546b0a.png?imageMogr2/auto-orient/strip|imageView2/2/w/553/format/webp)
修改后
将PermitRootLogin without-password修改为PermitRootLogin yes
![](http://upload-images.jianshu.io/upload_images/18666744-c44ed551d8b8fa8c.png?imageMogr2/auto-orient/strip|imageView2/2/w/854/format/webp)
修改前
![](http://upload-images.jianshu.io/upload_images/18666744-7c1c0894f0c327d6.png?imageMogr2/auto-orient/strip|imageView2/2/w/341/format/webp)
修改后
然后,按esc键后 输入:wq保存,退出vim
![](http://upload-images.jianshu.io/upload_images/18666744-57afd638a07b4354.png?imageMogr2/auto-orient/strip|imageView2/2/w/767/format/webp)
第二步:启动SSH服务
命令为:/etc/init.d/ssh start
或者service ssh start
![](http://upload-images.jianshu.io/upload_images/18666744-8177eae87977ea57.png?imageMogr2/auto-orient/strip|imageView2/2/w/518/format/webp)
查看SSH服务状态是否正常运行,命令为:
/etc/init.d/ssh status
或者
service ssh status
![](http://upload-images.jianshu.io/upload_images/18666744-059cac5819cf859b.png?imageMogr2/auto-orient/strip|imageView2/2/w/724/format/webp)
有running说明成功启动。
第三步:设置系统自动启动SSH服务
update-rc.d ssh enable //系统自动启动SSH服务
![](http://upload-images.jianshu.io/upload_images/18666744-85b3542fe6b0a473.png?imageMogr2/auto-orient/strip|imageView2/2/w/469/format/webp)
update-rc.d ssh disabled // 关闭系统自动启动SSH服务
再次执行netstat -lnt命令则看到22端口成功启动
![](http://upload-images.jianshu.io/upload_images/18666744-f9de270b00733271.png?imageMogr2/auto-orient/strip|imageView2/2/w/786/format/webp)