2019. november 8., péntek

Manage SSH public keys with github

This is just another note-to-self post.

Wouldn't be nice to have your publickey stored in someplace where you can import it to .ssh/authorized_keys? Apparently github is a very convenient place for exactly that.

Generate your digital identity (source)

Luckily you only need to do this once.
  1. In Git Bash (or your linux machine)
    1. ssh-keygen -t rsa -b 4096 -C "your_github_email@example.com
  2. Add the public key to github (source):
    1. Find your public key file. The default location is ~\.ssh\id_rsa.pub
    2. Go to https://github.com/settings/keys and add it ot your keys
  3. (optional, Windows & Putty only) Convert public key to putty format (source):
    1. Open puttygen, and:
      1. Click Conversions/Import key.
      2. Navigate to the OpenSSH private key and click Open.
      3. Under Actions / Save the generated key, select Save private key.
      4. Choose an optional passphrase to protect the private key.
      5. Save the private key as id_rsa.ppk.
    2. Open putty, and:
      1. In Session tab, load the config you want to change
      2. Open SSH/Auth, tab, Browse the id_rsa.ppk
      3. Back in the session tab, Save the config


Import the key on the server you are connecting

Yes, on all of them
  1. On your remote server, you can add the public key like this (tested on ubuntu server): ssh-import-id gh:<github_user_id>

Troubleshooting

(Putty only): make sure your client actually sends in the key. The ky file location stored with the saved session
On the remote server side:
chmod 700 ~/.ssh - to fix permission errors on the folder
chmod 600 ~/.ssh/authorized_keys - to fix permission errors on the file

Nincsenek megjegyzések:

Megjegyzés küldése