|
@@ -64,8 +64,6 @@ EXPORT_FILE=
|
64
|
64
|
|
65
|
65
|
CURRENT_DIR=$(pwd)
|
66
|
66
|
|
67
|
|
-REGENERATE_SSH_HOST_KEYS="no"
|
68
|
|
-REGENERATE_DH_KEYS="no"
|
69
|
67
|
DH_KEYLENGTH=2048
|
70
|
68
|
LETSENCRYPT_SERVER='https://acme-v01.api.letsencrypt.org/directory'
|
71
|
69
|
|
|
@@ -85,25 +83,6 @@ function get_ciphers_from_website {
|
85
|
83
|
SSL_CIPHERS=$(cat $WEBSITES_DIRECTORY/$1 | grep 'ssl_ciphers ' | awk -F "ssl_ciphers " '{print $2}' | awk -F "'" '{print $2}')
|
86
|
84
|
}
|
87
|
85
|
|
88
|
|
-function get_website_settings {
|
89
|
|
- if [ ! -d $WEBSITES_DIRECTORY ]; then
|
90
|
|
- return
|
91
|
|
- fi
|
92
|
|
-
|
93
|
|
- cd $WEBSITES_DIRECTORY
|
94
|
|
- for file in `dir -d *` ; do
|
95
|
|
- get_protocols_from_website $file
|
96
|
|
- if [ ${#SSL_PROTOCOLS} -gt $MINIMUM_LENGTH ]; then
|
97
|
|
- get_ciphers_from_website $file
|
98
|
|
- if [ ${#SSL_CIPHERS} -gt $MINIMUM_LENGTH ]; then
|
99
|
|
- break
|
100
|
|
- else
|
101
|
|
- SSL_PROTOCOLS=""
|
102
|
|
- fi
|
103
|
|
- fi
|
104
|
|
- done
|
105
|
|
-}
|
106
|
|
-
|
107
|
86
|
function get_imap_settings {
|
108
|
87
|
if [ ! -f $DOVECOT_CIPHERS ]; then
|
109
|
88
|
return
|
|
@@ -129,19 +108,10 @@ function get_xmpp_settings {
|
129
|
108
|
|
130
|
109
|
function get_ssh_settings {
|
131
|
110
|
if [ -f $SSH_CONFIG ]; then
|
132
|
|
- SSH_CIPHERS=$(cat $SSH_CONFIG | grep 'Ciphers ' | awk -F 'Ciphers ' '{print $2}')
|
133
|
|
- SSH_MACS=$(cat $SSH_CONFIG | grep 'MACs ' | awk -F 'MACs ' '{print $2}')
|
134
|
|
- SSH_KEX=$(cat $SSH_CONFIG | grep 'KexAlgorithms ' | awk -F 'KexAlgorithms ' '{print $2}')
|
135
|
111
|
SSH_PASSWORDS=$(cat $SSH_CONFIG | grep 'PasswordAuthentication ' | awk -F 'PasswordAuthentication ' '{print $2}')
|
136
|
112
|
fi
|
137
|
113
|
if [ -f /etc/ssh/ssh_config ]; then
|
138
|
114
|
SSH_HOST_KEY_ALGORITHMS=$(cat /etc/ssh/ssh_config | grep 'HostKeyAlgorithms ' | awk -F 'HostKeyAlgorithms ' '{print $2}')
|
139
|
|
- if [ ! $SSH_CIPHERS ]; then
|
140
|
|
- SSH_CIPHERS=$(cat /etc/ssh/ssh_config | grep 'Ciphers ' | awk -F 'Ciphers ' '{print $2}')
|
141
|
|
- fi
|
142
|
|
- if [ ! $SSH_MACS ]; then
|
143
|
|
- SSH_MACS=$(cat /etc/ssh/ssh_config | grep 'MACs ' | awk -F 'MACs ' '{print $2}')
|
144
|
|
- fi
|
145
|
115
|
fi
|
146
|
116
|
}
|
147
|
117
|
|
|
@@ -353,55 +323,51 @@ function send_monkeysphere_server_keys_to_users {
|
353
|
323
|
}
|
354
|
324
|
|
355
|
325
|
function regenerate_ssh_host_keys {
|
356
|
|
- if [[ $REGENERATE_SSH_HOST_KEYS == "yes" ]]; then
|
357
|
|
- rm -f /etc/ssh/ssh_host_*
|
358
|
|
- dpkg-reconfigure openssh-server
|
359
|
|
- echo $'ssh host keys regenerated'
|
360
|
|
- # remove small moduli
|
361
|
|
- awk '$5 > 2000' /etc/ssh/moduli > ~/moduli
|
362
|
|
- mv ~/moduli /etc/ssh/moduli
|
363
|
|
- echo $'ssh small moduli removed'
|
364
|
|
- # update monkeysphere
|
365
|
|
- DEFAULT_DOMAIN_NAME=
|
366
|
|
- read_config_param "DEFAULT_DOMAIN_NAME"
|
367
|
|
- monkeysphere-host import-key /etc/ssh/ssh_host_rsa_key ssh://$DEFAULT_DOMAIN_NAME
|
368
|
|
- SSH_ONION_HOSTNAME=$(cat ${COMPLETION_FILE} | grep 'ssh onion domain' | awk -F ':' '{print $2}')
|
369
|
|
- monkeysphere-host import-key /etc/ssh/ssh_host_rsa_key ssh://$SSH_ONION_HOSTNAME
|
370
|
|
- monkeysphere-host publish-key
|
371
|
|
- send_monkeysphere_server_keys_to_users
|
372
|
|
- echo $'updated monkeysphere ssh host key'
|
373
|
|
- systemctl restart ssh
|
374
|
|
- fi
|
|
326
|
+ rm -f /etc/ssh/ssh_host_*
|
|
327
|
+ dpkg-reconfigure openssh-server
|
|
328
|
+ echo $'ssh host keys regenerated'
|
|
329
|
+ # remove small moduli
|
|
330
|
+ awk '$5 > 2000' /etc/ssh/moduli > ~/moduli
|
|
331
|
+ mv ~/moduli /etc/ssh/moduli
|
|
332
|
+ echo $'ssh small moduli removed'
|
|
333
|
+ # update monkeysphere
|
|
334
|
+ DEFAULT_DOMAIN_NAME=
|
|
335
|
+ read_config_param "DEFAULT_DOMAIN_NAME"
|
|
336
|
+ monkeysphere-host import-key /etc/ssh/ssh_host_rsa_key ssh://$DEFAULT_DOMAIN_NAME
|
|
337
|
+ SSH_ONION_HOSTNAME=$(cat ${COMPLETION_FILE} | grep 'ssh onion domain' | awk -F ':' '{print $2}')
|
|
338
|
+ monkeysphere-host import-key /etc/ssh/ssh_host_rsa_key ssh://$SSH_ONION_HOSTNAME
|
|
339
|
+ monkeysphere-host publish-key
|
|
340
|
+ send_monkeysphere_server_keys_to_users
|
|
341
|
+ echo $'updated monkeysphere ssh host key'
|
|
342
|
+ systemctl restart ssh
|
375
|
343
|
}
|
376
|
344
|
|
377
|
345
|
function regenerate_dh_keys {
|
378
|
|
- if [[ $REGENERATE_DH_KEYS == "yes" ]]; then
|
379
|
|
- if [ ! -d /etc/ssl/mycerts ]; then
|
380
|
|
- echo $'No dhparam certificates were found'
|
381
|
|
- return
|
382
|
|
- fi
|
|
346
|
+ if [ ! -d /etc/ssl/mycerts ]; then
|
|
347
|
+ echo $'No dhparam certificates were found'
|
|
348
|
+ return
|
|
349
|
+ fi
|
383
|
350
|
|
384
|
|
- data=$(tempfile 2>/dev/null)
|
385
|
|
- trap "rm -f $data" 0 1 2 5 15
|
386
|
|
- dialog --backtitle "Freedombone Security Configuration" \
|
387
|
|
- --title "Diffie-Hellman key length" \
|
388
|
|
- --radiolist "The smaller length is better suited to low power embedded systems:" 12 40 3 \
|
389
|
|
- 1 "2048 bits" off \
|
390
|
|
- 2 "3072 bits" on \
|
391
|
|
- 3 "4096 bits" off 2> $data
|
392
|
|
- sel=$?
|
393
|
|
- case $sel in
|
394
|
|
- 1) exit 1;;
|
395
|
|
- 255) exit 1;;
|
396
|
|
- esac
|
397
|
|
- case $(cat $data) in
|
398
|
|
- 1) DH_KEYLENGTH=2048;;
|
399
|
|
- 2) DH_KEYLENGTH=3072;;
|
400
|
|
- 3) DH_KEYLENGTH=4096;;
|
401
|
|
- esac
|
|
351
|
+ data=$(tempfile 2>/dev/null)
|
|
352
|
+ trap "rm -f $data" 0 1 2 5 15
|
|
353
|
+ dialog --backtitle "Freedombone Security Configuration" \
|
|
354
|
+ --title "Diffie-Hellman key length" \
|
|
355
|
+ --radiolist "The smaller length is better suited to low power embedded systems:" 12 40 3 \
|
|
356
|
+ 1 "2048 bits" off \
|
|
357
|
+ 2 "3072 bits" on \
|
|
358
|
+ 3 "4096 bits" off 2> $data
|
|
359
|
+ sel=$?
|
|
360
|
+ case $sel in
|
|
361
|
+ 1) exit 1;;
|
|
362
|
+ 255) exit 1;;
|
|
363
|
+ esac
|
|
364
|
+ case $(cat $data) in
|
|
365
|
+ 1) DH_KEYLENGTH=2048;;
|
|
366
|
+ 2) DH_KEYLENGTH=3072;;
|
|
367
|
+ 3) DH_KEYLENGTH=4096;;
|
|
368
|
+ esac
|
402
|
369
|
|
403
|
|
- ${PROJECT_NAME}-dhparam --recalc yes -l ${DH_KEYLENGTH}
|
404
|
|
- fi
|
|
370
|
+ ${PROJECT_NAME}-dhparam --recalc yes -l ${DH_KEYLENGTH}
|
405
|
371
|
}
|
406
|
372
|
|
407
|
373
|
function renew_startssl {
|
|
@@ -528,11 +494,6 @@ function create_letsencrypt {
|
528
|
494
|
}
|
529
|
495
|
|
530
|
496
|
function update_ciphersuite {
|
531
|
|
- read_config_param SSL_CIPHERS
|
532
|
|
- read_config_param SSL_PROTOCOLS
|
533
|
|
- read_config_param SSH_CIPHERS
|
534
|
|
- read_config_param SSH_MACS
|
535
|
|
-
|
536
|
497
|
RECOMMENDED_SSL_CIPHERS="$SSL_CIPHERS"
|
537
|
498
|
if [ ${#RECOMMENDED_SSL_CIPHERS} -lt 5 ]; then
|
538
|
499
|
return
|
|
@@ -714,50 +675,72 @@ function remove_pinning {
|
714
|
675
|
esac
|
715
|
676
|
}
|
716
|
677
|
|
717
|
|
-function housekeeping {
|
718
|
|
- cmd=(dialog --separate-output \
|
719
|
|
- --backtitle "Freedombone Security Configuration" \
|
720
|
|
- --title "Housekeeping options" \
|
721
|
|
- --checklist "If you don't need to do any of these things then just press Enter:" 15 76 15)
|
722
|
|
- options=(1 "Regenerate ssh host keys" off
|
723
|
|
- 2 "Regenerate Diffie-Hellman keys" off
|
724
|
|
- 3 "Update cipersuite" off
|
725
|
|
- 4 "Create a new Let's Encrypt certificate" off
|
726
|
|
- 5 "Renew Let's Encrypt certificate" off
|
727
|
|
- 6 "Enable GPG based authentication (monkeysphere)" off
|
728
|
|
- 7 "Register a website with monkeysphere" off
|
729
|
|
- 8 "Go Back/Exit" on)
|
730
|
|
- choices=$("${cmd[@]}" "${options[@]}" 2>&1 >/dev/tty)
|
|
678
|
+function menu_security_settings {
|
|
679
|
+ data=$(tempfile 2>/dev/null)
|
|
680
|
+ trap "rm -f $data" 0 1 2 5 15
|
|
681
|
+ dialog --backtitle $"Freedombone Control Panel" \
|
|
682
|
+ --title $"Security Settings" \
|
|
683
|
+ --radiolist $"Choose an operation:" 15 76 15 \
|
|
684
|
+ 1 $"Regenerate ssh host keys" off \
|
|
685
|
+ 2 $"Regenerate Diffie-Hellman keys" off \
|
|
686
|
+ 3 $"Update cipersuite" off \
|
|
687
|
+ 4 $"Create a new Let's Encrypt certificate" off \
|
|
688
|
+ 5 $"Renew Let's Encrypt certificate" off \
|
|
689
|
+ 6 $"Enable GPG based authentication (monkeysphere)" off \
|
|
690
|
+ 7 $"Register a website with monkeysphere" off \
|
|
691
|
+ 8 $"Go Back/Exit" on 2> $data
|
|
692
|
+ sel=$?
|
|
693
|
+ case $sel in
|
|
694
|
+ 1) exit 1;;
|
|
695
|
+ 255) exit 1;;
|
|
696
|
+ esac
|
|
697
|
+
|
731
|
698
|
clear
|
732
|
|
- for choice in $choices
|
733
|
|
- do
|
734
|
|
- case $choice in
|
735
|
|
- 1)
|
736
|
|
- REGENERATE_SSH_HOST_KEYS="yes"
|
737
|
|
- ;;
|
738
|
|
- 2)
|
739
|
|
- REGENERATE_DH_KEYS="yes"
|
740
|
|
- ;;
|
741
|
|
- 3)
|
742
|
|
- update_ciphersuite
|
743
|
|
- ;;
|
744
|
|
- 4)
|
745
|
|
- create_letsencrypt
|
746
|
|
- ;;
|
747
|
|
- 5)
|
748
|
|
- renew_letsencrypt
|
749
|
|
- ;;
|
750
|
|
- 6)
|
751
|
|
- enable_monkeysphere
|
752
|
|
- ;;
|
753
|
|
- 7)
|
754
|
|
- register_website
|
755
|
|
- ;;
|
756
|
|
- 8)
|
757
|
|
- exit 0
|
758
|
|
- ;;
|
759
|
|
- esac
|
760
|
|
- done
|
|
699
|
+
|
|
700
|
+ read_config_param SSL_CIPHERS
|
|
701
|
+ read_config_param SSL_PROTOCOLS
|
|
702
|
+ read_config_param SSH_CIPHERS
|
|
703
|
+ read_config_param SSH_MACS
|
|
704
|
+ read_config_param SSH_KEX
|
|
705
|
+
|
|
706
|
+ get_imap_settings
|
|
707
|
+ get_ssh_settings
|
|
708
|
+ get_xmpp_settings
|
|
709
|
+ import_settings
|
|
710
|
+ export_settings
|
|
711
|
+
|
|
712
|
+ case $(cat $data) in
|
|
713
|
+ 1)
|
|
714
|
+ regenerate_ssh_host_keys
|
|
715
|
+ ;;
|
|
716
|
+ 2)
|
|
717
|
+ regenerate_dh_keys
|
|
718
|
+ ;;
|
|
719
|
+ 3)
|
|
720
|
+ interactive_setup
|
|
721
|
+ update_ciphersuite
|
|
722
|
+ ;;
|
|
723
|
+ 4)
|
|
724
|
+ create_letsencrypt
|
|
725
|
+ ;;
|
|
726
|
+ 5)
|
|
727
|
+ renew_letsencrypt
|
|
728
|
+ ;;
|
|
729
|
+ 6)
|
|
730
|
+ enable_monkeysphere
|
|
731
|
+ ;;
|
|
732
|
+ 7)
|
|
733
|
+ register_website
|
|
734
|
+ ;;
|
|
735
|
+ 8)
|
|
736
|
+ exit 0
|
|
737
|
+ ;;
|
|
738
|
+ esac
|
|
739
|
+
|
|
740
|
+ change_website_settings
|
|
741
|
+ change_imap_settings
|
|
742
|
+ change_ssh_settings
|
|
743
|
+ change_xmpp_settings
|
761
|
744
|
}
|
762
|
745
|
|
763
|
746
|
function import_settings {
|
|
@@ -1054,18 +1037,6 @@ do
|
1054
|
1037
|
shift
|
1055
|
1038
|
done
|
1056
|
1039
|
|
1057
|
|
-housekeeping
|
1058
|
|
-get_website_settings
|
1059
|
|
-get_imap_settings
|
1060
|
|
-get_ssh_settings
|
1061
|
|
-get_xmpp_settings
|
1062
|
|
-import_settings
|
1063
|
|
-export_settings
|
1064
|
|
-interactive_setup
|
1065
|
|
-change_website_settings
|
1066
|
|
-change_imap_settings
|
1067
|
|
-change_ssh_settings
|
1068
|
|
-change_xmpp_settings
|
1069
|
|
-regenerate_ssh_host_keys
|
1070
|
|
-regenerate_dh_keys
|
|
1040
|
+menu_security_settings
|
|
1041
|
+
|
1071
|
1042
|
exit 0
|