the easy way
use a graphical program to export secret keys, then install it somewhere else to import them. they all have some respective way to export.
Passwords and Keys, aka GNOME Seahorse. preinstalled on most GNOME distros.
Kleopatra, for KDE Plasma users. i dont think its frequently preinstalled but installing it is easy.
the other easy but slightly harder way
copy the entire .gnupg
and .ssh
folders from the home directory and move them to another place.
it is easy to backup but restoration requires some setup.
restoring a .ssh
folder:
- copy
.ssh
folder to home directory - run
ssh-add
to add all the keys (input passwords if necessary) - set every file's permissions so that only the owner has read-write access. it can be done graphically with a file manager (gnome nautilus, or kde dolphin) or automated through the command line
chmod 600 ~/.ssh/*
chmod
is the linux command to manage permissions
600
means only the owner has read-write access, and other groups and guests have none.
~/.ssh/*
is the directory of the ssh folder. the star at the end selects all files within the specified folder.
chmod 600 in chmod calculator
restoring a .gnugp
folder:
drag and drop into the home directory, as done with the ssh folder.
now you need to import a copy of the public key into your gpg keychain so it can recognize it has the public keys.
find a copy of the public key, and improt it either graphically or with gnupg
gpg --import my_public_key.pgp
it should automatically pick up on it.
you can fetch from keyservers incase of no local public keys avaliable
gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 12345678
hkp://pool.sks-keyservers.net
should be a desired keyserver, if you already have a configured keyserver that has your oublic key, the you can omit the --keyserver
option.
gpg --recv-keys 12345678
12345678
should be an identifier for the key, either the key ID, fingerprint, or an email, whatever is necessary to look through the keyserver.