PDA

View Full Version : How to create a mirror repository from kali



pedropt
2016-10-13, 12:09
Hi , i am wondering if anyone have an ideia on how to create in one of your lan servers a repository for kali .
I want to this for kali 1.1.0 only for now http://old.kali.org/kali/dists/moto/ .
The reason is that i have a gut that this repository will not be here for much time longer , and as security i want to have it on 1 of my servers in case i need some package from it in the future .

I was looking at some websites :
http://lgallardo.com/en/2012/12/06/como-crear-un-mirror-de-debian-y-ubuntu-con-debmirror/

but by default , people instead simplifying things they just complicate more .

Anyone of the admins here could give an idea in how to change this script for host the repository in this directory :/media/disk4/kali



#!/bin/sh

# Don't touch the user's keyring, have our own instead
export GNUPGHOME=/home/repo/keyrings/debian

# Architecture (i386, powerpc, amd64, etc.)
arch=i386,amd64

# Section (main,contrib,non-free)
section=main,contrib,non-free

# Release of the system (squeeze,lenny,stable,testing,etc)
release=squeeze

# Server name, minus the protocol and the path at the end
server=ftp.us.debian.org

# Path from the main server, so http://my.web.server/$dir, Server dependant
inPath=/debian

# Protocol to use for transfer (http, ftp, hftp, rsync)
proto=http

# Directory to store the mirror in
outPath=/home/repo/mirrors/debian

# Start script

debmirror -a $arch \
--no-source \
--md5sums \
--progress \
--passive \
--verbose \
-s $section \
-h $server \
-d $release \
-r $inPath \
-e $proto \
$outPath



and how do i install kali-archive-keyring_2015.2_all.deb properly according to this script :




# dpkg-deb -x ubuntu-keyring_2012.05.19_all.deb ~

# gpg --no-default-keyring --keyring /home/repo/keyrings/ubuntu/trustedkeys.gpg --import /root/usr/share/keyrings/ubuntu-archive-keyring.gpg

gpg: keyring `/home/repo/keyrings/ubuntu/trustedkeys.gpg' created
gpg: key 437D05B5: public key "Ubuntu Archive Automatic Signing Key " imported
gpg: key FBB75451: public key "Ubuntu CD Image Automatic Signing Key " imported
gpg: key C0B21F32: public key "Ubuntu Archive Automatic Signing Key (2012) " imported
gpg: key EFE21092: public key "Ubuntu CD Image Automatic Signing Key (2012) " imported
gpg: Total number processed: 4
gpg: imported: 4 (RSA: 2)
gpg: no ultimately trusted keys found



thanks .

pedropt
2016-10-13, 18:14
Problem Solved .

The script :

#!/bin/sh

# Don't touch the user's keyring, have our own instead
export GNUPGHOME=/kali/keyrings

# Architecture (i386, powerpc, amd64, etc.)
arch=i386,amd64

# Section (main,contrib,non-free)
section=main,contrib,non-free

# Release of the system (squeeze,lenny,stable,testing,etc)
release=moto

# Server name, minus the protocol and the path at the end
server=old.kali.org

# Path from the main server, so http://my.web.server/$dir, Server dependant
inPath=/kali

# Protocol to use for transfer (http, ftp, hftp, rsync)
proto=http

# Directory to store the mirror in
outPath=/media/disk4/kali/moto

# Start script

debmirror -a $arch \
--no-source \
--md5sums \
--progress \
--passive \
--verbose \
-s $section \
-h $server \
-d $release \
-r $inPath \
-e $proto \
$outPath

I had to download kali-archive-keyring_2015.2_all.deb and explort the gpg key to my folder at /kali/keyrings/trustedkeys.gpg

The debmirror is downloading the repository to /media/disk4/kali , where i will point later port 80 of nginx

pedropt
2016-10-16, 22:19
Eventually , this is how works after mirror the repository :

https://s22.postimg.org/ei5qibpw1/newrepo.png
https://s15.postimg.org/b9dtoxo7f/newrepo2.png
https://s14.postimg.org/jlaoryj8x/newrepo3.png

And pointing an http to your server on port 80 should look exactly like in kali repository :
https://s9.postimg.org/kh2uqx1bz/repohttp.png

An alternative way

Using wget

create the kali repository folder in your hard disk , and go to that directory
then apply the command to clone both repositories of kali sana & moto :

wget -r -np -nH --reject html*,gif,png --timestamping http://old.kali.org/kali/

This way wget will get all the files from the repository with original timestamp .
wget also will create a lot of html http directory structures , to remove them apply this command under you main directory of kali :

find . -name \index.* -type f -delete


To get only new updates to your existing repository , you should use :

wget -P /media/disk4/repo/kali/ -N --reject html*,gif,png --timestamping http://old.kali.org/kali/

-P switch is the output path to where wget will wire the files , witch in my case is /media/disk4/repo/kali/

-N switch tells wget to get the new files that are not yet in your repository folder

--timestamping tells wget to write in your repository the original date and time of the file at the main repository of kali .

Note : after the update you must always run the command in your main kali base repository :

find . -name \index.* -type f -delete
Somehow wget will write always html files from http directory structure .

However , these repositories of both sana and moto will not be updated again because kali is running on "kali-rooling" witch is a constant update on the fly and witch are in a different directory on kali main web server .

Note 2 : Downloading both Sana & Moto Kali repositories will require at least 500G of HDD space .

In case you want to clone the current kali-rooling repository , then you should add this link to your wget : http://http.kali.org/kali/