I am trying to encrypt a file using GPG. I am new to GPG. It's installed at version 2.0.22 on RHEL 7.4.
Whenever I try to run it, I get an error that the operation was cancelled by user.
sh-4.2$ gpg --output ~/test.gpg --symmetric --cipher-algo AES256 test.html gpg: cancelled by user gpg: error creating passphrase: Operation cancelled gpg: symmetric encryption of `test.html' failed: Operation cancelled sh-4.2$
From this answer I came to know that this could be due to the TTY permissions.
GnuPG tries to make sure it's reading the passphrase directly from the terminal, not (e.g.) piped from stdin. To do so, it tries to open the tty directly. Unfortunately, file permissions get in the way — the tty device is owned by the user you log in as. So only that user and root can open it. GnuPG appears to report the error incorrectly, saying you canceled (when in fact it got a permission denied).
For my machine, the TTY is owned by the root group with
g+rw, and while I am not root, I am in the root group:
sh-4.2$ stat /dev/tty File: '/dev/tty' Size: 0 Blocks: 0 IO Block: 4096 character special file Device: 100076h/1048694d Inode: 221356338 Links: 1 Device type: 5,0 Access: (0666/crw-rw-rw-) Uid: ( 0/ root) Gid: ( 0/ root) Access: 2018-05-17 14:08:51.809798450 +0100 Modify: 2018-05-17 14:08:51.809798450 +0100 Change: 2018-05-17 14:08:51.809798450 +0100 Birth: - sh-4.2$ id -g 0 sh-4.2$
So this doesn't seem to be the issue. Unfortunately I can't test if it works as root, as I don't have root access on this machine (although I can request for commands to be run as root when the machine starts up, but not to run daemons etc).
As it says the operation was cancelled by user (which is simply untrue), I have no idea how to debug this.
If I don't have root access, can this issue be fixed? Is it simply not possible to use GPG without root access?