SlideShare une entreprise Scribd logo
1  sur  7
Télécharger pour lire hors ligne
Basics of GnuPG (GPG) command in Linux

What is GPG ?
Gnu Privacy Guard or GnuPG or popularly known as GPG is a GPL Licensed alternative to PGP (Pretty
Good Privacy) and its openPGP complaint program for *nix people based on rfc 4880. It is part of GNU
software project started in 1991 by Werner Koch and majorly funded by German Government.
Its basic use is to send encrypted mails or files to the recipient who can decrypt these using its private
key. It is based on public and private key mechanism for encryption/decryption. We can encrypt any of
our data using our own key pair and send it to the person who can read the message if he has the
proper key to decrypt it! Many people use public key generated by gpg to verify his email signature too!
It uses following algorithm for various purposes used for safe message communication:
Pubkey: RSA, RSA-E, RSA-S, ELG-E, DSA
Cipher: 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH
Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2

Why GPG?






Because it is free and meant to be a replacement of PGP.
Gpg is a CLI program but there are many GUI also through which you can manage keys easily like
seahorse for GNOME (yum install seahorse) and KGpg for KDE.
It allows you to encrypt and sign your data, includes a key management system as well as access
modules for all kind of public key directories.
If you wish to encrypt your message while sending mail to someone important, you may try this
method.
You can share your public key and other users can download it to verify signature in mails/files
sent by you for authenticity. It would stop social engineering through email even would stop
spams send in the name of your friend’s id.

Applications of GPG







GPG encryption has been added to graphical email client like Evolution for email security.
There is a GNOME front-end application for managing PGP and SSH keys called “Seahorse”
which integrates with Nautilus, gedit and Evolution too for encryption, decryption etc.
PHP based email framework “horde” uses it too!
Enigmail is a data encryption/decryption extension for Mozilla Thunderbird and the SeaMonkey
which uses GPG
Mozilla Firefox also gets GPG enabled using Enigform.
GnuPG is being used for Windows Explorer and Outlook through GPG4win tool which are
wrapped in the standard Windows installer to make GnuPG easier to get installed and to be
used in Windows systems.

http://www.aliencoders.com/

Page 1
Basics of GnuPG (GPG) command in Linux


There are many frontend softwares that support GPG.

How GPG works
It uses hybrid encryption techniques i.e. it uses a combination of symmetric key cryptography for speed
and public-key cryptography for easy secured key exchange. By default GnuPG uses the CAST5
symmetrical algorithm.
As a matter of fact, GnuPG does not use patented or otherwise restricted software or algorithms.
Instead, GnuPG uses a variety of other, non-patented algorithms.
It will be clearer that how GnuPG works once we see the working of gpg commands step by step:
 Which version of gpg we are going to use?
 gpg command to generate keys
 Analysis of freshly created directory (.gnupg) and files inside it.
 Once you get public and private key. You must keep private key safe, once you forget it then you
will never be able to decrypt the data. So, better take private key backup.
 Want to see the list of public and private keys?
 Encrypt the message for specific recipient
 Decrypt the encrypted message

GPG commands explained
Which version of gpg we are going to use?
[sjaiswal@AlienCoders ~]$ gpg --version
gpg (GnuPG) 1.4.5
Copyright (C) 2006 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.
Home: ~/.gnupg
Supported algorithms:
Pubkey: RSA, RSA-E, RSA-S, ELG-E, DSA
Cipher: 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH
Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2
[sjaiswal@AlienCoders ~]$

gpg command to generate keys
[sjaiswal@AlienCoders ~/gpg_test]$ gpg --gen-key
gpg (GnuPG) 1.4.5; Copyright (C) 2006 Free Software Foundation, Inc.
This program comes with ABSOLUTELY NO WARRANTY.
This is free software, and you are welcome to redistribute it
under certain conditions. See the file COPYING for details.
http://www.aliencoders.com/

Page 2
Basics of GnuPG (GPG) command in Linux
Please select what kind of key you want:
(1) DSA and Elgamal (default)
(2) DSA (sign only)
(5) RSA (sign only)
Your selection? 1
DSA keypair will have 1024 bits.
ELG-E keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 4094
Requested keysize is 4094 bits
rounded up to 4096 bits
Please specify how long the key should be valid.
0 = key does not expire
<n> = key expires in n days
<n>w = key expires in n weeks
<n>m = key expires in n months
<n>y = key expires in n years
Key is valid for? (0) 3m
Key expires at Mon 03 Feb 2014 04:46:09 AM MST
Is this correct? (y/N) y
You need a user ID to identify your key; the software constructs the user ID
from the Real Name, Comment and Email Address in this form:
"Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>"
Real name: Sanjeev Jaiswal
Email address: sjaiswal@gmail.com
Comment: "GPG Key Test"
You selected this USER-ID:
"Sanjeev Jaiswal ("GPG Key Test") <sjaiswal@gmail.com>"
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O
You need a Passphrase to protect your secret key.
We need to generate a lot of random bytes. It is a good idea to perform
some other action (type on the keyboard, move the mouse, utilize the
disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
.++++++++++.+++++++++++++++..+++++..++++++++++++++++++++.+++++++++++++++++++++++++.
+gpg: /home/sjaiswal/.gnupg/trustdb.gpg: trustdb created
gpg: key CBE9BE42 marked as ultimately trusted
public and secret key created and signed.
gpg: checking the trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u
gpg: next trustdb check due at 2014-02-03
http://www.aliencoders.com/

Page 3
Basics of GnuPG (GPG) command in Linux
pub 1024D/CBE9BE42 2013-11-05 [expires: 2014-02-03]
Key fingerprint = 40B3 E709 81DA 43AF 1F64 117B DF03 A4AD CBE9 BE42
uid
Sanjeev Jaiswal ("GPG Key Test") <sjaiswal@gmail.com>
sub 4096g/38765DB9 2013-11-05 [expires: 2014-02-03]

Note:
 To generate keys using gpg, it would ask which kind of key you wish to use; you can choose any
of the given option. Type 1 or 2 or 5.
 Type the keysize between the given range
 Then provide the expiration date of key. You can use days,weeks, months, years.
 Once you are done with expiration days, use the next option carefully. Type Real name, Email
and comment appropriately as it will be used while encrypting the data and will ask the
recipient name. it will match recipient name before matching the keys.
 Then type anything using keyboard, do mouse activities etc to speed up random generation of
keys else it may take lot of time.
 Once it will get created, .gnupg directory under your home directory will be there. Use ls to see
what all files got created.
Analysis of freshly created directory (.gnupg) and files inside it
$ ls .gnupg/
gpg.conf pubring.gpg pubring.gpg~ random_seed secring.gpg trustdb.gpg








gpg.conf -> it contains all options set by you. Unless you specify which option file to use (with
the command line option "--options filename"), GnuPG uses the file ~/.gnupg/gpg.conf by
default. Check strings gpg.conf for more details.
pubring.gpg -> public key stored here. You should export it in ASCII format to send it to others.
pubring.gpg~ -> backup of public key
random_seed -> it contains all random keys used for encryption that you might be typing while
generating keys.
[Sanjeev@AlienCoders]$ strings random_seed
u-~N
bqUk
9a<b
vxyv
H@W@
02H]
KC!%
^v9@'
,i~JZ8Y
T_3 P>
secring.gpg -> it’s the secret key ring and one should keep it safe. Better have its backup
trustdb.gpg -> its trusted db which contains signatures, expiration date etc. and from time to
time the trust database must be updated so that expired keys or signatures and the resulting
changes in the Web of Trust can be tracked.

