the --pinentry-mode loopback doesn't work with --delete-secret-keys, it ends with error "gpg: deleting secret key failed: No pinentry" even if with --export-secret-keys is processed without any issues and passphrase is requested directly in command line
$ gpg2 --pinentry-mode loopback -a --export-secret-keys F4433F96910C9AC1FEF65A7299A5538C769B6150 -----BEGIN PGP PRIVATE KEY BLOCK----- Version: GnuPG v2 lQPGBFnnSl4BCADd1wEBR7xcxBMMEmnQh7WzYe8q1f4meaBY+wes+RVyO6MZogzv ... kr57Ty7Pvu0jrohVJeVJKJf9e82tbzzQBYldVDW4HTWUkJYBnoDFydt/+HoKJgvn iA== =ONaf -----END PGP PRIVATE KEY BLOCK----- $ gpg2 --pinentry-mode loopback --delete-secret-keys F4433F96910C9AC1FEF65A7299A5538C769B6150 gpg (GnuPG) 2.1.13; Copyright (C) 2016 Free Software Foundation, Inc. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. sec rsa2048/99A5538C769B6150 2017-10-18 Box B6FD1270D93C <firstname.lastname@example.org> Delete this key from the keyring? (y/N) y This is a secret key! - really delete? (y/N) y gpg: deleting secret key failed: No pinentry gpg: deleting secret subkey failed: No pinentry gpg: F4433F96910C9AC1FEF65A7299A5538C769B6150: delete key failed: No pinentry
This is a problem if I am connected to remote machine and need to remove secret key from keyring.