An Interest In:
Web News this Week
- March 6, 2024
- March 5, 2024
- March 4, 2024
- March 3, 2024
- March 2, 2024
- March 1, 2024
- February 29, 2024
September 17, 2022 07:49 pm GMT
Verify the existence of the directory
Creating the
Adding an
Original Link: https://dev.to/developemmanuel/set-up-ssh-for-github-in-the-terminal-25go
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 directorycd ~/.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 pressENTER
again.- If we don't want to, we just left it empty and press
ENTER
.
- If we don't want to, we just left it empty and press
Add the public password to Github
- Look and copy the public password:
cat id_rsa.pub
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
).- Note: The key we use is the public one, from the
id_rsa.pub
, NOT theid_rsa
key.
- Note: The key we use is the public one, from the
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)
- Add the password to the agent:
ssh-add ~/.ssh/id_rsa
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
- 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:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To