gpg2 terminal commands

Discussion in 'all things UNIX' started by Palancar, Dec 6, 2017.

  1. Palancar

    Palancar Registered Member

    Joined:
    Oct 26, 2011
    Posts:
    1,866
    I am drawing blanks for some reason. I use gpg/gpg2 with GUI helping software, but I am trying to leave that all behind for terminal commands. I have been "playing" with use of gpg2 and the terminal for encrypting text messages using Debian Jessie - an example would be for use in the PM system here. I can do file encryption, signature, and decryption without any hassles at all. A typical command line for file encryption and signature to a friend's key would look like this in my terminal:

    In this example I am encrypting a file located on the Desktop of a VM, and for here we'll name it "filename".

    cd Desktop && gpg2 --armor -r "myfriend" --encrypt --sign "filename"

    This works great and obviously I can decrypt easily as long as its a FILE. Now on to the question(s) of this post. How can I do the same thing using encrypted text like in a PM system on a website? I do use the PM system and encryption here and elsewhere, but cannot figure out how to use terminal commands to accomplish this. Obviously I am missing something somewhere in the learning process. If someone can answer in a way that I could use the PM system here it would solve the issues I am stumbling over. I could really use some direction.
     
  2. Palancar

    Palancar Registered Member

    Joined:
    Oct 26, 2011
    Posts:
    1,866
    Turns out this is really easy to do. This is for pasting text directly into your Terminal. Files are even easier, these commands are not for files. If anyone is interested I'll paste my command lines for you to use. Your linux system likely has gpg/gpg2 already installed.



    Decrypt in Terminal (will verify signature automatically if signed by sender)

    1. gpg2 -r Palancar -d

    2. Hit Enter

    2. "then paste in encrypted text" and it will tell your key password is needed. Mine is likely cached previously.

    3. then hit <left> CTRL D (twice ??)

    4. read message unencrypted.



    Encrypt and Sign in Terminal:

    1. gpg2 -r Palancar --sign -r "friends-key-name" -ae

    2.Hit Enter to create a line space

    3. Type text and hit Enter

    3. Left CTRL D (maybe twice)

    4. You will see encrypted text in the terminal to paste wherever, such as a PM!