瀏覽代碼

Make allowing ssh passwords a separate menu entry

Bob Mottram 8 年之前
父節點
當前提交
6096ac3bf8
共有 1 個檔案被更改,包括 27 行新增20 行删除
  1. 27
    20
      src/freedombone-sec

+ 27
- 20
src/freedombone-sec 查看文件

@@ -175,12 +175,13 @@ function change_ssh_settings {
175 175
             return
176 176
         fi
177 177
         if [ ! $SSH_PASSWORDS ]; then
178
-            return
178
+            SSH_PASSWORDS='yes'
179 179
         fi
180 180
 
181 181
         sed -i "s|Ciphers .*|Ciphers $SSH_CIPHERS|g" $SSH_CONFIG
182 182
         sed -i "s|MACs .*|MACs $SSH_MACS|g" $SSH_CONFIG
183 183
         sed -i "s|KexAlgorithms .*|KexAlgorithms $SSH_KEX|g" $SSH_CONFIG
184
+        sed -i "s|#PasswordAuthentication .*|PasswordAuthentication $SSH_PASSWORDS|g" $SSH_CONFIG
184 185
         sed -i "s|PasswordAuthentication .*|PasswordAuthentication $SSH_PASSWORDS|g" $SSH_CONFIG
185 186
         systemctl restart ssh
186 187
         echo $'ssh server security settings changed'
@@ -203,6 +204,25 @@ function change_xmpp_settings {
203 204
     echo $'xmpp security settings changed'
204 205
 }
205 206
 
207
+function allow_ssh_passwords {
208
+    if [[ $SSH_PASSWORDS == "yes" ]]; then
209
+        dialog --title $"SSH Passwords" \
210
+               --backtitle $"Freedombone Security Configuration" \
211
+               --yesno $"\nAllow SSH login using passwords?" 7 60
212
+    else
213
+        dialog --title $"SSH Passwords" \
214
+               --backtitle $"Freedombone Security Configuration" \
215
+               --defaultno \
216
+               --yesno $"\nAllow SSH login using passwords?" 7 60
217
+    fi
218
+    sel=$?
219
+    case $sel in
220
+        0) SSH_PASSWORDS="yes";;
221
+        1) SSH_PASSWORDS="no";;
222
+        255) exit 0;;
223
+    esac
224
+}
225
+
206 226
 function interactive_setup {
207 227
     if [ $SSL_CIPHERS ]; then
208 228
         data=$(tempfile 2>/dev/null)
@@ -257,23 +277,6 @@ function interactive_setup {
257 277
         esac
258 278
     fi
259 279
 
260
-    if [[ $SSH_PASSWORDS == "yes" ]]; then
261
-        dialog --title $"SSH Passwords" \
262
-               --backtitle $"Freedombone Security Configuration" \
263
-               --yesno $"\nAllow SSH login using passwords?" 7 60
264
-    else
265
-        dialog --title $"SSH Passwords" \
266
-               --backtitle $"Freedombone Security Configuration" \
267
-               --defaultno \
268
-               --yesno $"\nAllow SSH login using passwords?" 7 60
269
-    fi
270
-    sel=$?
271
-    case $sel in
272
-        0) SSH_PASSWORDS="yes";;
273
-        1) SSH_PASSWORDS="no";;
274
-        255) exit 0;;
275
-    esac
276
-
277 280
     if [ $XMPP_CIPHERS ]; then
278 281
         data=$(tempfile 2>/dev/null)
279 282
         trap "rm -f $data" 0 1 2 5 15
@@ -680,7 +683,7 @@ function menu_security_settings {
680 683
     trap "rm -f $data" 0 1 2 5 15
681 684
     dialog --backtitle $"Freedombone Control Panel" \
682 685
            --title $"Security Settings" \
683
-           --radiolist $"Choose an operation:" 15 76 15 \
686
+           --radiolist $"Choose an operation:" 16 76 16 \
684 687
            1 $"Regenerate ssh host keys" off \
685 688
            2 $"Regenerate Diffie-Hellman keys" off \
686 689
            3 $"Update cipersuite" off \
@@ -688,7 +691,8 @@ function menu_security_settings {
688 691
            5 $"Renew Let's Encrypt certificate" off \
689 692
            6 $"Enable GPG based authentication (monkeysphere)" off \
690 693
            7 $"Register a website with monkeysphere" off \
691
-           8 $"Go Back/Exit" on 2> $data
694
+           8 $"Allow ssh login with passwords" off \
695
+           9 $"Go Back/Exit" on 2> $data
692 696
     sel=$?
693 697
     case $sel in
694 698
         1) exit 1;;
@@ -733,6 +737,9 @@ function menu_security_settings {
733 737
             register_website
734 738
             ;;
735 739
         8)
740
+            allow_ssh_passwords
741
+            ;;
742
+        9)
736 743
             exit 0
737 744
             ;;
738 745
     esac