Back to the Central Hub

Public-key Cryptography Basics

Public-key cryptography uses a pair of mathematically related keys, a public key and a private key. Different implementations use these keys for different purposes.

A single SSH key can authenticate multiple services provided you add the public key to each service

Passkeys and cryptographic keys are stronger than traditional passwords because they rely on public-key cryptography and physical device possession instead of human-remembered shared secrets.

No secret is transmitted, they have phishing resistance, have immunity to guessing and brute force and protect against shoulder surfing.

System Generated Keys

  • Generate a key pair
    • ssh-keygen -t ed25519 -C "laptop"
      • ssh-keygen
        • Generates SSH keys. By default, it creates a public/private key pair.
      • -t
        • Stands for type. It tells ssh-keygen which cryptographic algorithm to use.
      • ed25519
        • Specifies the Ed25519 public-key signature algorithm. It’s a modern choice for SSH authentication, offering strong security and compact keys.
      • -C
      • Adds a text label to the key, helping you identify it later. For example, "laptop", "Arch Desktop", or "GitHub".

When prompted for a file, press Enter to accept the default ~/.ssh/id_ed25519 Set a passphrase if you want extra security.

  • Display your public key
    • cat ~/.ssh/id_ed25519.pub

New Computer Git Access

  • process used when logging into git from a computer that’s never logged in before.
    • Create new ssh key
      • ssh-keygen -t ed25519 -C "laptop"
        • accept the default storage location and set a passphrase
    • Display the public key
      • cat ~/.ssh/id_ed25519.pub
        • Copy that public key into your GitHub account under Settings → SSH and GPG keys → New SSH key
    • start the key agent
      • eval "$(ssh-agent -s)"
    • load key
      • ssh-add ~/.ssh/id_ed25519
    • test key loaded
      • ssh-add -l
    • Test Github connection

oneliner

eval "$(ssh-agent -s)" && ssh-add ~/.ssh/id_ed25519 && ssh-add -l && ssh -T [email protected]

Work on a repository stored on Github

  • Clone your repository

Back to the Central Hub