Преглед изворни кода

Removing ssh keys via the user control panel

Bob Mottram пре 9 година
родитељ
комит
8f02e9c434
1 измењених фајлова са 21 додато и 2 уклоњено
  1. 21
    2
      src/freedombone-controlpanel-user

+ 21
- 2
src/freedombone-controlpanel-user Прегледај датотеку

@@ -412,9 +412,9 @@ function remove_gpg_key {
412 412
 function add_ssh_key {
413 413
     data=$(tempfile 2>/dev/null)
414 414
     trap "rm -f $data" 0 1 2 5 15
415
-    dialog --title $"Add your ssh public key" \
415
+    dialog --title $"Add an ssh key for logging in" \
416 416
            --backtitle $"Freedombone User Control Panel" \
417
-           --inputbox $"This will allow you to log into Freedombone if you have an ssh key on your system, and provides much stronger security than simply using a login password.\n\nWARNING: If you make any mistakes here then you may not be able to log in and will need to get the administrator to clear your ssh authorized_keys file." 15 60 2>$data
417
+           --inputbox $"This will allow you to log into ${PROJECT_NAME} if you have an ssh key on your system, and provides much stronger security than simply using a login password.\n\nWARNING: If you make any mistakes here then you may not be able to log in and will need to get the administrator to clear your ssh authorized_keys file." 15 60 2>$data
418 418
     sel=$?
419 419
     case $sel in
420 420
         0)
@@ -448,6 +448,25 @@ function add_ssh_key {
448 448
 }
449 449
 
450 450
 function remove_ssh_key {
451
+    data=$(tempfile 2>/dev/null)
452
+    trap "rm -f $data" 0 1 2 5 15
453
+    dialog --title $"Remove an ssh key for logging in" \
454
+           --backtitle $"Freedombone User Control Panel" \
455
+           --inputbox $"Enter the ssh public key which is to be removed. This can be just the address at the end.\n\nWARNING: If you make any mistakes here then you may not be able to log in and will need to get the administrator to clear your ssh authorized_keys file." 15 60 2>$data
456
+    sel=$?
457
+    case $sel in
458
+        0)
459
+            SSH_PUBLIC_KEY=$(<$data)
460
+            if [ ${#SSH_PUBLIC_KEY} -gt 5 ]; then
461
+                if [ -f /home/$USER/.ssh/authorized_keys ]; then
462
+                    sed -i "s|.*${SSH_PUBLIC_KEY}.*||g" /home/$USER/.ssh/authorized_keys
463
+                    dialog --title $"Remove an ssh public key" \
464
+                           --backtitle $"Freedombone User Control Panel" \
465
+                           --msgbox $"The ssh key has been removed" 6 50
466
+                fi
467
+            fi
468
+            ;;
469
+    esac
451 470
 }
452 471
 
453 472
 function menu_encryption_keys {