Centos8 installs docker and configures Kali Linux graphical interface

Since there is currently no complete and easy-to-use tutorial on docker installation of kali + desktop connection on the Internet, I want to make one.

image-20220914095948937

Preparation

Wow, the image provided by this server provider is really pure, so pure that there is nothing in it.

Question 1: There is a problem with Centos8 source

Error: Failed to download metadata for repo 'appstream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

Solution

Starting from January 31, 2022, the CentOS team will remove all packages of CentOS 8 from the official image, but the packages will still remain on the official image for a period of time. Now moved to https://vault.centos.org. If you want to continue running old CentOS 8, you can update repos.d in /etc/yum.repos and use vault.centos.org instead of mirror.centos.org

sudo sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*
sudo sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

Generate cache updates

yum makecache

image-20220914100412525

Run yum update and reinstall wget

yum update -y

image-20220914100825461

yum install wget -y

image-20220914101300267

Start installing docker. I wrote a tutorial on installing docker some time ago. I’ll just take it over.

docker installation

1. Install docker
# Check if there is an old version installed
[root@localhost ~]# yum remove docker docker-common docker-selinux docker-engine
#Install dependent software packages
[root@localhost ~]# yum install -y yum-utils device-mapper-persistent-data lvm2
# Set yum source
[root@localhost ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
# View all docker versions
[root@localhost ~]# yum list docker-ce --showduplicates | sort -r
# Install
[root@localhost ~]# yum install docker-ce -y
# View version
[root@localhost ~]# docker version
# start up
[root@localhost ~]# systemctl start docker
2. Install docker-compose
# Download docker compose
[root@localhost ~]# curl -L "https://github.com/docker/compose/releases/download/1.25.0/docker-compose-$(uname -s)-$(uname -m)" - o /usr/local/bin/docker-compose
#Add executable permissions
[root@localhost ~]# chmod + x /usr/local/bin/docker-compose
# Copy the file to the /usr/bin/ directory
[root@localhost ~]# ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
# View version
[root@localhost ~]# docker-compose --version

Install kali

Get image

docker pull kalilinux/kali-rolling

View image

docker images

Create container

docker run -t -d -p 60000:22 -p 60001:5901 -p 60002:5902 -p 60003:5903 Image name

Enter the container

docker exec -it container name /bin/bash

Change official source

echo 'deb http://mirrors.aliyun.com/kali kali-rolling main non-free contrib' > /etc/opt/source.list

echo 'deb-src http://mirrors.aliyun.com/kali kali-rolling main non-free contrib' >> /etc/opt/source.list

Because vim is not installed in the image you just pulled, if you want to use vim, you can install vim first.

apt-get install vim -y

Then vim /etc/opt/source.list just change the source. After modification, press esc and then :wq and press Enter.

image-20220915114052387

Need to update after modification

apt-get update & amp; & amp; apt-get upgrade

After updating, install the SSH service

#Install required software
apt-get install vim net-tools openssh-server
# vim modify the configuration file to allow root login
vim /etc/ssh/sshd_config

image-20220915114720569

#Start ssh service
service ssh start
#Allow auto-start on boot
systemctl enable ssh
# Modify root password
passwd root
#Then enter the new password twice.

image-20220915114829959

Then you can log in to kali through the 60000 port you just mapped.

image-20220915114939061

Install kali-everything
#Choose one of the two installation options below, the first one is recommended.
apt-get install kali-linux-everything #Install all tools provided by kali
apt-get install kali-linux-large #Install the default tools provided by kali

image-20220915145924260

Installation graphical interface
apt-get install kali-desktop-xfce
apt-get install xorg
apt-get install xfce4
apt-get install xrdp
Configure xrdp to implement remote connection graphical interface
sed -i 's/port=port number/port=port number/g' /etc/xrdp/xrdp.ini
echo xfce4-session >~/.xsession
service xrdp restart

Because the port number assigned to the container I just created is 60002:5902, here I can use :60002 to connect remotely.

image-20220915150637509

Log in to kali

The user is root and the password is ssh password

image-20220915150831295

image-20220915151003006

Done and call it a day!

Reference article:

  1. Docker/kali desktop_kefonlo’s blog-CSDN blog_docker kali graphical interface

  2. docker installation kali_Meng Xiaoxi’s blog-CSDN blog_docker kali

  3. Docker installation of kali – Zhihu (zhihu.com)

  4. How to use Remote Desktop Connection (RDP) to Kali/Ubuntu graphical desktop? – Nuggets (juejin.cn)