Gpg encrypt file command




















Do not forget that we still have to save the file with the "Save All" option that appears at the end, if the file already exists it will ask us for confirmation to overwrite it.

To encrypt files, we use the gpg command with the -c parameter:. Unfortunately when using the terminal the password has to be entered in the Kleopatra interface, which opens automatically when executing the command, it is not something bad, but ideally, if we use the terminal, the whole procedure needs to be continued in the same terminal.

To decrypt we use the gpg command without parameters, only the name of the encrypted file:. To see in more detail the use of the command in the terminal we can review this guide to GPG in Linux , basically the options and parameters are the same, the only thing that changes is the installation method. Internet, Computing and Technology. However, to obtain these advantages, a minimal level of complexity is required to make it all work. For an overview of how public key cryptography works, read the Introduction to Cryptography link at the bottom of this post.

In all examples below, text that you will need to replace with your own values e. To get started with GPG, you first need to generate your key pair. That is, you will generate both a private and a public key with a single command. Enter your name and email address at the prompts, but accept the default options otherwise. The first key is your private or secret key. You must keep this private key safe at all times, and you must not share it with anyone.

The private key is protected with a password. Try to make the password as long as possible, but something you will not forget. For the same reason, you should also make a backup copy of your private key.

The second key is your public key, which you can safely share with other people. The relationship of the private and public key is actually very simple.

Anything that is encrypted using the public key can only be decrypted with the related private key. Therefore, you will provide your public key to another person, and they will provide you with their public key. Anything encrypted to your public key can only be decrypted by you. The next step is to export your public key and share it with another person.

That person should do the same, and export their public key. You can now view a list of public keys in your keyring, as well as the name and email address associated with each key. You need to have the public key of the recipient in order to encrypt the file, and the recipient needs your public key to decrypt it.

There is no danger in making your public keys just that—public. In fact, there are Public Key Servers for that very purpose, as we shall see.

Private keys must be kept private. If your public key is in the public domain, then your private key must be kept secret and secure. There are more steps involved in setting up GPG than there are in using it. Thankfully, you usually need only set it up once. The gpg command was installed on all of the Linux distributions that were checked, including Ubuntu, Fedora, and Manjaro. You can encrypt files and make them available for download, or pass them physically to the recipient.

You do need to associate an email address with the keys you generate, however, so choose which email address you are going to use. Here is the command to generate your keys. The --full-generate-key option generates your keys in an interactive session within your terminal window. You will also be prompted for a passphrase. Make sure you remember what the passphrase is. Three or four simple words joined together with punctuation is a good and robust model for passwords and passphrases.

You will be asked to pick an encryption type from a menu. Unless you have a good reason not to, type 1 and press Enter. You need to specify how long the key should last. If you are testing the system, enter a short duration like 5 for five days. If you are going to keep this key, enter a longer duration like 1y for one year.

The key will last 12 months and so will need renewing after one year. Confirm your choice with a Y. You will be prompted for your passphrase. You will need the passphrase whenever you work with your keys, so make sure you know what it is.

Click the OK button when you have entered your passphrase. If your private key becomes known to others, you will need to disassociate the old keys from your identity, so that you can generate new ones. To do this, you will require a revocation certificate.

The --output option must be followed by the filename of the certificate you wish to create. The --gen-revoke option causes gpg to generate a revocation certificate. You must provide the email address that you used when the keys were generated. You will be asked to confirm you wish to generate a certificate. Press Y and hit Enter. You will be asked for the reason you are generating the certificate.

Press 1 as a plausible guess and hit Enter. The certificate will be generated. You will see a message reinforcing the need to keep this certificate safe. Running Jobs with PBS. Post-Processing Data. Systems Reference. Security and Policies. Cloud Computing. Machine Learning. NAS Data Portal. Article ID: Examples If you choose not to add the cipher-algo AES to your gpg.



0コメント

  • 1000 / 1000