http://www.aliencoders.com/

Page 4
Basics of GnuPG (GPG) command in Linux
Normally, GnuPG will calculate when this is required and do it automatically.

Getting fingerprint and KeyID
[sjaiswal@AlienCoders ~/.gnupg]$ gpg --fingerprint sjaiswal@gmail.com
pub 1024D/CBE9BE42 2013-11-05 [expires: 2014-02-03]
Key fingerprint = 40B3 E709 81DA 43AF 1F64 117B DF03 A4AD CBE9 BE42
uid
Sanjeev Jaiswal ("GPG Key Test") <sjaiswal@gmail.com>
sub 4096g/38765DB9 2013-11-05 [expires: 2014-02-03]

Note: KeyID here is: 0xCBE9BE42 (always prepend 0x as it is 8 hex digits)
Taking backup of private key
gpg --export-secret-keys --armor sjaiswal@gmail.com > sjaiswal-privkey.asc

Listing public and private key(s)
[sjaiswal@AlienCoders ~/.gnupg]$ gpg --list-keys
/home/sjaiswal/.gnupg/pubring.gpg
--------------------------------pub 1024D/CBE9BE42 2013-11-05 [expires: 2014-02-03]
uid
Sanjeev Jaiswal ("GPG Key Test") <sjaiswal@gmail.com>
sub 4096g/38765DB9 2013-11-05 [expires: 2014-02-03]
[sjaiswal@AlienCoders ~/.gnupg]$ gpg --list-secret-keys
/home/sjaiswal/.gnupg/secring.gpg
--------------------------------sec 1024D/CBE9BE42 2013-11-05 [expires: 2014-02-03]
uid
Sanjeev Jaiswal ("GPG Key Test") <sjaiswal@gmail.com>
ssb 4096g/38765DB9 2013-11-05

Encrypting Message for recipient Sanjeev Jaiswal
Type the message and save it in text file, let’s say message.txt
[sjaiswal@AlienCoders ~/.gnupg]$gpg recipient Sanjeev Jaiswal --encrypt message.txt

It will create message.txt.gpg , which is an encrypted file. To decrypt it, you need to type passphrase
that you had typed while generating keys.
Or
gpg -r real-name --out secrets_to_aliencoders --encrypt secrets

which will have encrypted message in secrets_to_aliencoders
http://www.aliencoders.com/

Page 5
Basics of GnuPG (GPG) command in Linux
Decrypting the message
[sjaiswal@AlienCoders ~/.gnupg]$ gpg --decrypt message.txt.gpg

You need a passphrase to unlock the secret key for
user: "Sanjeev Jaiswal ("GPG Key Test") <sjaiswal@gmail.com>"
4096-bit ELG-E key, ID 38765DB9, created 2013-11-05 (main key ID CBE9BE42)
gpg: encrypted with 4096-bit ELG-E key, ID 38765DB9, created 2013-11-05
"Sanjeev Jaiswal ("GPG Key Test") <sjaiswal@gmail.com>"
Hi
This is Sabnjeev
Or
[sjaiswal@AlienCoders ~/.gnupg]$ gpg --output secrets_from_tom --decrypt secrets_to_aliencoders

Which would save the decrypted message in secrets_from_sanjeev
Editing Key
gpg --edit-key sjaiswal@gmail.com
There is more:
Photo IDs
GnuPG has the ability to add a photo ID to a public key, exactly as in recent Windows versions of PGP. A
photo ID attached to a public key can help other users to identify the owner of the key. To add a photo
ID to your own public key, use the command "gpg --edit-key <name>" and then enter "addphoto".
GnuPG will ask for the filename of a suitable JPEG. No other types of image files can be used.
If you want to see a photo ID on a particular key, enter the command "--show-photos" before using the
command "gpg --list-keys <name>". If <name> is omitted, GnuPG will display all the photos (if any) after
listing all the keys in your public keyring. Alternatively, if you want photos to be displayed in all cases by
default, you should uncomment the line "# show-photos" in the options file inside !GnuPGUser.
Output of trustdb
[Sanjeev@AlienCoders]$ gpg --update-trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0 valid: 1 signed: 7 trust: 0-, 0q, 0n, 0m, 0f, 1u
gpg: depth: 1 valid: 7 signed: 3 trust: 0-, 0q, 4n, 3m, 0f, 0u
gpg: the next trustdb check will be done on 2014-02-04

http://www.aliencoders.com/

