Unable to encrypt file with private/public key

Duplicity Mailing List duplicitymailinglist at mail.ru
Wed Dec 17 18:32:39 CET 2014


On 17/12/14 14:43, Haritwal, Dhiraj wrote:
> Hi,
> 
>  
> 
> I am using gpg (GnuPG) 1.4.7 & trying to encrypt a file with private key
> whose public key I have shared to the partner who have to decrypt this
> file. I tried with --armour –symmetric switches which requires a
> passphrase to encrypt but I have requirement to encrypt it through
> private/public key. If I am using –encrypt --hidden-recipient option
> showing below error. I am able to see the public key while running
> –list-keys option. I am running it on AIX 6.1 under root user.

If you just wish to encrypt, not sign, to the user, use:-

>gpg2 --recipient AABBCCDD --encrypt supersecret.txt

Or the shorter version:-
>gpg2 -r AABBCCDD -e supersecret.txt

It will dump supersecret.txt.gpg, that's your encrypted file. This isn't
signed (I.E. the receiver won't be able to verify _you_ sent it, and can
be replaced (Although not read) in transit). If you wish to sign it,
you'll also need a GPG key in your keyring, then run:-

>gpg2 --local-user FFEEDDCC --recipient AABBCCDD --encrypt --sign
supersecret.txt

Or the shorter version:-
>gpg2 -u FFEEDDCC -r AABBCCDD -se supersecret.txt

Where FFEEDDCC is your key identifier and AABBCCDD is the recipient's
key identifier. When they decrypt the file, they will see something
along the lines of:-
>gpg: Good signature from "John Doe (JohnDoe at Example.com) [ultimate]"
>gpg: binary signature, digest algorithm SHA512
>gpg: decryption okay

the command you're using, --symmetric, is for using a passphrase for
encryption/decrypt (I.E. symmetric encryption, not asymmetric).
--hidden-recipient should work too, and is used if you don't wish to
include information about the recipient in the gpg file, you probably
don't want to use this option (As oppose to --recipient) unless you
really do wish to use the features it provides.

As for the failed public key, may I ask the exact command you're
running? I get the same error message when I specify a recipient that
doesn't exist:-

>$ gpg2 -e -r ${RANDOM} b
>gpg: 31546: skipped: No public key
>gpg: b: encryption failed: No public key



More information about the Gnupg-users mailing list