DEV Community

amogh2019
amogh2019

Posted on

SSH connection to Github

from my new machine, wanted to checkout my existing github repo and start making commits.

how do I do connect to it via SSH?
for ssh we would need a private and public key pair,
private key we keep, and public key we let github know.

lets do this

setting this up on ubuntu / linux

  • assuming no existing key is present // generate ssh keypair
$ ssh-keygen -t ed25519 -C "your_email@example.com or username"
Enter fullscreen mode Exit fullscreen mode
  • add private key to ssh-agent // why??
$ ssh-add ~/.ssh/id_ed25519
Enter fullscreen mode Exit fullscreen mode
  • copy public key and add to github account (settings>access>ssh keys)
public key details is here
$ cat ~/.ssh/id_ed25519.pub
  # Then select and copy the contents of the id_ed25519.pub file
  # displayed in the terminal to your clipboard
Enter fullscreen mode Exit fullscreen mode
  • test ssh connection from terminal
$ ssh -T git@github.com
Enter fullscreen mode Exit fullscreen mode

Ref : https://docs.github.com/en/authentication/connecting-to-github-with-ssh/about-ssh

Top comments (0)