Page 6
Basics of GnuPG (GPG) command in Linux
The first line shows you the actual trust policy used by your GnuPG installation, and which you can
modify at your needs. It states that a key in your keyring is valid if it has been signed by at least 3
marginally trusted keys, or by at least one fully trusted key.
The second line describes the key of level 0, that is the key owned by you. It states that in your keyring
you have one level zero key, which is signed by 7 keys. Furthermore among all the level zero keys, you
have 0 of them for which you haven't yet evaluated the trust level. 0 of them are the keys for which you
have no idea of which validity level to assign (q="I don't know or won't say"). You also have 0 keys that
you do not trust at all (n="I do NOT trust"), 0 marginally trusted keys (m="I trust marginally"), 0 fully
trusted keys (f="I trust fully") and 1 ultimately trusted keys (u="I trust ultimately").
The third line analyzes the keys of level 1 in your keyring. You have 7 fully valid keys, because you have
personally signed them. Furthermore, among the keys that are stored in your keyring, you have 3 of
them that are not signed directly by you, but are at least signed by one of the fully valid keys. The trust
status counters have the same meaning of the ones in the second line. This time you have 4 keys signed
by you but for which you do not trust at all the owner as signer of third party's keys. On the other side, 3
of the 7 keys that you have signed are marginally trusted. This means that you are only marginally
confident that the owners of those keys can verify well the keys that they sign.
[Sanjeev@AlienCoders]$ gpg --check-trustdb
gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model
gpg: depth: 0 valid: 1 signed: 7 trust: 0-, 0q, 0n, 0m, 0f, 1u
gpg: next trustdb check due at 2014-02-04

Source: http://www.wikipedia.com
Reference: GnuPG Handbook

Author: Sanjeev Jaiswal
Facebook: https://www.facebook.com/aliencoders
G+: https://plus.google.com/+Aliencoders
Twitter: https://twitter.com/aliencoders
Pinterest: http://www.pinterest.com/aliencoders/
LinkedIn: http://www.linkedin.com/groups/Alien-Coders-4642371
Slideshare: http://www.slideshare.net/jassics

http://www.aliencoders.com/

Page 7

Contenu connexe

Tendances

Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...
Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...
Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...OpenDNS
 
Class Project Showcase: DNS Spoofing
Class Project Showcase: DNS SpoofingClass Project Showcase: DNS Spoofing
Class Project Showcase: DNS SpoofingBeibei Yang
 
2019 JJUG CCC Stateless Microservice Security with MicroProfile JWT
2019 JJUG CCC Stateless Microservice Security with MicroProfile JWT2019 JJUG CCC Stateless Microservice Security with MicroProfile JWT
2019 JJUG CCC Stateless Microservice Security with MicroProfile JWTDavid Blevins
 
Encryption Boot Camp at JavaZone 2010
Encryption Boot Camp at JavaZone 2010Encryption Boot Camp at JavaZone 2010
Encryption Boot Camp at JavaZone 2010Matthew McCullough
 
End-to-End Analysis of a Domain Generating Algorithm Malware Family
End-to-End Analysis of a Domain Generating Algorithm Malware FamilyEnd-to-End Analysis of a Domain Generating Algorithm Malware Family
End-to-End Analysis of a Domain Generating Algorithm Malware FamilyCrowdStrike
 
SSL/TLS for Mortals (JavaZone)
SSL/TLS for Mortals (JavaZone)SSL/TLS for Mortals (JavaZone)
SSL/TLS for Mortals (JavaZone)Maarten Mulders
 
Celebrity Cricket League 2016 - http://ccl5.com/
Celebrity Cricket League 2016 - http://ccl5.com/ Celebrity Cricket League 2016 - http://ccl5.com/
Celebrity Cricket League 2016 - http://ccl5.com/ Tania Agni
 
Hands-on getdns Tutorial
Hands-on getdns TutorialHands-on getdns Tutorial
Hands-on getdns TutorialShumon Huque
 
Improving password-based authentication
Improving password-based authenticationImproving password-based authentication
Improving password-based authenticationFrank Denis
 
2017 Devoxx MA Deconstructing and Evolving REST Security
2017 Devoxx MA Deconstructing and Evolving REST Security2017 Devoxx MA Deconstructing and Evolving REST Security
2017 Devoxx MA Deconstructing and Evolving REST SecurityDavid Blevins
 
Pgp pretty good privacy
Pgp pretty good privacyPgp pretty good privacy
Pgp pretty good privacyPawan Arya
 
Infrastructure Tracking with Passive Monitoring and Active Probing: ShmooCon ...
Infrastructure Tracking with Passive Monitoring and Active Probing: ShmooCon ...Infrastructure Tracking with Passive Monitoring and Active Probing: ShmooCon ...
Infrastructure Tracking with Passive Monitoring and Active Probing: ShmooCon ...OpenDNS
 
Ricardo de Oliveria Schmidt - DDoS Attacks on the Root DNS
Ricardo de Oliveria Schmidt - DDoS Attacks on the Root DNSRicardo de Oliveria Schmidt - DDoS Attacks on the Root DNS
Ricardo de Oliveria Schmidt - DDoS Attacks on the Root DNSMichiel Cazemier
 

Tendances (20)

Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...
Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...
Using Algorithms to Brute Force Algorithms...A Journey Through Time and Names...
 
Class Project Showcase: DNS Spoofing
Class Project Showcase: DNS SpoofingClass Project Showcase: DNS Spoofing
Class Project Showcase: DNS Spoofing
 
Breaking DES
Breaking DESBreaking DES
Breaking DES
 
Pgp
PgpPgp
Pgp
 
2019 JJUG CCC Stateless Microservice Security with MicroProfile JWT
2019 JJUG CCC Stateless Microservice Security with MicroProfile JWT2019 JJUG CCC Stateless Microservice Security with MicroProfile JWT
2019 JJUG CCC Stateless Microservice Security with MicroProfile JWT
 
Pgp
PgpPgp
Pgp
 
Encryption Boot Camp at JavaZone 2010
Encryption Boot Camp at JavaZone 2010Encryption Boot Camp at JavaZone 2010
Encryption Boot Camp at JavaZone 2010
 
End-to-End Analysis of a Domain Generating Algorithm Malware Family
End-to-End Analysis of a Domain Generating Algorithm Malware FamilyEnd-to-End Analysis of a Domain Generating Algorithm Malware Family
End-to-End Analysis of a Domain Generating Algorithm Malware Family
 
