NETPGP(1) | General Commands Manual | NETPGP(1) |
netpgp | --encrypt [--output=filename] [options] file ... |
netpgp | --decrypt [--output=filename] [--pass-fd=fd] [--num-tries=attempts] [options] file ... |
netpgp | --sign [--armor] [--detach] [--hash=algorithm] [--output=filename] [--pass-fd=fd] [--from=sig-valid-from] [--num-tries=attempts] [--duration=sig-valid-duration] [options] file ... |
netpgp | --verify [options] file ... |
netpgp | --cat [--output=filename] [options] file ... |
netpgp | --clearsign [--output=filename] [--pass-fd=fd] [options] file ... |
netpgp | --list-packets [--pass-fd=fd] file ... |
netpgp | --version |
netpgp | [-Vdesv] [-olong-option=value] file ... |
where the long options for all commands are:
[--cipher=ciphername]
For signing and encryption, a unique identity is needed. This identity is made up of a private and public key. The public key part is made available and known to everyone. The private key is kept secret, and known only to the user who created the identity. The secret key is protected with a passphrase.
In rough terms, a digital signature is a digest of a file's contents, encrypted with the user's private key. Since together, the private and public keys identify the user uniquely, the signature can be used to identify the exact version of the file, and any changes made to the file will mean that the signature no longer matches.
As a corollary, the file can be transformed using a user's public key, into text such that the contents can only be viewed by someone with the corresponding private key. This is called encryption.
To manipulate keys themselves, a separate utility is provided, called netpgpkeys(1).
Keyrings are collections of public keys belonging to other users. By using other means of identification, it is possible to establish the bona fides of other users. Once trust has been established, the public key of the other user will be signed. The other user's public key can be added to our keyring. The other user will add our public key to their keyring.
Keys can be listed, exported (i.e. made available to others), and imported (i.e. users who have signed our public key).
The --list-packets command can be used for debugging purposes.
The following commands are used to sign and verify signatures:
The following commands can be used to encrypt and decrypt files:
In addition to one of the preceding commands, a number of qualifiers or options may be given.
getpass(3) will be used to obtain the pass phrase from the user if it is needed, such as during signing or encryption, or key generation, so that any secret information cannot be viewed by other users using the ps(1) or top(1) commands, or by looking over the shoulder at the screen.
Since the public and private key pair can be used to verify a person's identity, and since identity theft can have far-reaching consequences, users are strongly encouraged to enter their pass phrases only when prompted by the application.
% netpgp --sign --userid=agc@netbsd.org a pub 2048/RSA (Encrypt or Sign) 1b68dcfcc0596823 2004-01-12 Key fingerprint: d415 9deb 336d e4cc cdfa 00cd 1b68 dcfc c059 6823 uid Alistair Crooks <agc@netbsd.org> uid Alistair Crooks <agc@pkgsrc.org> uid Alistair Crooks <agc@alistaircrooks.com> uid Alistair Crooks <alistair@hockley-crooks.com> netpgp passphrase: % netpgp --verify a.gpg Good signature for a.gpg made Thu Jan 29 03:06:00 2009 using RSA (Encrypt or Sign) key 1B68DCFCC0596823 pub 2048/RSA (Encrypt or Sign) 1b68dcfcc0596823 2004-01-12 Key fingerprint: d415 9deb 336d e4cc cdfa 00cd 1b68 dcfc c059 6823 uid Alistair Crooks <alistair@hockley-crooks.com> uid Alistair Crooks <agc@pkgsrc.org> uid Alistair Crooks <agc@netbsd.org> uid Alistair Crooks <agc@alistaircrooks.com> %
In the example above, a signature is made on a single file called “a” using a user identity corresponding to “agc@netbsd.org” The key located for the user identity is displayed, and the user is prompted to type in their passphrase. The resulting file, called “a.gpg” is placed in the same directory. The second part of the example shows a verification of the signed file taking place. The time and user identity of the signatory is displayed, followed by a fuller description of the public key of the signatory. In both cases, the exit value from the utility was a successful one.
If a detached signature of a file called “a” is requested, the signature would be placed in a file called “a.sig”.
To encrypt a file, the user's public key is used. Subsequent decryption of the file requires that the secret key is known. When decrypting, the key is displayed, and the passphrase protecting the secret key must be typed in to access the data in the encrypted file.
% netpgp --encrypt --userid=c0596823 a % netpgp --decrypt a.gpg pub 2048/RSA (Encrypt or Sign) 1b68dcfcc0596823 2004-01-12 Key fingerprint: d415 9deb 336d e4cc cdfa 00cd 1b68 dcfc c059 6823 uid Alistair Crooks <agc@netbsd.org> uid Alistair Crooks <agc@pkgsrc.org> uid Alistair Crooks <agc@alistaircrooks.com> uid Alistair Crooks <alistair@hockley-crooks.com> netpgp passphrase: %
If no file name is provided, the data will be read from standard input, and displayed on standard output:
% netpgp --encrypt < a | netpgp --decrypt > b netpgp: default key set to "C0596823" netpgp: default key set to "C0596823" pub 2048/RSA (Encrypt or Sign) 1b68dcfcc0596823 2004-01-12 Key fingerprint: d415 9deb 336d e4cc cdfa 00cd 1b68 dcfc c059 6823 uid Alistair Crooks <agc@netbsd.org> uid Alistair Crooks <agc@pkgsrc.org> uid Alistair Crooks <agc@alistaircrooks.com> uid Alistair Crooks <alistair@hockley-crooks.com> netpgp passphrase: %
This simple (and contrived) example shows that netpgp commands can be used together in a pipeline to produce the desired effect.
% netpgp --sign < a | netpgp --cat > b netpgp: default key set to "C0596823" netpgp: default key set to "C0596823" pub 2048/RSA (Encrypt or Sign) 1b68dcfcc0596823 2004-01-12 Key fingerprint: d415 9deb 336d e4cc cdfa 00cd 1b68 dcfc c059 6823 uid Alistair Crooks <agc@netbsd.org> uid Alistair Crooks <agc@pkgsrc.org> uid Alistair Crooks <agc@alistaircrooks.com> uid Alistair Crooks <alistair@hockley-crooks.com> netpgp passphrase: Good signature for <stdin> made Mon Dec 21 18:25:02 2009 using RSA (Encrypt or Sign) key 1b68dcfcc0596823 pub 2048/RSA (Encrypt or Sign) 1b68dcfcc0596823 2004-01-12 Key fingerprint: d415 9deb 336d e4cc cdfa 00cd 1b68 dcfc c059 6823 uid Alistair Crooks <alistair@hockley-crooks.com> uid Alistair Crooks <agc@pkgsrc.org> uid Alistair Crooks <agc@netbsd.org> uid Alistair Crooks <agc@alistaircrooks.com> uid Alistair Crooks (Yahoo!) <agcrooks@yahoo-inc.com> %
For operations like signing and encrypting a file at the same time, the best way is to make use of pipelines:
% netpgp --sign < example | netpgp --encrypt --userid=c0596823 > example.gpg netpgp: default key set to "C0596823" pub 2048/RSA (Encrypt or Sign) 1b68dcfcc0596823 2004-01-12 Key fingerprint: d415 9deb 336d e4cc cdfa 00cd 1b68 dcfc c059 6823 uid Alistair Crooks <alistair@hockley-crooks.com> uid Alistair Crooks <agc@pkgsrc.org> uid Alistair Crooks <agc@netbsd.org> uid Alistair Crooks <agc@alistaircrooks.com> uid Alistair Crooks (Yahoo!) <agcrooks@yahoo-inc.com> netpgp passphrase: % netpgp --decrypt < example.gpg | netpgp --cat netpgp: default key set to "C0596823" netpgp: default key set to "C0596823" pub 2048/RSA (Encrypt or Sign) 1b68dcfcc0596823 2004-01-12 Key fingerprint: d415 9deb 336d e4cc cdfa 00cd 1b68 dcfc c059 6823 uid Alistair Crooks <alistair@hockley-crooks.com> uid Alistair Crooks <agc@pkgsrc.org> uid Alistair Crooks <agc@netbsd.org> uid Alistair Crooks <agc@alistaircrooks.com> uid Alistair Crooks (Yahoo!) <agcrooks@yahoo-inc.com> netpgp passphrase: Good signature for <stdin> made Mon Feb 22 07:21:19 2010 using RSA (Encrypt or Sign) key 1b68dcfcc0596823 pub 2048/RSA (Encrypt or Sign) 1b68dcfcc0596823 2004-01-12 Key fingerprint: d415 9deb 336d e4cc cdfa 00cd 1b68 dcfc c059 6823 uid Alistair Crooks <alistair@hockley-crooks.com> uid Alistair Crooks <agc@pkgsrc.org> uid Alistair Crooks <agc@netbsd.org> uid Alistair Crooks <agc@alistaircrooks.com> uid Alistair Crooks (Yahoo!) <agcrooks@yahoo-inc.com> ...contents of original file... %
November 28, 2010 | NetBSD 6.1 |