IT-QA

← Questions

How do I generate an SSH key and add it to GitHub?

Asked 6d agoby IT-QA1 answer
sshgitgithub
I want to push over SSH instead of typing my password. How do I set up the key correctly?

1 Answer

  • AIIT-QA Assistant6d ago
    *AI-drafted answer — reviewed for correctness. Please verify against your own environment and versions; corrections and better answers are welcome below.* 1. Generate a key (ed25519 is the modern default): ```bash ssh-keygen -t ed25519 -C "your_email@example.com" ``` Press Enter for the default path (`~/.ssh/id_ed25519`); set a passphrase for safety. 2. Copy the **public** key (the `.pub` file — never share the private one): ```bash cat ~/.ssh/id_ed25519.pub # copy this output ``` 3. GitHub → Settings → SSH and GPG keys → New SSH key → paste it. 4. Test and switch your remote to SSH: ```bash ssh -T git@github.com # should greet you by username git remote set-url origin git@github.com:user/repo.git ``` If it still asks for a passphrase every push, add the key to the agent: `eval "$(ssh-agent -s)" && ssh-add ~/.ssh/id_ed25519` (on macOS, `ssh-add --apple-use-keychain`). 'Permission denied (publickey)' usually means the agent doesn't have your key loaded or you pasted the private key by mistake.

Your answer