SSL/TLS for Mortals (JavaZone)
SSL/TLS for Mortals (JavaZone)SSL/TLS for Mortals (JavaZone)
SSL/TLS for Mortals (JavaZone)
 
Celebrity Cricket League 2016 - http://ccl5.com/
Celebrity Cricket League 2016 - http://ccl5.com/ Celebrity Cricket League 2016 - http://ccl5.com/
Celebrity Cricket League 2016 - http://ccl5.com/
 
Hands-on getdns Tutorial
Hands-on getdns TutorialHands-on getdns Tutorial
Hands-on getdns Tutorial
 
Bitcoin
BitcoinBitcoin
Bitcoin
 
Interpolique
InterpoliqueInterpolique
Interpolique
 
Improving password-based authentication
Improving password-based authenticationImproving password-based authentication
Improving password-based authentication
 
Email Security
Email SecurityEmail Security
Email Security
 
Aoevideo
AoevideoAoevideo
Aoevideo
 
2017 Devoxx MA Deconstructing and Evolving REST Security
2017 Devoxx MA Deconstructing and Evolving REST Security2017 Devoxx MA Deconstructing and Evolving REST Security
2017 Devoxx MA Deconstructing and Evolving REST Security
 
Pgp pretty good privacy
Pgp pretty good privacyPgp pretty good privacy
Pgp pretty good privacy
 
Infrastructure Tracking with Passive Monitoring and Active Probing: ShmooCon ...
Infrastructure Tracking with Passive Monitoring and Active Probing: ShmooCon ...Infrastructure Tracking with Passive Monitoring and Active Probing: ShmooCon ...
Infrastructure Tracking with Passive Monitoring and Active Probing: ShmooCon ...
 
Ricardo de Oliveria Schmidt - DDoS Attacks on the Root DNS
Ricardo de Oliveria Schmidt - DDoS Attacks on the Root DNSRicardo de Oliveria Schmidt - DDoS Attacks on the Root DNS
Ricardo de Oliveria Schmidt - DDoS Attacks on the Root DNS
 

En vedette

Mdupiriak 30boxes
Mdupiriak 30boxesMdupiriak 30boxes
Mdupiriak 30boxesdboling
 
How researchers use of Social Media & Scholarly Collaboration Networks
How researchers use of Social Media & Scholarly Collaboration NetworksHow researchers use of Social Media & Scholarly Collaboration Networks
How researchers use of Social Media & Scholarly Collaboration NetworksKeita Bando
 
VietRees_Newsletter_47_Tuan1_Thang09
VietRees_Newsletter_47_Tuan1_Thang09VietRees_Newsletter_47_Tuan1_Thang09
VietRees_Newsletter_47_Tuan1_Thang09internationalvr
 
VietRees_Newsletter_42_Tuan1_Thang08
VietRees_Newsletter_42_Tuan1_Thang08VietRees_Newsletter_42_Tuan1_Thang08
VietRees_Newsletter_42_Tuan1_Thang08internationalvr
 
Vistas exteriores
Vistas exterioresVistas exteriores
Vistas exterioresademonte
 
Om Max Power Of Having A Spritual Friend 1
Om Max   Power Of Having A Spritual Friend 1Om Max   Power Of Having A Spritual Friend 1
Om Max Power Of Having A Spritual Friend 1Bryan Sumendap
 
8. Social 2.0 Would U Like To Add Me Rudi Leung
8. Social 2.0    Would U Like To Add Me   Rudi Leung8. Social 2.0    Would U Like To Add Me   Rudi Leung
8. Social 2.0 Would U Like To Add Me Rudi LeungHKAIM
 
VietRees_Newsletter_60_Tuan1_Thang12
VietRees_Newsletter_60_Tuan1_Thang12VietRees_Newsletter_60_Tuan1_Thang12
VietRees_Newsletter_60_Tuan1_Thang12internationalvr
 
Maalem Imen Kairouan02
Maalem Imen Kairouan02Maalem Imen Kairouan02
Maalem Imen Kairouan02guest2c3715
 
Lights camera action orlando - october 2015 -slide upload
Lights camera action   orlando - october 2015 -slide uploadLights camera action   orlando - october 2015 -slide upload
Lights camera action orlando - october 2015 -slide uploadtsmeans
 

En vedette (20)

Mdupiriak 30boxes
Mdupiriak 30boxesMdupiriak 30boxes
Mdupiriak 30boxes
 
How researchers use of Social Media & Scholarly Collaboration Networks
How researchers use of Social Media & Scholarly Collaboration NetworksHow researchers use of Social Media & Scholarly Collaboration Networks
How researchers use of Social Media & Scholarly Collaboration Networks
 
VietRees_Newsletter_47_Tuan1_Thang09
VietRees_Newsletter_47_Tuan1_Thang09VietRees_Newsletter_47_Tuan1_Thang09
VietRees_Newsletter_47_Tuan1_Thang09
 
Wimax vsWi-fi
Wimax vsWi-fiWimax vsWi-fi
Wimax vsWi-fi
 
Morphological Image Processing
Morphological Image ProcessingMorphological Image Processing
Morphological Image Processing
 
Creating New Opportunities Under Obama Health Care Reform
Creating New Opportunities Under Obama  Health Care ReformCreating New Opportunities Under Obama  Health Care Reform
Creating New Opportunities Under Obama Health Care Reform
 
flashcards A1
flashcards A1flashcards A1
flashcards A1
 
VietRees_Newsletter_42_Tuan1_Thang08
VietRees_Newsletter_42_Tuan1_Thang08VietRees_Newsletter_42_Tuan1_Thang08
VietRees_Newsletter_42_Tuan1_Thang08
 
Cryptography&Security
Cryptography&SecurityCryptography&Security
Cryptography&Security
 
How IP address works
How IP address worksHow IP address works
How IP address works
 
Mixbook
MixbookMixbook
Mixbook
 
Real Time Image Processing
Real Time Image Processing Real Time Image Processing
Real Time Image Processing
 
