Enable gpg-agent for users
This commit is contained in:
parent
5f9fdcb159
commit
3bb1002538
|
@ -156,6 +156,7 @@ if [ ! -f $MY_GPG_PUBLIC_KEY ]; then
|
|||
userdel -r $ADD_USERNAME
|
||||
exit 7
|
||||
fi
|
||||
|
||||
gpg_agent_setup $ADD_USERNAME
|
||||
|
||||
# add a monkeysphere subkey
|
||||
|
@ -246,7 +247,11 @@ if [ -d /home/$ADD_USERNAME/.gnupg/crls.d ]; then
|
|||
fi
|
||||
|
||||
${PROJECT_NAME}-pass -u $ADD_USERNAME -a login -p "$NEW_USER_PASSWORD"
|
||||
|
||||
gpg_agent_enable $ADD_USERNAME
|
||||
|
||||
clear
|
||||
|
||||
echo $"New user $ADD_USERNAME was created"
|
||||
echo $"Their login password is $NEW_USER_PASSWORD"
|
||||
echo ''
|
||||
|
|
|
@ -923,7 +923,7 @@ function menu_top_level {
|
|||
}
|
||||
|
||||
sign_keys
|
||||
gpg_agent_setup $USER
|
||||
gpg_agent_enable $USER
|
||||
menu_top_level
|
||||
clear
|
||||
. ~/.bashrc
|
||||
|
|
|
@ -268,6 +268,33 @@ function gpg_agent_setup {
|
|||
fi
|
||||
}
|
||||
|
||||
function gpg_agent_enable {
|
||||
gpg_username=$1
|
||||
|
||||
if [[ $gpg_username == 'root' ]]; then
|
||||
return
|
||||
else
|
||||
if grep -q 'GPG_TTY' /home/$gpg_username/.bashrc; then
|
||||
sed -i '/GPG_TTY/d' /home/$gpg_username/.bashrc
|
||||
chown $gpg_username:$gpg_username /home/$gpg_username/.bashrc
|
||||
fi
|
||||
if grep -q 'use-agent' /home/$gpg_username/.gnupg/gpg.conf; then
|
||||
sed -i '/use-agent/d' /home/$gpg_username/.gnupg/gpg.conf
|
||||
fi
|
||||
if grep -q 'pinentry-mode loopback' /home/$gpg_username/.gnupg/gpg.conf; then
|
||||
sed -i '/pinentry-mode loopback/d' /home/$gpg_username/.gnupg/gpg.conf
|
||||
fi
|
||||
if [ -f /home/$gpg_username/.gnupg/gpg-agent.conf ]; then
|
||||
rm /home/$gpg_username/.gnupg/gpg-agent.conf
|
||||
fi
|
||||
if [[ "$gpg_username" != "$USER" ]]; then
|
||||
su -c "echo RELOADAGENT | gpg-connect-agent" - $gpg_username
|
||||
else
|
||||
echo RELOADAGENT | gpg-connect-agent
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
function gpg_pubkey_from_email {
|
||||
key_owner_username=$1
|
||||
key_email_address=$2
|
||||
|
|
Loading…
Reference in New Issue