Passwords can be guessed or leaked. SSH keys use a pair of files, so the private half never leaves your machine.

To set one up:

ssh-keygen -t ed25519 -C "[email protected]"

Accept the default location and set a passphrase. The passphrase protects the key if someone copies the file.

Then:

  1. Start the agent and add the key with ssh-add.
  2. Copy the contents of the .pub file into your GitHub account under SSH keys.
  3. Test the connection with ssh -T [email protected].

Never share the private key file, and never commit it to a repository. If you think a key has leaked, delete it from GitHub and generate a new one.