forked from EESSI/software-layer
-
Notifications
You must be signed in to change notification settings - Fork 1
Setting up SSH based access to GitHub
trz42 edited this page Feb 7, 2023
·
2 revisions
ssh-keygen -t ed25519 -f ~/.ssh/id_gh_nessi
Type in a passphrase. It needs to be strong. No big deal if you forget it, just repeat the steps to create a new one.
- Open https://github.com/settings/keys
- Click “New SSH key”
- Provide a meaningful name and set key type to “Authentication key”
- Paste in the public part of the key (display it on your machine with
cat ~/.ssh/id_gh_nessi.pub
)
In a terminal run
ssh -i ~/.ssh/id_gh_nessi -T git@github.com
You should be asked to type in the passphrase of the key. If the test is successful you should see something like:
Hi YOUR_GH_ACCOUNT! You've successfully authenticated, but GitHub does not provide shell access.
To avoid that you have to type in your passphrase again and again, you can set up an ssh-agent
and store your key with it. You only have to type in the passphrase of the key once.
- Launch
ssh-agent
in your shell (note has to be done for every shell)
eval “$(ssh-agent -s)”
- Add your SSH key pair to the agent
ssh-add ~/.ssh/id_gh_nessi
Type in the passphrase for the key. 3. Try again to authenticate against GitHub
ssh -T git@github.com -i ~/.ssh/id_gh_nessi
Should show something like below without asking for the passphrase.
Hi YOUR_GH_ACCOUNT! You've successfully authenticated, but GitHub does not provide shell access.
Add a section to your ~/.ssh/config
Host gh-nessi
Hostname github.com
IdentitiesOnly yes
IdentityFile ~/.ssh/id_gh_nessi