From: Nicolas Boisselier Date: Wed, 30 Apr 2025 23:04:03 +0000 (+0200) Subject: etc/profile.d/gpg.sh X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=a19bf6c58a52fcf906abffb60de0ad4eb395da37;p=nb.git etc/profile.d/gpg.sh --- diff --git a/etc/profile.d/gpg.sh b/etc/profile.d/gpg.sh index 6568f841..20d34b77 100644 --- a/etc/profile.d/gpg.sh +++ b/etc/profile.d/gpg.sh @@ -1,5 +1,6 @@ which gpg >/dev/null 2>&1 || return export GPG_TTY=$(tty) + gpg_import_ssh() { local usage="gpg_import_host HOST" local host=${1:?$usage} @@ -7,3 +8,26 @@ gpg_import_ssh() { ssh -t "$host" 'install -m 600 /dev/null "'$tmp'" && GPG_TTY=$(tty) gpg --armor --export-secret-keys -o "'$tmp'"' ssh "$host" 'cat "'$tmp'" && rm "'$tmp'"' | gpg --import --allow-secret-key-import } + +gpg_change_password() { + echo "Enter old password:" + read -s -p "Enter old password:" old + read -s -p "Enter new password:" new + read -s -p "Enter new password again:" new2 + if [ "$new" != "$new2" ] + then + echo New password differs + return 1 + fi + return + gpg --batch --passphrase-fd 0 --pinentry-mode loopback --change-passphrase KEY_ID <