C Questions
C QuestionsC Questions
C Questions
 
Vistas exteriores
Vistas exterioresVistas exteriores
Vistas exteriores
 
Om Max Power Of Having A Spritual Friend 1
Om Max   Power Of Having A Spritual Friend 1Om Max   Power Of Having A Spritual Friend 1
Om Max Power Of Having A Spritual Friend 1
 
Kedos v3
Kedos v3Kedos v3
Kedos v3
 
8. Social 2.0 Would U Like To Add Me Rudi Leung
8. Social 2.0    Would U Like To Add Me   Rudi Leung8. Social 2.0    Would U Like To Add Me   Rudi Leung
8. Social 2.0 Would U Like To Add Me Rudi Leung
 
VietRees_Newsletter_60_Tuan1_Thang12
VietRees_Newsletter_60_Tuan1_Thang12VietRees_Newsletter_60_Tuan1_Thang12
VietRees_Newsletter_60_Tuan1_Thang12
 
Maalem Imen Kairouan02
Maalem Imen Kairouan02Maalem Imen Kairouan02
Maalem Imen Kairouan02
 
Lights camera action orlando - october 2015 -slide upload
Lights camera action   orlando - october 2015 -slide uploadLights camera action   orlando - october 2015 -slide upload
Lights camera action orlando - october 2015 -slide upload
 

Similaire à Basics of GnuPG (gpg) command in linux

OpenPGP/GnuPG Encryption
OpenPGP/GnuPG EncryptionOpenPGP/GnuPG Encryption
OpenPGP/GnuPG EncryptionTanner Lovelace
 
CryptoGraphy Module in Mulesoft
CryptoGraphy Module in MulesoftCryptoGraphy Module in Mulesoft
CryptoGraphy Module in Mulesoftshyamraj55
 
Using pgp with mule
Using pgp with muleUsing pgp with mule
Using pgp with muleAnil Kumar V
 
Using pgp with mule
Using pgp with muleUsing pgp with mule
Using pgp with muleAnil Kumar V
 
Mulesoft Meetup Cryptography Module
Mulesoft Meetup Cryptography ModuleMulesoft Meetup Cryptography Module
Mulesoft Meetup Cryptography ModuleManjuKumara GH
 
Secure Mail Application's by Ashok Panwar
Secure Mail Application's by Ashok PanwarSecure Mail Application's by Ashok Panwar
Secure Mail Application's by Ashok PanwarAshok Panwar
 
Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...
Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...
Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...Puppet
 
B. Nouri-Moghaddam et al Int. Journal of Engineering Research .docx
B. Nouri-Moghaddam et al Int. Journal of Engineering Research .docxB. Nouri-Moghaddam et al Int. Journal of Engineering Research .docx
B. Nouri-Moghaddam et al Int. Journal of Engineering Research .docxikirkton
 
Digital Certified Mail
Digital Certified MailDigital Certified Mail
Digital Certified MailMatthew Chang
 
PGP desk top basis lecture 002
PGP desk top basis lecture 002PGP desk top basis lecture 002
PGP desk top basis lecture 002Qaisar Ayub
 
Ahmadabad mule soft_meetup_17april2021_mule4_cryptography
Ahmadabad mule soft_meetup_17april2021_mule4_cryptographyAhmadabad mule soft_meetup_17april2021_mule4_cryptography
Ahmadabad mule soft_meetup_17april2021_mule4_cryptographyShekh Muenuddeen
 
Pgp security mule
Pgp security   mulePgp security   mule
Pgp security muleSindhu VL
 
Encrption in mule
Encrption in muleEncrption in mule
Encrption in muleSindhu VL
 
PGP managing Key Lecture 007
PGP managing Key Lecture 007PGP managing Key Lecture 007
PGP managing Key Lecture 007Qaisar Ayub
 
PGP Encryption And Decryption With Mule ESB
PGP Encryption And Decryption With Mule ESBPGP Encryption And Decryption With Mule ESB
PGP Encryption And Decryption With Mule ESBJitendra Bafna
 
Data-in-Motion, Data-At-Rest and GPG
Data-in-Motion, Data-At-Rest and GPGData-in-Motion, Data-At-Rest and GPG
Data-in-Motion, Data-At-Rest and GPGAnkit Mehta
 
Privacy is a UX problem (David Dahl)
Privacy is a UX problem (David Dahl)Privacy is a UX problem (David Dahl)
Privacy is a UX problem (David Dahl)Future Insights
 
FLISOL 2015 - Criptografia é importante! Aprenda meios simples de proteger ar...
FLISOL 2015 - Criptografia é importante! Aprenda meios simples de proteger ar...FLISOL 2015 - Criptografia é importante! Aprenda meios simples de proteger ar...
FLISOL 2015 - Criptografia é importante! Aprenda meios simples de proteger ar...Paulo Henrique
 

Similaire à Basics of GnuPG (gpg) command in linux (20)

OpenPGP/GnuPG Encryption
OpenPGP/GnuPG EncryptionOpenPGP/GnuPG Encryption
OpenPGP/GnuPG Encryption
 
CryptoGraphy Module in Mulesoft
CryptoGraphy Module in MulesoftCryptoGraphy Module in Mulesoft
CryptoGraphy Module in Mulesoft
 
Crypto hlug
Crypto hlugCrypto hlug
Crypto hlug
 
Using pgp with mule
Using pgp with muleUsing pgp with mule
Using pgp with mule
 
Using pgp with mule
Using pgp with muleUsing pgp with mule
Using pgp with mule
 
Mulesoft Meetup Cryptography Module
Mulesoft Meetup Cryptography ModuleMulesoft Meetup Cryptography Module
Mulesoft Meetup Cryptography Module
 
Secure Mail Application's by Ashok Panwar
Secure Mail Application's by Ashok PanwarSecure Mail Application's by Ashok Panwar
Secure Mail Application's by Ashok Panwar
 
Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...
Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...
Puppet Camp NYC 2014: Safely storing secrets and credentials in Git for use b...
 
