Home | Ubuntu/Mint | Arch/Manjaro | ssh/gpg | texlive | python | git | steam

ssh & gpg

ssh

Generate an ssh key:
ssh-keygen -t rsa -b 4096

Show the public key:
cat ~/.ssh/id_rsa.pub

Passwordless authentication:
ssh-copy-id -i ~/.ssh/id_rsa.pub -p <port> <user>@<server>

gpg

Generate an GPG key:
gpg --full-gen-key

List keys:
gpg --list-secret-keys --keyid-format LONG

Get the relevant secure piece:
gpg --list-secret-keys --keyid-format LONG | grep sec | awk '{print $2}' | awk -F/ '{print $2}'
Use it to sign git commits:
git config --global user.signingkey $(gpg --list-secret-keys --keyid-format LONG | grep sec | awk '{print $2}' | awk -F/ '{print $2}')
git config --global commit.gpgsign true

Export the public key:
gpg --armor --export $(gpg --list-secret-keys --keyid-format LONG | grep sec | awk '{print $2}' | awk -F/ '{print $2}')

Export public and private keys to move them to a new user/machine:
gpg --export ${KEY} > public.key
gpg --export-secret-key ${KEY} > private.key

where ${KEY} is the relevant secure piece from above.
Import them again:
gpg --import public.key
gpg --import private.key