Skip to main content

Set up an SSH keypair

Requirements: Linux or Mac or a good Windows terminal.

  1. Check you don't already have one:
    ls ~/.ssh
    
    If you do, you can skip to (5), unless you want a new pair.
  2. ssh-keygen -t ed25519 -a 100 -C "name that will remind me why I made this"
    
  3. It will ask for a location. Default is fine, but if you already have one that you're still using, don't overwrite it! In any case, make sure it's in ~/.ssh.
  4. It will ask for a passphrase. You probably want to leave this empty, because it will be very annoying to type it in every time you make an SSH connection, and automatic scripts like cronjobs won't be able to use it at all.
  5. Give the other party the entire contents of your public key file (~/.ssh/id_ed25519.pub, unless you changed the location).
    • If you're in a web interface, paste it into the appropriate form field.
    • Otherwise, say you're connecting to example.com and your username there is goku123. Cast this spell:
      ssh goku123@example.com touch .ssh/authorized_keys
      cat ~/.ssh/id_ed25519.pub | ssh goku123@example.com 'dd of=.ssh/authorized_keys oflag=append conv=notrunc'
      

Never copy your private key (at ~/.ssh/id_ed25519). But if you accidentally do upload it somewhere, delete both the private and public key from your computer + everywhere you've uploaded them, and it should be fine.