LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 09-28-2009, 10:53 AM   #1
Kearneyman
LQ Newbie
 
Registered: Sep 2004
Location: Austin, TX
Distribution: Alpine Linux, Bunsen Labs
Posts: 15

Rep: Reputation: 0
export GPG keys to multiple servers


I need to use Duplicity to backup server directories to Amazon S3.

Duplicity uses GnuPG to encrypt the data so that no one can read it.

I followed this guide to create "The script"

So, my task was create 1 script to be deployed across my servers which would backup the directories. And should any server die, have the ability to SCP the public and private keys to that server so that restoration could occur automatically and backups could occur after restoration.

Here's what to do

1. Generate the private and public keys
Code:
gpg --gen-key
answer all the questions. We'll assume the key created was 12345678. And the name you entered (Real name) is "Real name"

now create backups of your keys
Code:
gpg --output secret --export-secret-keys "Real name"
gpg --output public --export "Real name"
so, let's pretend, server dies. You get the OS installed on the new one

scp the secret and public keys to server2
Code:
#scp secret public root@server2:
now, from server2 import the keys
Code:
# gpg --import secret public
now, here comes the tricky part, you must tell GPG to trust these keys to avoid the error

gpg: There is no assurance this key belongs to the named user

Code:
server2# gpg --edit-key 12345678
Secret key is available.

Command> trust
pub  1024D/12345678  created: 2009-09-25  expires: never       usage: SC
                     trust: unknown       validity: unknown
sub  2048g/87654321  created: 2009-09-25  expires: never       usage: E
[ unknown] (1). Real name (comment) <some@email.com>

Please decide how far you trust this user to correctly verify other users' keys
(by looking at passports, checking fingerprints from different sources, etc.)

  1 = I don't know or won't say
  2 = I do NOT trust
  3 = I trust marginally
  4 = I trust fully
  5 = I trust ultimately
  m = back to the main menu

Your decision? 5
Do you really want to set this key to ultimate trust? (y/N) y

Command> save

server2#
now you can encrypt/decrypt things using the keys generated in step 1 on this new server

Last edited by Kearneyman; 09-28-2009 at 02:11 PM. Reason: Found solution
 
Old 09-28-2009, 11:10 AM   #2
Kearneyman
LQ Newbie
 
Registered: Sep 2004
Location: Austin, TX
Distribution: Alpine Linux, Bunsen Labs
Posts: 15

Original Poster
Rep: Reputation: 0
If you any questions or suggestions, please feel free to ask/post.

Last edited by Kearneyman; 09-28-2009 at 02:23 PM.
 
Old 09-28-2009, 03:49 PM   #3
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Is this a question or a howto?

As an alternative to using the interactive session to establish trust, you can:
Code:
$ gpg --export-ownertrust
(Then --import-ownertrust on the target host.)
 
Old 09-29-2009, 10:17 AM   #4
Kearneyman
LQ Newbie
 
Registered: Sep 2004
Location: Austin, TX
Distribution: Alpine Linux, Bunsen Labs
Posts: 15

Original Poster
Rep: Reputation: 0
Talking

Quote:
Originally Posted by anomie View Post
Is this a question or a howto?

As an alternative to using the interactive session to establish trust, you can:
Code:
$ gpg --export-ownertrust
(Then --import-ownertrust on the target host.)
LOL. First it was a question. Then after 3 hours I figured it out, and so I thought I'd post the solution.

Thanks for that command though. I just started learning GPG last week.

So, to clarify, on the server I created the GPG keys, say server1, I would issue the command
Code:
gpg --export-ownertrust "Real name" |
and pipe that to server2
Code:
gpg --import-ownertrust
Like this? Or am I mistaken?

Code:
gpg --export-ownertrust | ssh server2 --import-ownertrust
Again, thanks for your help. I really appreciate it.

I hope this helps a lot of people who want/need to accomplish this task.

Last edited by Kearneyman; 09-29-2009 at 10:34 AM.
 
Old 09-29-2009, 10:30 AM   #5
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
I'm not sure if you can specify real name in that fashion -- I have only exported / imported the entire trust db when I've used this. (But you can figure it out with a quick test.)

Anyway, yes - you have the gist of it.
 
  


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
Help understanding gpg keys Gins Linux - Software 5 10-10-2006 01:38 PM
GPG Keys matsko Linux - General 4 12-23-2005 07:53 PM
gpg keys pr0xibus Fedora 1 10-04-2005 10:45 AM
Using GPG Keys on Multiple Computers General_Tso Linux - Security 5 10-06-2004 10:37 AM

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

All times are GMT -5. The time now is 07:46 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