LinuxQuestions.org
Help answer threads with 0 replies.
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 04-25-2011, 05:26 PM   #1
mstone0802
LQ Newbie
 
Registered: Apr 2011
Location: Phoenix, AZ
Distribution: Ubuntu, Mint, CentOS
Posts: 7

Rep: Reputation: 0
Automated gpg Key Trust


My company makes extensive use of gpg, and we are constantly getting keys from our customers. We're looking to automatically import those keys (or at least pseudo-automatically), and grant a minimal trust level. I've done some reading on this, and found a couple different pages that have suggestions, but none seem to work. Most give me this:

Code:
gpg --edit-key ########
trust
1 -- or other numeric value corresponding to trust level
save
This is all well and good, but doesn't quite meet our needs. We'd like to script the process if we could. We've got everything automated up to the trust. Is there a way to grant a level of trust that can be executed from outside the gpg application so it can be scripted?

Last edited by mstone0802; 04-25-2011 at 06:08 PM. Reason: Removed redundant exit code from the -- well -- code.
 
Old 04-25-2011, 06:00 PM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

You can give a try to the following:

1. Create directory which will contain all gpg keys.
2. If they start with a particular name or end with particular extension you can go with gpg --import abc.* or *.abc and this will get the key imported to your system.
3. Schedule a crontab job to run this task every midnight.

Let me know if this helps.
 
Old 04-25-2011, 06:06 PM   #3
mstone0802
LQ Newbie
 
Registered: Apr 2011
Location: Phoenix, AZ
Distribution: Ubuntu, Mint, CentOS
Posts: 7

Original Poster
Rep: Reputation: 0
Thank you for the reply, but that's the part that we've already got automated. Our problem is that once the keys are imported, they have a trust level of 1 (which is default). If you look at them in gpg, the trust level will report as "Unknown". We'd like to give them a trust level of 3 (marginal), but to do that, we have to follow the steps I previously mentioned. We're looking to upgrade that trust level within the script that does the initial import.
 
Old 04-25-2011, 06:38 PM   #4
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ Reply

Unfortunately it is a menu driven program so I am not sure how we can automate the process.

The only idea that I can give is if you can set some kind of redirection which can change the value of trust=3, like people usually do with databases

Just an example example of what I am trying to say:

database < database_file

Last edited by T3RM1NVT0R; 04-25-2011 at 07:00 PM.
 
Old 04-25-2011, 07:00 PM   #5
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
I think I found something

Check out this link: http://www.gossamer-threads.com/lists/gnupg/users/51413
 
1 members found this post helpful.
Old 04-25-2011, 11:25 PM   #6
mstone0802
LQ Newbie
 
Registered: Apr 2011
Location: Phoenix, AZ
Distribution: Ubuntu, Mint, CentOS
Posts: 7

Original Poster
Rep: Reputation: 0
Lightbulb Promising..

That last link looks really promising. I'll let you know how implementation goes when I'm back at work tomorrow. Fingers crossed!
 
Old 04-26-2011, 12:33 PM   #7
mstone0802
LQ Newbie
 
Registered: Apr 2011
Location: Phoenix, AZ
Distribution: Ubuntu, Mint, CentOS
Posts: 7

Original Poster
Rep: Reputation: 0
Talking Solution Found!!

Thanks for the link T3RM1NVT0R, it gave me what I needed. If anybody wants to do something similar in the future, here's the relevant snippet of code:

Code:
TRUST_VALUE=':3:'

TEMP_VAR=0
while [ "${KEYNAMES[$TEMP_VAR]}" != "" ]
do
  TRUSTVAR=`gpg --fingerprint ${KEYNAMES[$TEMP_VAR]}|grep Key|cut -d= -f2|sed 's/ //g'`
  echo $TRUSTVAR$TRUST_VALUE >> $TEMP_FILE
  TEMP_VAR=`expr $TEMP_VAR + 1`
done

gpg --import-ownertrust $TEMP_FILE
This code references a previously built array of key names. Works like a charm.
 
  


Reply



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: Bad session key gpg between gpg on linux and gpg gui on windows XP konqi Linux - Software 1 07-21-2009 09:37 AM
Revoking GPG key with only passphrase and public key djib Linux - Security 2 03-13-2007 03:20 AM
can see gpg key in apt-key, still can't update Dan63043 Ubuntu 2 09-25-2006 11:35 AM
Can I trust GPG? crashsystems Linux - Security 10 08-22-2006 06:54 PM
GPG Data, Secret Key but no Public Key? Aeiri Linux - Software 5 07-20-2004 06:00 PM

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

All times are GMT -5. The time now is 08:35 PM.

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