There is no transfer method more secure than using a physical USB storage to move the private key. However, often connecting physical devices is a barrier and at other times is an opposite wind. So, we'll create a simple HTTP server over a private (home) network and use that for the transfer.
Let us first export the GPG private and public keys:
gpg --output private.key --armor --export-secret-keys [email protected]
gpg --output public.key --armor --export [email protected]Most machines today will have at least a primitive version of python installed.
cd ~/
python3 -m http.serverAlso, we'll need to know the IP address of the origin machine as,
ipconfig getifaddr en0 # considering it's wirelessThis gives us (let's say) 1.2.3.4.
We open up a browser or curl 1.2.3.4 and download the following files:
~/.gnupg/private.key~/.gnupg/public.key~/.ssh/keys/personal.pem
And then move then appropriately to the location as required:
cp ~/Downloads/*.pem ~/.ssh/keys/A file downloaded from web doesn't have correct permissions for being a SSH key, hence we need to fix the permissions as well:
chmod 400 ~/.ssh/keys/*.pem