- Check for existing ssh key
- Generate ssh key (if no key)
- Adding ssh private key to ssh-agent (optional)
- Adding ssh public key to GitHub account
- (Appndiex)
Check for existing ssh key
ls -al ~/.ssh
Generate ssh key (if no key)
ssh-keygen -t ed25519 -C "luchongkai96@gmail.com"
Replace the email address with yours
Adding ssh private key to ssh-agent (optional)
So you only need type the passwd once in every session.
Run ssh-agent
eval "$(ssh-agent -s)"
Add ssh private key to the running agent
ssh-add ~/.ssh/id_ed25519
Adding ssh public key to GitHub account
- Copy the SSH public key to your clipboard.
cat ~/.ssh/id_ed25519.pub
In the upper-right corner of any page, click your profile photo, then click Settings.
In the “Access” section of the sidebar, click SSH and GPG keys.
Click New SSH key or Add SSH key.
- In the “Title” field, add a descriptive label for the new key. For example, if you’re using a personal Mac, you might call this key “Personal MacBook Air”.
- Paste your key into the “Key” field.
(Appndiex)
Change a exsiting project authorization from HTTPS to SSH
git remote rm origin
git remote add origin git@github.com:user/repo.git # change to your ssh .git
git fetch origin
git push --set-upstream origin master