B. Nouri-Moghaddam et al Int. Journal of Engineering Research .docx
B. Nouri-Moghaddam et al Int. Journal of Engineering Research .docxB. Nouri-Moghaddam et al Int. Journal of Engineering Research .docx
B. Nouri-Moghaddam et al Int. Journal of Engineering Research .docx
 
Digital Certified Mail
Digital Certified MailDigital Certified Mail
Digital Certified Mail
 
PGP desk top basis lecture 002
PGP desk top basis lecture 002PGP desk top basis lecture 002
PGP desk top basis lecture 002
 
Ahmadabad mule soft_meetup_17april2021_mule4_cryptography
Ahmadabad mule soft_meetup_17april2021_mule4_cryptographyAhmadabad mule soft_meetup_17april2021_mule4_cryptography
Ahmadabad mule soft_meetup_17april2021_mule4_cryptography
 
G43053847
G43053847G43053847
G43053847
 
Pgp security mule
Pgp security   mulePgp security   mule
Pgp security mule
 
Encrption in mule
Encrption in muleEncrption in mule
Encrption in mule
 
PGP managing Key Lecture 007
PGP managing Key Lecture 007PGP managing Key Lecture 007
PGP managing Key Lecture 007
 
PGP Encryption And Decryption With Mule ESB
PGP Encryption And Decryption With Mule ESBPGP Encryption And Decryption With Mule ESB
PGP Encryption And Decryption With Mule ESB
 
Data-in-Motion, Data-At-Rest and GPG
Data-in-Motion, Data-At-Rest and GPGData-in-Motion, Data-At-Rest and GPG
Data-in-Motion, Data-At-Rest and GPG
 
Privacy is a UX problem (David Dahl)
Privacy is a UX problem (David Dahl)Privacy is a UX problem (David Dahl)
Privacy is a UX problem (David Dahl)
 
FLISOL 2015 - Criptografia é importante! Aprenda meios simples de proteger ar...
FLISOL 2015 - Criptografia é importante! Aprenda meios simples de proteger ar...FLISOL 2015 - Criptografia é importante! Aprenda meios simples de proteger ar...
FLISOL 2015 - Criptografia é importante! Aprenda meios simples de proteger ar...
 

Dernier

Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Kaya Weers
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxAna-Maria Mihalceanu
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...BookNet Canada
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Karmanjay Verma
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxLoriGlavin3
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...itnewsafrica
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Farhan Tariq
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfAarwolf Industries LLC
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfIngrid Airi González
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfNeo4j
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integrationmarketing932765
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFMichael Gough
 

Dernier (20)

Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)Design pattern talk by Kaya Weers - 2024 (v2)
Design pattern talk by Kaya Weers - 2024 (v2)
 
A Glance At The Java Performance Toolbox
A Glance At The Java Performance ToolboxA Glance At The Java Performance Toolbox
A Glance At The Java Performance Toolbox
 
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
Transcript: New from BookNet Canada for 2024: BNC SalesData and LibraryData -...
 
Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#Microservices, Docker deploy and Microservices source code in C#
Microservices, Docker deploy and Microservices source code in C#
 
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptxA Deep Dive on Passkeys: FIDO Paris Seminar.pptx
A Deep Dive on Passkeys: FIDO Paris Seminar.pptx
 
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...Zeshan Sattar- Assessing the skill requirements and industry expectations for...
Zeshan Sattar- Assessing the skill requirements and industry expectations for...
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...Genislab builds better products and faster go-to-market with Lean project man...
Genislab builds better products and faster go-to-market with Lean project man...
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Landscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdfLandscape Catalogue 2024 Australia-1.pdf
Landscape Catalogue 2024 Australia-1.pdf
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
Generative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdfGenerative Artificial Intelligence: How generative AI works.pdf
Generative Artificial Intelligence: How generative AI works.pdf
 
Connecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdfConnecting the Dots for Information Discovery.pdf
Connecting the Dots for Information Discovery.pdf
 
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS:  6 Ways to Automate Your Data IntegrationBridging Between CAD & GIS:  6 Ways to Automate Your Data Integration
Bridging Between CAD & GIS: 6 Ways to Automate Your Data Integration
 
All These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDFAll These Sophisticated Attacks, Can We Really Detect Them - PDF
All These Sophisticated Attacks, Can We Really Detect Them - PDF
 

