Kali Linux

How to Setup a Kali Linux Mirror

Using the easy-to-follow steps provided in this guide, you can set up a Kali Linux mirror that can host Kali’s main repositories and images. A Kali Linux mirror is handy.

Let us get started.

Requirements

To set up a complete Kali Linux mirror, you will need to have a few resources. These include:

  • An accessible web server with HTTP and HTTPs access
  • A large disk space—As of writing this, according to Kali Linux maintainers, the Kali Linux package repository is 1.1 TB and growing fast
  • HTTP and RSYNC services installed and running on the system

Set up a User for Kali Linux mirror

The first step is to set up a full account dedicated to kali Linux mirrors only. Use the adduser command:

$ adduser –disabled-password linuxhint

Adding user `linuxhint’...

Adding new group `linuxhint’ (1001) ...

Adding new user `linuxhint’ (1001) with group `linuxhint’...

Creating home directory `/home/linuxhint' ...

Copying files from `/etc/skel'
...

Changing the user information for linuxhint

Enter the new value, or press ENTER for the default

Full Name []:

Room Number []:

Work Phone []:

Home Phone []:

Other []:

Is the information correct? [Y/n] y

Set up Mirror Directories

Next, we need to set up the directories that contain the mirrors and assign permissions to the user we’ve created.

mkdir -p /srv/mirrors/kali{,-images}

chown linuxhint:linuxhint /srv/mirrors/kali{,-images}

The commands above will create the directories kali and kali-images and set ownership to the user we created earlier.

Set up rsync

The next step involves starting and configuring rsync service. Export the directories using the command:

sed -i -e "s/RSYNC_ENABLE=false/RSYNC_ENABLE=true/" /etc/default/rsync

# nano /etc/rsyncd.conf

# cat /etc/rsyncd.conf

uid = nobody

gid = nogroup

max connections = 25

socket options = SO_KEEPALIVE

 

[kali]

path = /srv/mirrors/kali

read only = true

[kali-images]

path = /srv/mirrors/kali-images

read only = true

# service rsync start

Starting rsync daemon: rsync.

Configuring your Mirrors

Next, we need to export the mirrors under http://domain.com/kali and http://domain.com/kali-images

We start by downloading and unarchiving the http://archive.kali.org/ftpsync.tar.gz archive in the user’s directory created earlier.

# su - archvsync

# wget http://archive.kali.org/ftpsync.tar.gz

# tar zxf ftpsync.tar.gz

Next set up the configuration file.

cp etc/ftpsync.conf.sample etc/ftpsync-kali.conf

nano etc/ftpsync-kali.conf

grep -E '^[^#]' etc/ftpsync-kali.conf

MIRRORNAME=`hostname -f`

TO="/srv/mirrors/kali/"

RSYNC_PATH="kali"

RSYNC_HOST=archive.kali.org

 Configuring SSH Access

The final step is to configure SSH authorized keys for archive.kali.org to trigger the mirror.

mkdir /home/linuxhint/.ssh

chown 700 /home/linuxhint/.ssh

wget –O- -q http://archive.kali.org/pushmirror.pub >> /home/linuxhint/.ssh/authorized_keys

chown 644 /home/linuxhint/authorized_keys

 Contacting Kali.org

Once you have finished setting up your system, send an email to [email protected] providing all details for your mirrors, including the user, the port to access the SSH service, and public hostname. You should also state who Kali should contact in case of problems and if any changes should get applied according to the mirror setup.

From there, all you have to do is wait for the first push from archive.kali.org.

About the author

John Otieno

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list