LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 01-08-2021, 07:20 AM   #1
villumanati
Member
 
Registered: Jun 2008
Posts: 48

Rep: Reputation: 15
GPG command line encryption


Hello,

I would appreciate it if someone would clarify gpg encryption.

essentially I run the command


Code:
gpg --output myFile.gpg --encrypt --recipient MyReciever myInput.txt
I then receive a prompt

Code:
It is not certain that the key belongs to the person named in the user id. If you really know what you are doing, you may answer the next question with yes

Use this key anyway? (y/N)
My question is there a way to skip this prompt and/or have it automatically enter y?


if it matters i am running linux debian 4.9.168...
 
Old 01-08-2021, 07:30 AM   #2
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,252

Rep: Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011
Are you encrypting files to keep yourself or are you emailing them to someone? I only encrypted files to keep for myself so I can't speak as to how to use gpg with email.
 
Old 01-08-2021, 09:26 AM   #3
villumanati
Member
 
Registered: Jun 2008
Posts: 48

Original Poster
Rep: Reputation: 15
I have received a public key i am encrytping the file so i can send to someone else.
 
Old 01-08-2021, 09:57 AM   #4
sevendogsbsd
Senior Member
 
Registered: Sep 2017
Distribution: FreeBSD
Posts: 2,252

Rep: Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011Reputation: 1011
I've never done this but is the public key imported into your configuration so gpg knows it exists? Guessing "MyReciever" is an alias or just placeholder for the recipient's email address so you don't post it publicly here?

Sorry for the vague answers but as I mentioned, I have never used gpg to send an encrypted file. I am quite familiar with PKI though, just not that implementation.
 
Old 01-08-2021, 10:52 AM   #5
villumanati
Member
 
Registered: Jun 2008
Posts: 48

Original Poster
Rep: Reputation: 15
yes, I imported into my keyring.

as a side note the entire encryption process works fine. i can encrypt a message without issue. i am trying to do it in a script which is why i am trying to avoid the
 
Old 01-08-2021, 10:57 AM   #6
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622
Blog Entries: 40

Rep: Reputation: Disabled
Code:
It is not certain that the key belongs to the person named in the user id. If you really know what you are doing, you may answer the next question with yes

Use this key anyway? (y/N)
The message indicates that in the web of trust no connection can be made between you and the selected key and that confidence in the authenticity of that key has not yet been established.

This is what key-signing is about.

What you do normally in this case is a
Code:
:~$ gpg -kv [userid or key-id]
to see the details of the key. Then you either phone up the holder of the key or (better) visit her/him at home to compare these data with those that she/he can establish for her/his own key. This way the identity of the user's key with the one that you have is established.

Next, you sign the key with your own to certify the validity of the key. You created a new connection in the web of trust and GnuPG will no longer ask for confirmations. Even other people, who trust *your* key already, can now trust the other user's key.

See also: Key-signing party.
See also: TOFU
See also: Self-signing a key

comp.security.pgp FAQ - Very old and outdated, but still conveys the basics.

Last edited by Michael Uplawski; 01-08-2021 at 11:02 AM. Reason: a lot
 
1 members found this post helpful.
Old 01-08-2021, 11:10 AM   #7
villumanati
Member
 
Registered: Jun 2008
Posts: 48

Original Poster
Rep: Reputation: 15
thanks for the clarification
is there a way to avoid signing the key and still generating a valid encrypted file?

basically, if i didn't care and just wanted to encrypt the file since i have the public key of the receiver?
 
Old 01-08-2021, 01:41 PM   #8
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622
Blog Entries: 40

Rep: Reputation: Disabled
Quote:
Originally Posted by villumanati View Post
thanks for the clarification
is there a way to avoid signing the key and still generating a valid encrypted file?
I am sorry, but I do not understand the question. GnuPG asks “use this key anyway?”, and I bet your English is better than mine.

Quote:
basically, if i didn't care and just wanted to encrypt the file since i have the public key of the receiver?
This is what it is all about. Maybe I have not been clear enough in my previous post. You say, you have the key of the receiver.
If you know that the key is authentic, GnuPG lets you set a trust-level for the key. ALL is in the manuals. The manuals to GnuPG are among the best ever written for any software.

See here: https://www.gnupg.org/gph/en/manual/x334.html

Last edited by Michael Uplawski; 01-08-2021 at 01:43 PM.
 
Old 01-10-2021, 07:51 AM   #9
villumanati
Member
 
Registered: Jun 2008
Posts: 48

Original Poster
Rep: Reputation: 15
Thanks, Michael for the reply. You lead me down the right path.

I used the information you provided along with this (https://ianatkinson.net/computing/gnupg.htm) website to avoid having to sign the key.

Also, made me aware of other ways also such as this https://blog.tersmitten.nl/how-to-ul...ractively.html.
 
Old 01-10-2021, 08:52 AM   #10
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,910

Rep: Reputation: 5027Reputation: 5027Reputation: 5027Reputation: 5027Reputation: 5027Reputation: 5027Reputation: 5027Reputation: 5027Reputation: 5027Reputation: 5027Reputation: 5027
What I usually do is use --lsign-key, which is basically saying I trust the key for my own use, but I'm not prepared to vouch for it to others.
 
Old 01-10-2021, 02:56 PM   #11
vincix
Senior Member
 
Registered: Feb 2011
Distribution: Ubuntu, Centos
Posts: 1,240

Rep: Reputation: 103Reputation: 103
Another solution would be to use yes and the pipe the command into it, such:
Code:
yes | gpg --output myFile.gpg --encrypt --recipient MyReciever myInput.txt
That way you'll be able to automate it into a script without worrying about the prompt, if you don't care about understanding gpg and its whole gpg-web-of-trust thing.
 
Old 01-10-2021, 04:21 PM   #12
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,622
Blog Entries: 40

Rep: Reputation: Disabled
Quote:
Originally Posted by vincix View Post
automate it into a script without worrying about the prompt, if you don't care about understanding gpg and its whole gpg-web-of-trust thing.
Could be funny. Engrave this into a stone and fling it at someone you really hate...
Naa... I think it is funny.
 
  


Reply

Tags
gpg



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gpg / gpg-agent -- Can't connect to /root/.gnupg/S.gpg-agent jrtayloriv Linux - Security 9 06-03-2019 10:06 AM
[SOLVED] gpg: WARNING: unsafe permissions on configuration file `/home/b/.gnupg/options' gpg: widda Mandriva 9 07-30-2018 07:49 AM
Need simple process for File Encryption and decryption using gpg command in Linux lakshmi@Linux Linux - Newbie 8 03-16-2017 02:40 AM
[SOLVED] Questions on GPG keyrings for debain apt-get? (fixing problem with gpg) frog-o Debian 2 05-12-2013 10:50 AM
GPG: Bad session key gpg between gpg on linux and gpg gui on windows XP konqi Linux - Software 1 07-21-2009 09:37 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 07:31 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration