gpg: cancelled by user

While signing a release tar.gz with gpg key, I got into this weird issue. After digging the internet I finally got the solution. Here is the error that I got and below is the solution to this issue. 

[user@host tar]$ gpg --armor --output something.tar.gz.asc --detach-sig something-.tar.gz

You need a passphrase to unlock the secret key for
user: "user (somthing) "
4096-bit RSA key, ID 654321, created 2012-06-22

can't connect to `/home/user/.gnupg/S.gpg-agent': No such file or directory
gpg-agent[7582]: command get_passphrase failed: Operation cancelled
gpg: cancelled by user
gpg: no default secret key: General error
gpg: signing failed: General error


Initially I thought I didn't start the gpg-agent


[user@host tar]$      eval $(gpg-agent --daemon)

I started the gpg-agent with the above eval

[user@host tar]$ gpg --armor --output something.tar.gz.asc --detach-sig something-.tar.gz

You need a passphrase to unlock the secret key for
user: "user (somthing) "
4096-bit RSA key, ID 654321, created 2012-06-22

can't connect to `/home/user/.gnupg/S.gpg-agent': No such file or directory
gpg-agent[7582]: command get_passphrase failed: Operation cancelled
gpg: cancelled by user
gpg: no default secret key: General error
gpg: signing failed: General error

Finally after allowing other's to r+w on tty seem to solve this issue

[root@host ~]# chmod o+rw $(tty)

Comments

Krishna Kakatur said…
I had the same issue and I resolved it by running gpg command from a putty session when connected directly as the user running the command.

For some reason, gpg "sign" command fails if you use "su" to switch the user.
Unknown said…
I am getting below errors.
gpg: cancelled by user
decryption failed: No secret key
Exception in component tFileInputFullRow_1

I tried chmod o+rw $(tty)

It is asking passphrase.we are running cron jobs for gpg decryption.we can not give passphrase every time.
Please provide any solution to this.

Popular posts from this blog

How to find the source branch of a branch in git

yarn nodemanager doesn't start - Caused by: EPERM: Operation not permitted