docker安装kalilinux并配置ssh访问
1.拉取linuxkali系统
docker pull kalilinux/kali-linux-docker #拉取linuxkali系统
2.查看镜像文件
root@instance-20220207:~# docker images # REPOSITORY TAG IMAGE ID CREATED SIZE kalilinux/kali-rolling latest e8308dde407b 8 days ago 120MB matomo latest 5cdcc7bda51e 2 weeks ago 500MB whyour/qinglong latest b3c3978468a9 3 weeks ago 554MB jonnyan404/mrdoc-alpine latest f3b2904f3b75 3 weeks ago 717MB fredblgr/ubuntu-novnc 20.04 5ecc90d57f36 5 weeks ago 1.2GB registry.aliyuncs.com/openspug/spug latest b79726b9911b 8 weeks ago 691MB portainer/portainer-ce latest 1efc33b4796f 2 months ago 257MB
3.运行容器
(-d 放入后台 -t 终端-p 2222:22 将容器22端口映射到宿主机2222端口)
docker run -t -d -p 2222:22 e8308dde407b #
4.进入容器终端
docker exec -it e8308dde407b /bin/bash
5.更改root密码
centos/redhat(非交互式更改密码为123456)
echo 123456 | passwd --stdin root
ubuntu/debian(非交互式更改密码为123456)
echo "root:123456"|chpasswd
6.更新系统
apt-get update
7.安装SSH工具
apt-get install openssh-server
8.安装net-tools工具
apt-get install net-tools
9.查看是否运行
netstat -ant ┌──(root㉿a9145bab5282)-[/] └─# netstat -ant Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN tcp 0 0 172.17.0.6:22 150.230.93.137:51478 ESTABLISHED tcp6 0 0 :::22 :::* LISTEN
10.更改SSH配置文件允许root远程登陆
vi /etc/ssh/sshd_config ......... #Include /etc/ssh/sshd_config.d/*.conf #将该行注释 PermitRootLogin yes #将该行改为YES允许root登陆 PasswordAuthentication yes #将改行也改为YES 密码验证 ....................
11.重启SSHD服务配置生效
service ssh restart
12.远程SSH访问Kali系统
此时我们就可以通过 宿主机的IP+2222端口SSH远程ROOT登陆我们的Kali系统了(如宿主机IP是150.230.93.137)
example
ssh root@150.230.93.137 -p 2222
13.登陆成功的界面
┌──(root㉿a9145bab5282)-[~]
└─#
over