forked from 0x90/kali-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkali-mirror.sh
executable file
·172 lines (139 loc) · 6.37 KB
/
kali-mirror.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
#!/bin/bash
# Based on http://docs.kali.org/kali-support/kali-linux-mirrors
. helper.sh
mirror(){
read -p "New user for sync: " name
name=${name:-archvsync}
echo $name
echo "Enter your name:"
read name
echo "...and now your age:"
read age
adduser --disabled-password archvsync
mkdir /srv/mirrors/kali{,-security,-images}
chown archvsync:archvsync /srv/mirrors/kali{,-security,-images}
sed -i -e "s/RSYNC_ENABLE=false/RSYNC_ENABLE=true/" /etc/default/rsync
cp /etc/rsyncd.conf /etc/rsyncd.conf.bak
wget http://pastebin.com/raw.php?i=gMyZk3gM -O /etc/rsyncd.conf
service rsync start
sudo su - archvsync
wget http://archive.kali.org/ftpsync.tar.gz
tar zxf ftpsync.tar.gz
#Now we need to create two configurations files.
# We start from a template and we edit at least the MIRRORNAME, TO, RSYNC_PATH, and RSYNC_HOST parameters:
cp etc/ftpsync.conf.sample etc/ftpsync-kali.conf
cp etc/ftpsync.conf.sample etc/ftpsync-kali-security.conf
vim etc/ftpsync-kali.conf
grep -E '^[^#]' etc/ftpsync-kali.conf
#TODO: add some code here
MIRRORNAME=`hostname -f`
TO="/srv/mirrors/kali/"
RSYNC_PATH="kali"
RSYNC_HOST=archive.kali.org
vim etc/ftpsync-kali-security.conf
grep -E '^[^#]' etc/ftpsync-kali-security.conf
MIRRORNAME=`hostname -f`
TO="/srv/mirrors/kali-security/"
RSYNC_PATH="kali-security"
RSYNC_HOST=archive.kali.org
The last step is to setup the .ssh/authorized_keys file so that archive.kali.org can trigger your mirror:
mkdir -p .ssh
wget -O - -q http://archive.kali.org/pushmirror.pub >>.ssh/authorized_keys
#If you have not unpacked the ftpsync.tar.gz in the home directory,
# then you must adjust accordingly the “~/bin/ftpsync” path, which is hard-coded in .ssh/authorized_keys.
# Now you must send an email to [email protected] with all the URLs of your mirrors so that you can be added in the main mirror list
# and to open up your rsync access on archive.kali.org. Please indicate clearly who should be contacted in case of problems
# (or if changes must be made/coordinated to the mirror setup).
# Instead of waiting for the first push from archive.kali.org, you should run an initial rsync with a mirror close to you,
# using the mirror list linked above to select one. Assuming that you picked archive-4.kali.org, here’s what you can run as your
# dedicated mirror user:
rsync -qaH archive-4.kali.org::kali /srv/mirrors/kali/ &
rsync -qaH archive-4.kali.org::kali-security /srv/mirrors/kali-security/ &
rsync -qaH archive-4.kali.org::kali-images /srv/mirrors/kali-images/ &
# Manual Mirror of ISO Images
# The ISO images repository does not use push mirroring so you must schedule a daily rsync run.
# We provide a bin/mirror-kali-images script, which is ready to use that you can add in the crontab of your dedicated user.
# You just have to configure etc/mirror-kali-images.conf.
sudo su - archvsync
cp etc/mirror-kali-images.conf.sample etc/mirror-kali-images.conf
vim etc/mirror-kali-images.conf
grep -E '^[^#]' etc/mirror-kali-images.conf
TO=/srv/mirrors/kali-images/
crontab -e
crontab -l
# m h dom mon dow command
39 3 * * * ~/bin/mirror-kali-images
}
mirror
##########################
#!/bin/sh
# Based on http://docs.kali.org/kali-support/kali-linux-mirrors
adduser --disabled-password archvsync
mkdir /srv/mirrors/kali{,-security,-images}
chown archvsync:archvsync /srv/mirrors/kali{,-security,-images}
sed -i -e "s/RSYNC_ENABLE=false/RSYNC_ENABLE=true/" /etc/default/rsync
cat <<EOF > /etc/rsyncd.conf
uid = nobody
gid = nogroup
max connections = 25
socket options = SO_KEEPALIVE
[kali]
path = /srv/mirrors/kali
comment = The Kali Archive
read only = true
[kali-security]
path = /srv/mirrors/kali-security
comment = The Kali security archive
read only = true
[kali-images]
path = /srv/mirrors/kali-images
comment = The Kali ISO images
read only = true
EOF
service rsync start
sudo su - archvsync
wget http://archive.kali.org/ftpsync.tar.gz
tar zxf ftpsync.tar.gz
#Now we need to create two configurations files.
# We start from a template and we edit at least the MIRRORNAME, TO, RSYNC_PATH, and RSYNC_HOST parameters:
cp etc/ftpsync.conf.sample etc/ftpsync-kali.conf
cp etc/ftpsync.conf.sample etc/ftpsync-kali-security.conf
vim 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
vim etc/ftpsync-kali-security.conf
grep -E '^[^#]' etc/ftpsync-kali-security.conf
MIRRORNAME=`hostname -f`
TO="/srv/mirrors/kali-security/"
RSYNC_PATH="kali-security"
RSYNC_HOST=archive.kali.org
The last step is to setup the .ssh/authorized_keys file so that archive.kali.org can trigger your mirror:
mkdir -p .ssh
wget -O - -q http://archive.kali.org/pushmirror.pub >>.ssh/authorized_keys
#If you have not unpacked the ftpsync.tar.gz in the home directory,
# then you must adjust accordingly the “~/bin/ftpsync” path, which is hard-coded in .ssh/authorized_keys.
# Now you must send an email to [email protected] with all the URLs of your mirrors so that you can be added in the main mirror list
# and to open up your rsync access on archive.kali.org. Please indicate clearly who should be contacted in case of problems
# (or if changes must be made/coordinated to the mirror setup).
# Instead of waiting for the first push from archive.kali.org, you should run an initial rsync with a mirror close to you,
# using the mirror list linked above to select one. Assuming that you picked archive-4.kali.org, here’s what you can run as your
# dedicated mirror user:
rsync -qaH archive-4.kali.org::kali /srv/mirrors/kali/ &
rsync -qaH archive-4.kali.org::kali-security /srv/mirrors/kali-security/ &
rsync -qaH archive-4.kali.org::kali-images /srv/mirrors/kali-images/ &
# Manual Mirror of ISO Images
# The ISO images repository does not use push mirroring so you must schedule a daily rsync run.
# We provide a bin/mirror-kali-images script, which is ready to use that you can add in the crontab of your dedicated user.
# You just have to configure etc/mirror-kali-images.conf.
sudo su - archvsync
cp etc/mirror-kali-images.conf.sample etc/mirror-kali-images.conf
vim etc/mirror-kali-images.conf
grep -E '^[^#]' etc/mirror-kali-images.conf
TO=/srv/mirrors/kali-images/
crontab -e
crontab -l
# m h dom mon dow command
39 3 * * * ~/bin/mirror-kali-images