How to Import/Export GPG key pair
Posted: Mon Jun 14, 2010 10:56 pm
This tutorial will show how you can export and import a set of GPG keys from one computer to another.
This way, you can sign/encrypt the same way one different computer.
A simple way of doing it would be to:
but this would import all your keyring.
If you want to import only one set of key, you first have to get the listing of your keys and find the one you want to export:
1. Export the GPG key
In this case, I am going to import key ABCDFE01.
Then copy thos files over to the remote host:
2. Import the GPG key
Now, log in the remote host:
And then import:
and then clean up:
This way, you can sign/encrypt the same way one different computer.
A simple way of doing it would be to:
Code: Select all
$ scp -r ~/.gnupg user@remotehost:~/
If you want to import only one set of key, you first have to get the listing of your keys and find the one you want to export:
1. Export the GPG key
Code: Select all
$gpg --list-keys
/home/user/.gnupg/pubring.gpg
--------------------------------
pub 1024D/ABCDFE01 2008-04-13
uid firstname lastname (description)
sub 2048g/DEFABC01 2008-04-13
Code: Select all
$ gpg --output mygpgkey_pub.gpg --armor --export ABCDFE01
$ gpg --output mygpgkey_sec.gpg --armor --export-secret-key ABCDFE01
Code: Select all
$ scp mygpgkey_pub.gpg mygpgkey_sec.gpg user@remotehost:~/
Now, log in the remote host:
Code: Select all
$ ssh user@remotehost
Code: Select all
user@remotehost:~$ gpg --import ~/mygpgkey_pub.gpg
user@remotehost:~$ gpg --allow-secret-key-import --import ~/mygpgkey_sec.gpg
Code: Select all
user@remotehost:~$ gpg --list-keys
/home/user/.gnupg/pubring.gpg
--------------------------------
pub 1024D/ABCDFE01 2008-04-13
uid firstname lastname (description)
sub 2048g/DEFABC01 2008-04-13
Code: Select all
user@remotehost:~$ rm ~/mygpgkey_sec.gpg ~/mygpgkey_pub.gpg