|
@@ -23,8 +23,7 @@ function enable_backports {
|
23
|
23
|
}
|
24
|
24
|
|
25
|
25
|
function remove_proprietary_repos {
|
26
|
|
- sed 's/ non-free//g' /etc/apt/sources.list > /tmp/sources.list
|
27
|
|
- cp -f /tmp/sources.list /etc/apt/sources.list
|
|
26
|
+ sed -i 's/ non-free//g' /etc/apt/sources.list
|
28
|
27
|
}
|
29
|
28
|
|
30
|
29
|
function update_the_kernel {
|
|
@@ -107,24 +106,17 @@ function enable_zram {
|
107
|
106
|
|
108
|
107
|
function hardware_random_number_generator
|
109
|
108
|
apt-get -y install rng-tools
|
110
|
|
- sed 's|#HRNGDEVICE=/dev/hwrng|HRNGDEVICE=/dev/hwrng|g' /etc/default/rng-tools > /tmp/rng-tools
|
111
|
|
- cp -f /tmp/rng-tools /etc/default/rng-tools
|
|
109
|
+ sed -i 's|#HRNGDEVICE=/dev/hwrng|HRNGDEVICE=/dev/hwrng|g' /etc/default/rng-tools
|
112
|
110
|
service rng-tools restart
|
113
|
111
|
}
|
114
|
112
|
|
115
|
113
|
function configure_ssh {
|
116
|
|
- sed 's/PermitRootLogin without-password/PermitRootLogin no/g' /etc/ssh/sshd_config > /tmp/sshd_config
|
117
|
|
- cp -f /tmp/sshd_config /etc/ssh/sshd_config
|
118
|
|
- sed 's/X11Forwarding yes/X11Forwarding no/g' /etc/ssh/sshd_config > /tmp/sshd_config
|
119
|
|
- cp -f /tmp/sshd_config /etc/ssh/sshd_config
|
120
|
|
- sed 's/ServerKeyBits 1024/ServerKeyBits 4096/g' /etc/ssh/sshd_config > /tmp/sshd_config
|
121
|
|
- cp -f /tmp/sshd_config /etc/ssh/sshd_config
|
122
|
|
- sed 's/TCPKeepAlive yes/TCPKeepAlive no/g' /etc/ssh/sshd_config > /tmp/sshd_config
|
123
|
|
- cp -f /tmp/sshd_config /etc/ssh/sshd_config
|
124
|
|
- sed 's|HostKey /etc/ssh/ssh_host_dsa_key|#HostKey /etc/ssh/ssh_host_dsa_key|g' /etc/ssh/sshd_config > /tmp/sshd_config
|
125
|
|
- cp -f /tmp/sshd_config /etc/ssh/sshd_config
|
126
|
|
- sed 's|HostKey /etc/ssh/ssh_host_ecdsa_key|#HostKey /etc/ssh/ssh_host_ecdsa_key|g' /etc/ssh/sshd_config > /tmp/sshd_config
|
127
|
|
- cp -f /tmp/sshd_config /etc/ssh/sshd_config
|
|
114
|
+ sed -i 's/PermitRootLogin without-password/PermitRootLogin no/g' /etc/ssh/sshd_config
|
|
115
|
+ sed -i 's/X11Forwarding yes/X11Forwarding no/g' /etc/ssh/sshd_config
|
|
116
|
+ sed -i 's/ServerKeyBits 1024/ServerKeyBits 4096/g' /etc/ssh/sshd_config
|
|
117
|
+ sed -i 's/TCPKeepAlive yes/TCPKeepAlive no/g' /etc/ssh/sshd_config
|
|
118
|
+ sed -i 's|HostKey /etc/ssh/ssh_host_dsa_key|#HostKey /etc/ssh/ssh_host_dsa_key|g' /etc/ssh/sshd_config
|
|
119
|
+ sed -i 's|HostKey /etc/ssh/ssh_host_ecdsa_key|#HostKey /etc/ssh/ssh_host_ecdsa_key|g' /etc/ssh/sshd_config
|
128
|
120
|
echo "ClientAliveInterval 60" >> /etc/ssh/sshd_config
|
129
|
121
|
echo "ClientAliveCountMax 3" >> /etc/ssh/sshd_config
|
130
|
122
|
echo "Ciphers aes256-ctr,aes128-ctr" >> /etc/ssh/sshd_config
|
|
@@ -293,26 +285,16 @@ function save_firewall_settings {
|
293
|
285
|
}
|
294
|
286
|
|
295
|
287
|
function configure_internet_protocol {
|
296
|
|
- sed "s/#net.ipv4.tcp_syncookies=1/net.ipv4.tcp_syncookies=1/g" /etc/sysctl.conf > /tmp/sysctl.conf
|
297
|
|
- cp -f /tmp/sysctl.conf /etc/sysctl.conf
|
298
|
|
- sed "s/#net.ipv4.conf.all.accept_redirects = 0/net.ipv4.conf.all.accept_redirects = 0/g" /etc/sysctl.conf > /tmp/sysctl.conf
|
299
|
|
- cp -f /tmp/sysctl.conf /etc/sysctl.conf
|
300
|
|
- sed "s/#net.ipv6.conf.all.accept_redirects = 0/net.ipv6.conf.all.accept_redirects = 0/g" /etc/sysctl.conf > /tmp/sysctl.conf
|
301
|
|
- cp -f /tmp/sysctl.conf /etc/sysctl.conf
|
302
|
|
- sed "s/#net.ipv4.conf.all.send_redirects = 0/net.ipv4.conf.all.send_redirects = 0/g" /etc/sysctl.conf > /tmp/sysctl.conf
|
303
|
|
- cp -f /tmp/sysctl.conf /etc/sysctl.conf
|
304
|
|
- sed "s/#net.ipv4.conf.all.accept_source_route = 0/net.ipv4.conf.all.accept_source_route = 0/g" /etc/sysctl.conf > /tmp/sysctl.conf
|
305
|
|
- cp -f /tmp/sysctl.conf /etc/sysctl.conf
|
306
|
|
- sed "s/#net.ipv6.conf.all.accept_source_route = 0/net.ipv6.conf.all.accept_source_route = 0/g" /etc/sysctl.conf > /tmp/sysctl.conf
|
307
|
|
- cp -f /tmp/sysctl.conf /etc/sysctl.conf
|
308
|
|
- sed "s/#net.ipv4.conf.default.rp_filter=1/net.ipv4.conf.default.rp_filter=1/g" /etc/sysctl.conf > /tmp/sysctl.conf
|
309
|
|
- cp -f /tmp/sysctl.conf /etc/sysctl.conf
|
310
|
|
- sed "s/#net.ipv4.conf.all.rp_filter=1/net.ipv4.conf.all.rp_filter=1/g" /etc/sysctl.conf > /tmp/sysctl.conf
|
311
|
|
- cp -f /tmp/sysctl.conf /etc/sysctl.conf
|
312
|
|
- sed "s/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=0/g" /etc/sysctl.conf > /tmp/sysctl.conf
|
313
|
|
- cp -f /tmp/sysctl.conf /etc/sysctl.conf
|
314
|
|
- sed "s/#net.ipv6.conf.all.forwarding=1/net.ipv6.conf.all.forwarding=0/g" /etc/sysctl.conf > /tmp/sysctl.conf
|
315
|
|
- cp -f /tmp/sysctl.conf /etc/sysctl.conf
|
|
288
|
+ sed -i "s/#net.ipv4.tcp_syncookies=1/net.ipv4.tcp_syncookies=1/g" /etc/sysctl.conf
|
|
289
|
+ sed -i "s/#net.ipv4.conf.all.accept_redirects = 0/net.ipv4.conf.all.accept_redirects = 0/g" /etc/sysctl.conf
|
|
290
|
+ sed -i "s/#net.ipv6.conf.all.accept_redirects = 0/net.ipv6.conf.all.accept_redirects = 0/g" /etc/sysctl.conf
|
|
291
|
+ sed -i "s/#net.ipv4.conf.all.send_redirects = 0/net.ipv4.conf.all.send_redirects = 0/g" /etc/sysctl.conf
|
|
292
|
+ sed -i "s/#net.ipv4.conf.all.accept_source_route = 0/net.ipv4.conf.all.accept_source_route = 0/g" /etc/sysctl.conf
|
|
293
|
+ sed -i "s/#net.ipv6.conf.all.accept_source_route = 0/net.ipv6.conf.all.accept_source_route = 0/g" /etc/sysctl.conf
|
|
294
|
+ sed -i "s/#net.ipv4.conf.default.rp_filter=1/net.ipv4.conf.default.rp_filter=1/g" /etc/sysctl.conf
|
|
295
|
+ sed -i "s/#net.ipv4.conf.all.rp_filter=1/net.ipv4.conf.all.rp_filter=1/g" /etc/sysctl.conf
|
|
296
|
+ sed -i "s/#net.ipv4.ip_forward=1/net.ipv4.ip_forward=0/g" /etc/sysctl.conf
|
|
297
|
+ sed -i "s/#net.ipv6.conf.all.forwarding=1/net.ipv6.conf.all.forwarding=0/g" /etc/sysctl.conf
|
316
|
298
|
echo "# ignore pings" >> /etc/sysctl.conf
|
317
|
299
|
echo "net.ipv4.icmp_echo_ignore_all = 1" >> /etc/sysctl.conf
|
318
|
300
|
echo "net.ipv6.icmp_echo_ignore_all = 1" >> /etc/sysctl.conf
|
|
@@ -373,8 +355,7 @@ function configure_email {
|
373
|
355
|
echo "dc_mailname_in_oh='true'" >> /etc/exim4/update-exim4.conf.conf
|
374
|
356
|
echo "dc_localdelivery='maildir_home'" >> /etc/exim4/update-exim4.conf.conf
|
375
|
357
|
update-exim4.conf
|
376
|
|
- sed "s/START=no/START=yes/g" /etc/default/saslauthd > /tmp/saslauthd
|
377
|
|
- cp -f /tmp/saslauthd /etc/default/saslauthd
|
|
358
|
+ sed -i "s/START=no/START=yes/g" /etc/default/saslauthd
|
378
|
359
|
/etc/init.d/saslauthd start
|
379
|
360
|
|
380
|
361
|
# make a tls certificate for email
|
|
@@ -385,17 +366,10 @@ function configure_email {
|
385
|
366
|
chown root:Debian-exim /etc/exim4/exim.key /etc/exim4/exim.crt /etc/exim4/exim.dhparam
|
386
|
367
|
chmod 640 /etc/exim4/exim.key /etc/exim4/exim.crt /etc/exim4/exim.dhparam
|
387
|
368
|
|
388
|
|
- sed '/login_saslauthd_server/,/.endif/ s/# *//' /etc/exim4/exim4.conf.template > /tmp/exim4.conf.template
|
389
|
|
- cp -f /tmp/exim4.conf.template /etc/exim4/exim4.conf.template
|
390
|
|
-
|
391
|
|
- sed '/.ifdef MAIN_HARDCODE_PRIMARY_HOSTNAME/i\MAIN_HARDCODE_PRIMARY_HOSTNAME = $DOMAIN_NAME\nMAIN_TLS_ENABLE = true' /etc/exim4/exim4.conf.template > /tmp/exim4.conf.template
|
392
|
|
- cp -f /tmp/exim4.conf.template /etc/exim4/exim4.conf.template
|
393
|
|
-
|
394
|
|
- sed "s|SMTPLISTENEROPTIONS=''|SMTPLISTENEROPTIONS='-oX 465:25:587 -oP /var/run/exim4/exim.pid'|g" /etc/default/exim4 > /tmp/exim4
|
395
|
|
- cp -f /tmp/exim4 /etc/default/exim4
|
396
|
|
-
|
397
|
|
- sed '/03_exim4-config_tlsoptions/a\tls_on_connect_ports=465' /etc/exim4/exim4.conf.template > /tmp/exim4.conf.template
|
398
|
|
- cp -f /tmp/exim4.conf.template /etc/exim4/exim4.conf.template
|
|
369
|
+ sed -i '/login_saslauthd_server/,/.endif/ s/# *//' /etc/exim4/exim4.conf.template
|
|
370
|
+ sed -i '/.ifdef MAIN_HARDCODE_PRIMARY_HOSTNAME/i\MAIN_HARDCODE_PRIMARY_HOSTNAME = $DOMAIN_NAME\nMAIN_TLS_ENABLE = true' /etc/exim4/exim4.conf.template
|
|
371
|
+ sed -i "s|SMTPLISTENEROPTIONS=''|SMTPLISTENEROPTIONS='-oX 465:25:587 -oP /var/run/exim4/exim.pid'|g" /etc/default/exim4
|
|
372
|
+ sed -i '/03_exim4-config_tlsoptions/a\tls_on_connect_ports=465' /etc/exim4/exim4.conf.template
|
399
|
373
|
|
400
|
374
|
adduser $MY_USERNAME sasl
|
401
|
375
|
addgroup Debian-exim sasl
|
|
@@ -441,17 +415,12 @@ function configure_email {
|
441
|
415
|
|
442
|
416
|
function spam_filtering {
|
443
|
417
|
apt-get -y install spamassassin exim4-daemon-heavy
|
444
|
|
- sed 's/ENABLED=0/ENABLED=1/g' /etc/default/spamassassin > /tmp/spamassassin
|
445
|
|
- cp -f /tmp/spamassassin /etc/default/spamassassin
|
446
|
|
- sed 's/# spamd_address = 127.0.0.1 783/spamd_address = 127.0.0.1 783/g' /etc/exim4/exim4.conf.template > /tmp/exim4.conf.template
|
447
|
|
- cp -f /tmp/exim4.conf.template /etc/exim4/exim4.conf.template
|
|
418
|
+ sed -i 's/ENABLED=0/ENABLED=1/g' /etc/default/spamassassin
|
|
419
|
+ sed -i 's/# spamd_address = 127.0.0.1 783/spamd_address = 127.0.0.1 783/g' /etc/exim4/exim4.conf.template
|
448
|
420
|
# This configuration is based on https://wiki.debian.org/DebianSpamAssassin
|
449
|
|
- sed 's/local_parts = postmaster/local_parts = postmaster:abuse/g' /etc/exim4/conf.d/acl/30_exim4-config_check_rcpt > /tmp/30_exim4-config_check_rcpt
|
450
|
|
- cp -f /tmp/30_exim4-config_check_rcpt /etc/exim4/conf.d/acl/30_exim4-config_check_rcpt
|
451
|
|
- sed '/domains = +local_domains : +relay_to_domains/a\ set acl_m0 = rfcnames' /etc/exim4/conf.d/acl/30_exim4-config_check_rcpt > /tmp/30_exim4-config_check_rcpt
|
452
|
|
- cp -f /tmp/30_exim4-config_check_rcpt /etc/exim4/conf.d/acl/30_exim4-config_check_rcpt
|
453
|
|
- sed 's/accept/accept condition = ${if eq{$acl_m0}{rfcnames} {1}{0}}/g' /etc/exim4/conf.d/acl/40_exim4-config_check_data > /tmp/40_exim4-config_check_data
|
454
|
|
- cp -f /tmp/40_exim4-config_check_data /etc/exim4/conf.d/acl/40_exim4-config_check_data
|
|
421
|
+ sed -i 's/local_parts = postmaster/local_parts = postmaster:abuse/g' /etc/exim4/conf.d/acl/30_exim4-config_check_rcpt
|
|
422
|
+ sed -i '/domains = +local_domains : +relay_to_domains/a\ set acl_m0 = rfcnames' /etc/exim4/conf.d/acl/30_exim4-config_check_rcpt
|
|
423
|
+ sed -i 's/accept/accept condition = ${if eq{$acl_m0}{rfcnames} {1}{0}}/g' /etc/exim4/conf.d/acl/40_exim4-config_check_data
|
455
|
424
|
echo "warn message = X-Spam-Score: $spam_score ($spam_bar)" >> /etc/exim4/conf.d/acl/40_exim4-config_check_data
|
456
|
425
|
echo " spam = nobody:true" >> /etc/exim4/conf.d/acl/40_exim4-config_check_data
|
457
|
426
|
echo "warn message = X-Spam-Flag: YES" >> /etc/exim4/conf.d/acl/40_exim4-config_check_data
|