Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
September 17, 2022 07:49 pm GMT

Set up SSH for GitHub in the Terminal

Verify the existence of the directory ~/.ssh

  • Let's verify if we have a directory called .ssh in the root (cd ~). We can verify by changing to that directory cd ~/.ssh

Creating the .ssh directory

  • If we don't have the directory then we create it: mkdir ~/.ssh.

Generate a new key

  • If we have the directory, then we generate a key by
ssh-keygen
  • We press ENTER to save the key in our directory /Users/user-name/.ssh/id_rsa

  • If we want a password that protect the key, we enter a passphrase and click ENTER, and we repeat the same passphrase settled later and press ENTERagain.

    • If we don't want to, we just left it empty and press ENTER.

Add the public password to Github

  • Look and copy the public password:
cat id_rsa.pub

Image description

  • We go to Settings profile:
    Image description

  • Then we move to SSH and GPG keys:
    Image description

  • And we add a New SSH key by adding a Title, the use of that key (in our case Authentication key), and the public key generated from the public password (cat id_rsa.pub).
    Image description

    • Note: The key we use is the public one, from the id_rsa.pub, NOT the id_rsakey.

Adding an agent to hold the ssh key.

An agent holds the public and private key for authenticate into services, in our case GitHub.

  • Start the agent:
eval $(ssh-agent -s)

Image description

  • Add the password to the agent:
ssh-add ~/.ssh/id_rsa

Image description

Testing

Now in our session is validated to use push and clone our public and private repositories

Basic Test

git initgit add .
  • Then we add the SSH link from a GitHub Repository:
git remote add origin [email protected]:user/Repo_Name

Image description

  • We make our commit:
git commit -m "First Commit"

So when we do some git push -u origin master the authentication will be settled.


Original Link: https://dev.to/developemmanuel/set-up-ssh-for-github-in-the-terminal-25go

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To