准备工作
要配置远程登录Kali Linux,首先我们需要更改默认的root密码并生成新的SSH密钥。
作者:
锦凡歆在酷狗直播唱歌最好听
怎么做
使用passwd命令修改root密码
- root@osboxes:~# passwd
- Enter new UNIX password:
- Retype new UNIX password:
- passwd: password updated successfully
- root@osboxes:~#
重新配置SSH主机密钥非常简单,首先删除当前的SSH主机密钥,然后使用dpkg-reconfigure openssh-server命令重新生成密钥即可。
- root@osboxes:~# rm /etc/ssh/ssh_host_*
- root@osboxes:~# dpkg-reconfigure openssh-server
- Creating SSH2 RSA key; this may take some time ...
- 2048 SHA256:1FN10l0k50Ng/dpeLIXTPmFGyupZB22hk4JNQC1aKcI root@osboxes (RSA)
- Creating SSH2 ECDSA key; this may take some time ...
- 256 SHA256:37c9q4AwOW4wEwUoEpQ1Jz/KXIYJfV53ORWeGBzONdI root@osboxes (ECDSA)
- Creating SSH2 ED25519 key; this may take some time ...
- 256 SHA256:ky1bOQlbMFIMB0si0w7Msv32fpSeza6lZeHn8OevGdU root@osboxes (ED25519)
- rescue-ssh.target is a disabled or a static unit, not starting it.
我们还需要编辑OpenSSH服务配置文件:/etc/ssh/sshd_config,将#PermitRootLogin without-password 更改为PermitRootLogin yes,从而运行root远程登录。
若要设置SSH服务开机启动,则执行systemctl enable ssh即可
- root@osboxes:~# systemctl enable ssh
- 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.
Tip:最好是将远程登录配置为密钥登录,而不是使用密码。