在VM虚拟中,安装好kali,默认是关闭了root账号(空密码)登录,没有开启ssh远程连接。
1. 给root账号设置密码
利用可以登录的其他用户文件,利用sudo命令给root用户添加密码:
┌──(kali㉿kali)-[~]
└─$ sudo passwd root
[sudo] password for kali:
New password:
Retype new password:
passwd: password updated successfully
2. 用root账号登录,进行相关的配置
打开终端。
![](https://img-blog.csdnimg.cn/img_convert/78e1be4dc401b51a0d3483194f2f150c.png)
在终端中进行ssh的配置,配置文件有两个:分别是ssh和sshd,其存放的目录是:/etc/ssh中,①ssh_config,②sshd_config。
![](https://img-blog.csdnimg.cn/img_convert/51e7c65f30dec8f040612f6cce41cfe8.png)
输入命令 vim /etc/ssh/ssh_config
在==# PasswprdAuthentication yes== 语句中把注释去掉(允许账号和密码登录),如下图:
![](https://img-blog.csdnimg.cn/img_convert/4a00164b1c6ee4102a2c91db1785a503.png)
输入命令 vim /etc/ssh/sshd_config
在这个配置文件中,要更改两处地方:①PermitRootLogin 和 ②PubkeyAuthentication。
第一个是允许root登录,第二个是通话ssh认证登录。配置如下:
![](https://img-blog.csdnimg.cn/img_convert/3152a1f24f73b8756b78a58ce32bb288.png)
3. 启动ssh服务且自动开启
输入/etc/init.d/ssh start启动ssh服务
之后可以用命令/etc/init.d/ssh status 来查看一下ssh是否开启了
![](https://img-blog.csdnimg.cn/img_convert/2dbb6a8a52702893cb5082a81f488305.png)
active(running)已经运行。
设置ssh服务开机自启:使用update-rc.d ssh enable命令
操作结束后,就可以使用ssh客户端程序连接kali了,也可以使用root用户和密码直接登录。
![](https://img-blog.csdnimg.cn/img_convert/2fb16904fe7cab24066b2b10f3d13522.png)