Removing ssh keys via the user control panel

This commit is contained in:
Bob Mottram 2016-02-27 12:01:55 +00:00
parent 021f5f9921
commit 8f02e9c434
1 changed files with 21 additions and 2 deletions

View File

@ -412,9 +412,9 @@ function remove_gpg_key {
function add_ssh_key {
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --title $"Add your ssh public key" \
dialog --title $"Add an ssh key for logging in" \
--backtitle $"Freedombone User Control Panel" \
--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
--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
sel=$?
case $sel in
0)
@ -448,6 +448,25 @@ function add_ssh_key {
}
function remove_ssh_key {
data=$(tempfile 2>/dev/null)
trap "rm -f $data" 0 1 2 5 15
dialog --title $"Remove an ssh key for logging in" \
--backtitle $"Freedombone User Control Panel" \
--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
sel=$?
case $sel in
0)
SSH_PUBLIC_KEY=$(<$data)
if [ ${#SSH_PUBLIC_KEY} -gt 5 ]; then
if [ -f /home/$USER/.ssh/authorized_keys ]; then
sed -i "s|.*${SSH_PUBLIC_KEY}.*||g" /home/$USER/.ssh/authorized_keys
dialog --title $"Remove an ssh public key" \
--backtitle $"Freedombone User Control Panel" \
--msgbox $"The ssh key has been removed" 6 50
fi
fi
;;
esac
}
function menu_encryption_keys {