DEV Community

Arshan Nawaz
Arshan Nawaz

Posted on

1 1 1

Add SSH to Github

Step 1: Generate a new SSH key

ssh-keygen -t ed25519 -C "email@example.com" -f ~/.ssh/key-path

Enter fullscreen mode Exit fullscreen mode

Step 2: Display the public key (use this to add to GitHub)

cat ~/.ssh/key-path.pub

Enter fullscreen mode Exit fullscreen mode

Step 3: Start the SSH agent

eval "$(ssh-agent -s)"

Enter fullscreen mode Exit fullscreen mode

Step 4: Add the new key to the SSH agent

ssh-add ~/.ssh/key-path

Enter fullscreen mode Exit fullscreen mode

Step 5: Edit the SSH config file to specify which key to use for GitHub

nano ~/.ssh/config

Enter fullscreen mode Exit fullscreen mode

Inside the config file, add the following:

Host github.com
   HostName github.com
  User git
   IdentityFile ~/.ssh/key-path
Enter fullscreen mode Exit fullscreen mode

Step 6: Set appropriate permissions for the .ssh directory and the keys

chmod 700 ~/.ssh              # Permissions for the .ssh folder
chmod 600 ~/.ssh/key-path      # Permissions for the private key
chmod 644 ~/.ssh/key-path.pub  # Permissions for the public key
Enter fullscreen mode Exit fullscreen mode

Step 7: Test the connection to GitHub

ssh -T git@github.com

Enter fullscreen mode Exit fullscreen mode

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

Heroku

This site is powered by Heroku

Heroku was created by developers, for developers. Get started today and find out why Heroku has been the platform of choice for brands like DEV for over a decade.

Sign Up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay