I use gpg on ubuntu and I have two keyrings I want to decrypt a message with my second private key but gpg uses the first key for decryption. How I specify private key for decryption? Thanks!
You should be able to use
--keyring <file> and
From the gpg man page:
--keyring file Add file to the current list of keyrings. If file begins with a tilde and a slash, these are replaced by the $HOME directory. If the filename does not contain a slash, it is assumed to be in the GnuPG home directory ("~/.gnupg" if --homedir or $GNUPGHOME is not used). Note that this adds a keyring to the current list. If the intent is to use the specified keyring alone, use --keyring along with --no-default-keyring.
It does seem odd this would be necessary. Perhaps the encrypted file does not specify the recipient properly or at all?
If it is anonymous you might need to use