| 
				
			 | 
			
			
				@@ -410,6 +410,41 @@ function remove_gpg_key { 
			 | 
		
	
		
			
			| 
				410
			 | 
			
				410
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				411
			 | 
			
				411
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				412
			 | 
			
				412
			 | 
			
			
				 function add_ssh_key { 
			 | 
		
	
		
			
			| 
				
			 | 
			
				413
			 | 
			
			
				+    data=$(tempfile 2>/dev/null) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				414
			 | 
			
			
				+    trap "rm -f $data" 0 1 2 5 15 
			 | 
		
	
		
			
			| 
				
			 | 
			
				415
			 | 
			
			
				+    dialog --title $"Add your ssh public key" \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				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 
			 | 
		
	
		
			
			| 
				
			 | 
			
				418
			 | 
			
			
				+    sel=$? 
			 | 
		
	
		
			
			| 
				
			 | 
			
				419
			 | 
			
			
				+    case $sel in 
			 | 
		
	
		
			
			| 
				
			 | 
			
				420
			 | 
			
			
				+        0) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				421
			 | 
			
			
				+            SSH_PUBLIC_KEY=$(<$data) 
			 | 
		
	
		
			
			| 
				
			 | 
			
				422
			 | 
			
			
				+            if [ ${#SSH_PUBLIC_KEY} -gt 20 ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				423
			 | 
			
			
				+                if [[ "$SSH_PUBLIC_KEY" == "ssh-"* ]]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				424
			 | 
			
			
				+                    if [ ! -d /home/$USER/.ssh ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				425
			 | 
			
			
				+                        mkdir /home/$USER/.ssh 
			 | 
		
	
		
			
			| 
				
			 | 
			
				426
			 | 
			
			
				+                    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				427
			 | 
			
			
				+                    if [ ! -f /home/$USER/.ssh/authorized_keys ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				428
			 | 
			
			
				+                        touch /home/$USER/.ssh/authorized_keys 
			 | 
		
	
		
			
			| 
				
			 | 
			
				429
			 | 
			
			
				+                    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				430
			 | 
			
			
				+                    if ! grep -q "$SSH_PUBLIC_KEY" /home/$USER/.ssh/authorized_keys; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				431
			 | 
			
			
				+                        echo "$SSH_PUBLIC_KEY" >> /home/$USER/.ssh/authorized_keys 
			 | 
		
	
		
			
			| 
				
			 | 
			
				432
			 | 
			
			
				+                        dialog --title $"New ssh key added" \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				433
			 | 
			
			
				+                               --backtitle $"Freedombone User Control Panel" \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				434
			 | 
			
			
				+                               --msgbox $"Your ssh key has now been added" 6 50 
			 | 
		
	
		
			
			| 
				
			 | 
			
				435
			 | 
			
			
				+                    else 
			 | 
		
	
		
			
			| 
				
			 | 
			
				436
			 | 
			
			
				+                        dialog --title $"ssh key already added" \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				437
			 | 
			
			
				+                               --backtitle $"Freedombone User Control Panel" \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				438
			 | 
			
			
				+                               --msgbox $"That ssh key has already been added" 6 50 
			 | 
		
	
		
			
			| 
				
			 | 
			
				439
			 | 
			
			
				+                    fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				440
			 | 
			
			
				+                else 
			 | 
		
	
		
			
			| 
				
			 | 
			
				441
			 | 
			
			
				+                    dialog --title $"Unrecognised ssh public key" \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				442
			 | 
			
			
				+                           --backtitle $"Freedombone User Control Panel" \ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				443
			 | 
			
			
				+                           --msgbox $"This doesn't look like an ssh key" 6 50 
			 | 
		
	
		
			
			| 
				
			 | 
			
				444
			 | 
			
			
				+                fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				445
			 | 
			
			
				+            fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				446
			 | 
			
			
				+            ;; 
			 | 
		
	
		
			
			| 
				
			 | 
			
				447
			 | 
			
			
				+    esac 
			 | 
		
	
		
			
			| 
				413
			 | 
			
				448
			 | 
			
			
				 } 
			 | 
		
	
		
			
			| 
				414
			 | 
			
				449
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				415
			 | 
			
				450
			 | 
			
			
				 function remove_ssh_key { 
			 |