Tag Archives: Key based security

Key based security (Digital Signature )with gpg encryption in RedHat Linux Server

Hello guys today we will learn how to configure key based Security in RedHat Linux. its a very simple process you just Follow my Simple Steps

file encrypt

Step 1 here i Create a.txt File and put something text matter in this file

[root@localhost exp]# vim a.txt
Hello this is my Digital key signature demo in linux redhat Server
~
~
~
~
:wq

Step 2 then we will encrypt our file below commands

[root@localhost exp]# gpg -c a.txt
Enter passphrase: redhat
Repeat passphrase: redhat
(Note-Here we will remove a.txt file then we have a.txt.gpg file. this is a encrypt file )
[root@localhost ~]# rm -rf a.txt
(Note- now we will open a.txt.gpg file then we will found encrypt data )
[root@localhost ~]# cat a.txt.gpg
?Q]?q*k?`????@?E?x??[???F??{??6Q??

Step 3 now we can get original file data through below commands

[root@localhost ~]# gpg -d a.txt.gpg
gpg: CAST5 encrypted data
Enter passphrase:redhat
Hello this is my Digital key signature demo in linux redhat Server
(Note- if we want remove encrypt security we will used below Commands)
[root@localhost exp]# gpg a.txt.gpg
gpg: CAST5 encrypted data
gpg: encrypted with 1 passphrase
gpg: WARNING: message was not integrity protected
[root@localhost exp]# ls
a.txt  a.txt.gpg

now suppose we have multi pal file and we want to protract  all file then we can use digital key.if we will create digital key then again to again no need to create password any time we can apply same password on all file through digital key .

Step 4 then we will Create Digital key through below Commands

[root@localhost exp]# 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.
Please select what kind of key you want:
   (1) DSA and Elgamal (default)
   (2) DSA (sign only)
   (5) RSA (sign only)
Your selection? 1 (note- here we will select 1 )
DSA keypair will have 1024 bits.
ELG-E keys may be between 1024 and 4096 bits long.
What keysize do you want? (2048) 2048 (note- here we will put our key bits size)
Requested keysize is 2048 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) 0 (notes- here we will select 0 becouse we want not Expiry key )
Key does not expire at all
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: vishnu sharma        (note- here we will put our name email Address and something Comments)
Email address: vlalitsharma@gmailcom  
Comment: this is digital key password
You selected this USER-ID:
    "vishnu sharma (this is digital key password) <vlalitsharma@gmailcom>"
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit? o (note- here will press o for okay)
ou need a Passphrase to protect your secret key. (Note- here we will put our password )
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.
.++++++++++++++++++++++++++++++.++++++++++..+++++++++++++++.+++++++++++++++++++++++++++disks) during the prime generation; this gives the random number
generator a better chance to gain enough entropy.
.++++++++++..+++++++++++++++.++++++++++..+++++++++++++++..++++++++++..++++++++++++++++++
gpg: key 52747DF7 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:   2  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 2u
pub   1024D/52747DF7 2017-03-10
      Key fingerprint = B00B 24CC CA58 9DBB AC29  DFB5 7DBF FE59 5274 7DF7
uid                  vishnu sharma (this is digital key password) <vlalitsharma@gmailcom>
sub   2048g/1C25308A 2017-03-10

Step 5 here we will look our file key below Commands

[root@localhost exp]# gpg --list-key
/root/.gnupg/pubring.gpg
------------------------
pub   1024D/5B148026 2017-03-09
uid                  vishnu sharma (hindiitsolution.com) <vlalitsharma@gmail.com>
sub   2048g/7DB30C64 2017-03-09

Step 6 now we will provide key on file through below Commands

[root@localhost exp]# gpg -e -r 'vlalitsharma@gmail.com' a.txt(Note- here we will gave file name which we want protract)

Step 7 we can also broken file in parts through gpg commands 

[root@localhost exp]# gpgsplit a.txt.gpg
[root@localhost exp]# ls
000001-001.pk_enc  000002-018.encrypted_mdc  a.txt  a.txt.gpg

Step 6 we can combine our file below Commands 

[root@localhost exp]# cat 000001-001.pk_enc 000002-018.encrypted_mdc >a.txt
[root@localhost exp]# ls
000001-001.pk_enc  000002-018.encrypted_mdc  a.txt 

if you have any problem in this process so please Comments here i will solve your problem

Thank you

by Vishnu Sharma

Advertisements