Basics of GnuPG (gpg) command in linux

  • 1. Basics of GnuPG (GPG) command in Linux What is GPG ? Gnu Privacy Guard or GnuPG or popularly known as GPG is a GPL Licensed alternative to PGP (Pretty Good Privacy) and its openPGP complaint program for *nix people based on rfc 4880. It is part of GNU software project started in 1991 by Werner Koch and majorly funded by German Government. Its basic use is to send encrypted mails or files to the recipient who can decrypt these using its private key. It is based on public and private key mechanism for encryption/decryption. We can encrypt any of our data using our own key pair and send it to the person who can read the message if he has the proper key to decrypt it! Many people use public key generated by gpg to verify his email signature too! It uses following algorithm for various purposes used for safe message communication: Pubkey: RSA, RSA-E, RSA-S, ELG-E, DSA Cipher: 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224 Compression: Uncompressed, ZIP, ZLIB, BZIP2 Why GPG?      Because it is free and meant to be a replacement of PGP. Gpg is a CLI program but there are many GUI also through which you can manage keys easily like seahorse for GNOME (yum install seahorse) and KGpg for KDE. It allows you to encrypt and sign your data, includes a key management system as well as access modules for all kind of public key directories. If you wish to encrypt your message while sending mail to someone important, you may try this method. You can share your public key and other users can download it to verify signature in mails/files sent by you for authenticity. It would stop social engineering through email even would stop spams send in the name of your friend’s id. Applications of GPG       GPG encryption has been added to graphical email client like Evolution for email security. There is a GNOME front-end application for managing PGP and SSH keys called “Seahorse” which integrates with Nautilus, gedit and Evolution too for encryption, decryption etc. PHP based email framework “horde” uses it too! Enigmail is a data encryption/decryption extension for Mozilla Thunderbird and the SeaMonkey which uses GPG Mozilla Firefox also gets GPG enabled using Enigform. GnuPG is being used for Windows Explorer and Outlook through GPG4win tool which are wrapped in the standard Windows installer to make GnuPG easier to get installed and to be used in Windows systems. http://www.aliencoders.com/ Page 1
  • 2. Basics of GnuPG (GPG) command in Linux  There are many frontend softwares that support GPG. How GPG works It uses hybrid encryption techniques i.e. it uses a combination of symmetric key cryptography for speed and public-key cryptography for easy secured key exchange. By default GnuPG uses the CAST5 symmetrical algorithm. As a matter of fact, GnuPG does not use patented or otherwise restricted software or algorithms. Instead, GnuPG uses a variety of other, non-patented algorithms. It will be clearer that how GnuPG works once we see the working of gpg commands step by step:  Which version of gpg we are going to use?  gpg command to generate keys  Analysis of freshly created directory (.gnupg) and files inside it.  Once you get public and private key. You must keep private key safe, once you forget it then you will never be able to decrypt the data. So, better take private key backup.  Want to see the list of public and private keys?  Encrypt the message for specific recipient  Decrypt the encrypted message GPG commands explained Which version of gpg we are going to use? [sjaiswal@AlienCoders ~]$ gpg --version gpg (GnuPG) 1.4.5 Copyright (C) 2006 Free Software Foundation, Inc. This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See the file COPYING for details. Home: ~/.gnupg Supported algorithms: Pubkey: RSA, RSA-E, RSA-S, ELG-E, DSA Cipher: 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224 Compression: Uncompressed, ZIP, ZLIB, BZIP2 [sjaiswal@AlienCoders ~]$ gpg command to generate keys [sjaiswal@AlienCoders ~/gpg_test]$ gpg --gen-key gpg (GnuPG) 1.4.5; Copyright (C) 2006 Free Software Foundation, Inc. This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See the file COPYING for details. http://www.aliencoders.com/ Page 2
  • 3. Basics of GnuPG (GPG) command in Linux Please select what kind of key you want: (1) DSA and Elgamal (default) (2) DSA (sign only) (5) RSA (sign only) Your selection? 1 DSA keypair will have 1024 bits. ELG-E keys may be between 1024 and 4096 bits long. What keysize do you want? (2048) 4094 Requested keysize is 4094 bits rounded up to 4096 bits Please specify how long the key should be valid. 0 = key does not expire <n> = key expires in n days <n>w = key expires in n weeks <n>m = key expires in n months <n>y = key expires in n years Key is valid for? (0) 3m Key expires at Mon 03 Feb 2014 04:46:09 AM MST Is this correct? (y/N) y You need a user ID to identify your key; the software constructs the user ID from the Real Name, Comment and Email Address in this form: "Heinrich Heine (Der Dichter) <heinrichh@duesseldorf.de>" Real name: Sanjeev Jaiswal Email address: sjaiswal@gmail.com Comment: "GPG Key Test" You selected this USER-ID: "Sanjeev Jaiswal ("GPG Key Test") <sjaiswal@gmail.com>" Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? O You need a Passphrase to protect your secret key. We need to generate a lot of random bytes. It is a good idea to perform some other action (type on the keyboard, move the mouse, utilize the disks) during the prime generation; this gives the random number generator a better chance to gain enough entropy. .++++++++++.+++++++++++++++..+++++..++++++++++++++++++++.+++++++++++++++++++++++++. +gpg: /home/sjaiswal/.gnupg/trustdb.gpg: trustdb created gpg: key CBE9BE42 marked as ultimately trusted public and secret key created and signed. gpg: checking the trustdb gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model gpg: depth: 0 valid: 1 signed: 0 trust: 0-, 0q, 0n, 0m, 0f, 1u gpg: next trustdb check due at 2014-02-03 http://www.aliencoders.com/ Page 3
  • 4. Basics of GnuPG (GPG) command in Linux pub 1024D/CBE9BE42 2013-11-05 [expires: 2014-02-03] Key fingerprint = 40B3 E709 81DA 43AF 1F64 117B DF03 A4AD CBE9 BE42 uid Sanjeev Jaiswal ("GPG Key Test") <sjaiswal@gmail.com> sub 4096g/38765DB9 2013-11-05 [expires: 2014-02-03] Note:  To generate keys using gpg, it would ask which kind of key you wish to use; you can choose any of the given option. Type 1 or 2 or 5.  Type the keysize between the given range  Then provide the expiration date of key. You can use days,weeks, months, years.  Once you are done with expiration days, use the next option carefully. Type Real name, Email and comment appropriately as it will be used while encrypting the data and will ask the recipient name. it will match recipient name before matching the keys.  Then type anything using keyboard, do mouse activities etc to speed up random generation of keys else it may take lot of time.  Once it will get created, .gnupg directory under your home directory will be there. Use ls to see what all files got created. Analysis of freshly created directory (.gnupg) and files inside it $ ls .gnupg/ gpg.conf pubring.gpg pubring.gpg~ random_seed secring.gpg trustdb.gpg       gpg.conf -> it contains all options set by you. Unless you specify which option file to use (with the command line option "--options filename"), GnuPG uses the file ~/.gnupg/gpg.conf by default. Check strings gpg.conf for more details. pubring.gpg -> public key stored here. You should export it in ASCII format to send it to others. pubring.gpg~ -> backup of public key random_seed -> it contains all random keys used for encryption that you might be typing while generating keys. [Sanjeev@AlienCoders]$ strings random_seed u-~N bqUk 9a<b vxyv H@W@ 02H] KC!% ^v9@' ,i~JZ8Y T_3 P> secring.gpg -> it’s the secret key ring and one should keep it safe. Better have its backup trustdb.gpg -> its trusted db which contains signatures, expiration date etc. and from time to time the trust database must be updated so that expired keys or signatures and the resulting changes in the Web of Trust can be tracked. http://www.aliencoders.com/ Page 4
  • 5. Basics of GnuPG (GPG) command in Linux Normally, GnuPG will calculate when this is required and do it automatically. Getting fingerprint and KeyID [sjaiswal@AlienCoders ~/.gnupg]$ gpg --fingerprint sjaiswal@gmail.com pub 1024D/CBE9BE42 2013-11-05 [expires: 2014-02-03] Key fingerprint = 40B3 E709 81DA 43AF 1F64 117B DF03 A4AD CBE9 BE42 uid Sanjeev Jaiswal ("GPG Key Test") <sjaiswal@gmail.com> sub 4096g/38765DB9 2013-11-05 [expires: 2014-02-03] Note: KeyID here is: 0xCBE9BE42 (always prepend 0x as it is 8 hex digits) Taking backup of private key gpg --export-secret-keys --armor sjaiswal@gmail.com > sjaiswal-privkey.asc Listing public and private key(s) [sjaiswal@AlienCoders ~/.gnupg]$ gpg --list-keys /home/sjaiswal/.gnupg/pubring.gpg --------------------------------pub 1024D/CBE9BE42 2013-11-05 [expires: 2014-02-03] uid Sanjeev Jaiswal ("GPG Key Test") <sjaiswal@gmail.com> sub 4096g/38765DB9 2013-11-05 [expires: 2014-02-03] [sjaiswal@AlienCoders ~/.gnupg]$ gpg --list-secret-keys /home/sjaiswal/.gnupg/secring.gpg --------------------------------sec 1024D/CBE9BE42 2013-11-05 [expires: 2014-02-03] uid Sanjeev Jaiswal ("GPG Key Test") <sjaiswal@gmail.com> ssb 4096g/38765DB9 2013-11-05 Encrypting Message for recipient Sanjeev Jaiswal Type the message and save it in text file, let’s say message.txt [sjaiswal@AlienCoders ~/.gnupg]$gpg recipient Sanjeev Jaiswal --encrypt message.txt It will create message.txt.gpg , which is an encrypted file. To decrypt it, you need to type passphrase that you had typed while generating keys. Or gpg -r real-name --out secrets_to_aliencoders --encrypt secrets which will have encrypted message in secrets_to_aliencoders http://www.aliencoders.com/ Page 5
  • 6. Basics of GnuPG (GPG) command in Linux Decrypting the message [sjaiswal@AlienCoders ~/.gnupg]$ gpg --decrypt message.txt.gpg You need a passphrase to unlock the secret key for user: "Sanjeev Jaiswal ("GPG Key Test") <sjaiswal@gmail.com>" 4096-bit ELG-E key, ID 38765DB9, created 2013-11-05 (main key ID CBE9BE42) gpg: encrypted with 4096-bit ELG-E key, ID 38765DB9, created 2013-11-05 "Sanjeev Jaiswal ("GPG Key Test") <sjaiswal@gmail.com>" Hi This is Sabnjeev Or [sjaiswal@AlienCoders ~/.gnupg]$ gpg --output secrets_from_tom --decrypt secrets_to_aliencoders Which would save the decrypted message in secrets_from_sanjeev Editing Key gpg --edit-key sjaiswal@gmail.com There is more: Photo IDs GnuPG has the ability to add a photo ID to a public key, exactly as in recent Windows versions of PGP. A photo ID attached to a public key can help other users to identify the owner of the key. To add a photo ID to your own public key, use the command "gpg --edit-key <name>" and then enter "addphoto". GnuPG will ask for the filename of a suitable JPEG. No other types of image files can be used. If you want to see a photo ID on a particular key, enter the command "--show-photos" before using the command "gpg --list-keys <name>". If <name> is omitted, GnuPG will display all the photos (if any) after listing all the keys in your public keyring. Alternatively, if you want photos to be displayed in all cases by default, you should uncomment the line "# show-photos" in the options file inside !GnuPGUser. Output of trustdb [Sanjeev@AlienCoders]$ gpg --update-trustdb gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model gpg: depth: 0 valid: 1 signed: 7 trust: 0-, 0q, 0n, 0m, 0f, 1u gpg: depth: 1 valid: 7 signed: 3 trust: 0-, 0q, 4n, 3m, 0f, 0u gpg: the next trustdb check will be done on 2014-02-04 http://www.aliencoders.com/ Page 6
  • 7. Basics of GnuPG (GPG) command in Linux The first line shows you the actual trust policy used by your GnuPG installation, and which you can modify at your needs. It states that a key in your keyring is valid if it has been signed by at least 3 marginally trusted keys, or by at least one fully trusted key. The second line describes the key of level 0, that is the key owned by you. It states that in your keyring you have one level zero key, which is signed by 7 keys. Furthermore among all the level zero keys, you have 0 of them for which you haven't yet evaluated the trust level. 0 of them are the keys for which you have no idea of which validity level to assign (q="I don't know or won't say"). You also have 0 keys that you do not trust at all (n="I do NOT trust"), 0 marginally trusted keys (m="I trust marginally"), 0 fully trusted keys (f="I trust fully") and 1 ultimately trusted keys (u="I trust ultimately"). The third line analyzes the keys of level 1 in your keyring. You have 7 fully valid keys, because you have personally signed them. Furthermore, among the keys that are stored in your keyring, you have 3 of them that are not signed directly by you, but are at least signed by one of the fully valid keys. The trust status counters have the same meaning of the ones in the second line. This time you have 4 keys signed by you but for which you do not trust at all the owner as signer of third party's keys. On the other side, 3 of the 7 keys that you have signed are marginally trusted. This means that you are only marginally confident that the owners of those keys can verify well the keys that they sign. [Sanjeev@AlienCoders]$ gpg --check-trustdb gpg: 3 marginal(s) needed, 1 complete(s) needed, PGP trust model gpg: depth: 0 valid: 1 signed: 7 trust: 0-, 0q, 0n, 0m, 0f, 1u gpg: next trustdb check due at 2014-02-04 Source: http://www.wikipedia.com Reference: GnuPG Handbook Author: Sanjeev Jaiswal Facebook: https://www.facebook.com/aliencoders G+: https://plus.google.com/+Aliencoders Twitter: https://twitter.com/aliencoders Pinterest: http://www.pinterest.com/aliencoders/ LinkedIn: http://www.linkedin.com/groups/Alien-Coders-4642371 Slideshare: http://www.slideshare.net/jassics http://www.aliencoders.com/ Page 7