How to Encrypt File with Password Using GPG

31

Security is an very important side for each Linux consumer who needs to construct a safe device. From sending encrypted recordsdata or paperwork over the web to storing them on an area device, there exist more than a few answers for enabling report encryption tactics. You too can use a GPG or “GNU Privacy Guard” for encrypting a report or listing with a password in Linux.

This write-up will speak about methods to encrypt a report with password the use of GPG. Moreover, we can additionally exhibit the process of report encryption the use of the command-line and Seahorse Linux instrument. So, let’s get started!

Before leaping into the report encryption process, set up GPG in case you don’t have it already.

How to put in GPG in Linux

To set up GnuPG or GPG to your Linux device, at the start press “CTRL+ALT+T” after which sort the below-given command within the opened terminal:

$ sudo apt-get set up GnuPG

After putting in, transfer forward against the report encryption process.

Note: For the demonstration goal, we can percentage the encrypted recordsdata to every other consumer account in an effort to have a greater concept of the report decryption procedure.

How to encrypt a report with password the use of GPG thru command-line

In Linux-based techniques, you’ll be able to safe the recordsdata or paperwork with a password. For this goal, we can use GPG and display you methods to carry out the required operation during the command line.

The syntax of the gpg command for encrypting a report is given under:

Here, the “-c” choice is added to encrypt the report with the assistance of a symmetric cipher passphrase or password.

Now, at the start we can create a “samplefile.txt” report and upload some content material to it by means of executing the next “echo” command:

$ echo “This is linuxhint.com” > samplefile.txt

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485300 12 How to Encrypt File with Password Using GPG

GPG used “CAST5” as an encryption set of rules within the older variations; alternatively, since model 2.1, the AES symmetric set of rules is embedded within the GPG tool. Three block ciphers at the moment are integrated in AES:

  • AES128” encrypts and decrypts a block of messages by using a 128-bit key period.
  • AES192” encrypts and decrypts a block of messages by using a 192-bit key period.
  • AES256” encrypts and decrypts a block of messages by using a 256-bit key period.

We have decided on the GPG “AES256” to encrypt the “samplefile.txt”:

$ gpg -c –cipher-algo AES256 ./samplefile.txt

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485300 462 How to Encrypt File with Password Using GPG

Now, you are going to be requested to sort a passphrase. In the encryption procedure, the passphrase is used to encrypt the personal key of the consumer and give protection to it from any assault. So, make a selection a robust passphrase to safe the chosen report:

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485301 431 How to Encrypt File with Password Using GPG

Re-enter your passphrase for the affirmation:

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485301 497 How to Encrypt File with Password Using GPG

The error-free execution of the “gpg” command signifies that we have got effectively encrypted the “sampefile.txt” report:

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485301 39 How to Encrypt File with Password Using GPG

After doing so, listing out the content material of your present operating listing and spot the encrypted “samplefile.txt.gpg” report:

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485301 200 How to Encrypt File with Password Using GPG

Till this level, you’ve got encrypted the chosen report with a password the use of the GPG command. Now, take a look at its content material by means of executing the “cat” command:

The output will print out the encrypted type of the “samplefile.txt” report’s content material:

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485302 117 How to Encrypt File with Password Using GPG

Next, execute the straightforward “gpg” command with the encrypted filename to generate its decrypted report:

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485302 853 How to Encrypt File with Password Using GPG

You shall be requested to go into the “Passphrase” which was once used to encrypt the “samplefile.txt” report:

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485302 313 How to Encrypt File with Password Using GPG

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485303 187 How to Encrypt File with Password Using GPG

A “samplefile.txt” decrypted report shall be generated after coming into the passphrase. To take a look at  its content material, write out the next command:

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485303 976 How to Encrypt File with Password Using GPG

How to encrypt a report with password thru GUI

Most of the customers choose to make use of Linux GUI, because it lets them encrypt a report with a password the use of a couple of clicks. More particularly, the “Seahorse” is among the common Linux programs this is used for a similar goal.

Seahorse is a GNOME front-end program this is used for managing SSH, PGP, and the password associated with encrypted recordsdata. It was once launched as unfastened tool underneath the GPL 2.0 License. In the Seahorse program, the GPG is used for imposing the PGP reinforce and the GNOME keyring is helping to safe the passwords.

Now, execute the next command for putting in “seahorse-nautilus” bundle to your Linux device:

$ sudo apt-get set up seahorse-nautilus

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485303 111 How to Encrypt File with Password Using GPG

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485304 167 How to Encrypt File with Password Using GPG

The error-free output signifies that “Seahorse” is put in to your device. Now, make a selection the report which you need to encrypt with a password. In our case, we have now decided on the “testfile.txt” which is provide within the “Documents” Directory:

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485304 522 How to Encrypt File with Password Using GPG

Next, click on at the decided on report and make a selection the “Encrypt” choice:

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485304 4 How to Encrypt File with Password Using GPG

A pop-up conversation field will seem to your display, click on at the “Use a shared passphrase” solution to affiliate a password with the report encryption process:

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485304 374 How to Encrypt File with Password Using GPG

Now, sort out a robust passphrase to finish the report encryption procedure:

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485305 636 How to Encrypt File with Password Using GPG

Re-enter the added passphrase for the verification:

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485305 391 How to Encrypt File with Password Using GPG

After doing so, you are going to see a brand new encrypted report having the similar filename as the unique one with the “.gpg” extension. For example, in our case, the “testfile.txt.pgp” is the encrypted report having a password:

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485306 744 How to Encrypt File with Password Using GPG

To decrypt this “samplefile.txt.gpg” report, you’ve got to make a choice the “Open With Decrypt File” choice from its left-click menu:

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485306 527 How to Encrypt File with Password Using GPG

Then, a passphrase window will seem to your display asking you to enter the passphrase which you’ve got used for encrypting the “testfile.txt” report:

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485307 562 How to Encrypt File with Password Using GPG

After coming into the passphrase, a decrypted report shall be generated  which is “testfile.txt” in our case:

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485307 210 How to Encrypt File with Password Using GPG

Now, click on at the generated report and examine its decrypted content material for your textual content editor:

how to encrypt file with password using gpg How to Encrypt File with Password Using GPG 1641485307 573 How to Encrypt File with Password Using GPG

Conclusion

When it involves safety, encrypting recordsdata with passwords in Linux is a should. GPG lets you encrypt your recordsdata and paperwork prior to you ship them in ongoing verbal exchange. It additionally has a versatile key control device in addition to get entry to modules for quite a few public key directories. This write-up mentioned methods to encrypt recordsdata with a password the use of GPG. Moreover, we have now additionally demonstrated the process of report encryption the use of the command-line and Seahorse Linux instrument.

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More