Sfoglia il codice sorgente

Removing ssh keys via the user control panel

Bob Mottram 9 anni fa
parent
commit
8f02e9c434
1 ha cambiato i file con 21 aggiunte e 2 eliminazioni
  1. 21
    2
      src/freedombone-controlpanel-user

+ 21
- 2
src/freedombone-controlpanel-user Vedi File

412
 function add_ssh_key {
412
 function add_ssh_key {
413
     data=$(tempfile 2>/dev/null)
413
     data=$(tempfile 2>/dev/null)
414
     trap "rm -f $data" 0 1 2 5 15
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
            --backtitle $"Freedombone User Control Panel" \
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
     sel=$?
418
     sel=$?
419
     case $sel in
419
     case $sel in
420
         0)
420
         0)
448
 }
448
 }
449
 
449
 
450
 function remove_ssh_key {
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
 function menu_encryption_keys {
472
 function menu_encryption_keys {