xxxxxxxxxx
$ sudo -s -H
$ eval "$(ssh-agent -s)"
> Agent pid 59566
xxxxxxxxxx
# 1/ check for previous keys (should not exists before the first time)
cd ~/.ssh #check for already existing pair of id_x and id_x.pub (id_rsa/id_edxxx/ )
# 2/ generate keys (if you dont have any) - pick one
#rsa
ssh-keygen -o
#ed algorithm (recommended)
ssh-keygen -t ed25519 -C you@mail.com
# 3/ add the key to the shh-agent
eval "$(ssh-agent -s)" #if the agent is running, it should return something like Agent pid 18544
sh-add ~/.ssh/id_ed25519 #or: ssh-add ~/.ssh/id_rsa
# 4/ copy the public key
cat ~/.ssh/id_ed25519.pub #or: cat ~/.ssh/id_rsa.pub
# copy all: ssh-ed25510...... you@mail.com or ssh-rsa....... you@mail.com
# 5/ past it to the github
# login - profile prefferences - ssh and gpg keys - new SSH key and paste 4/
# 6/ verify
ssh -v git@github.com
# if you got the following error:
# The authenticity of host 'github.com (ip)' can't be established.
# execute the following command and try again:
ssh-keyscan github.com >> ~/.ssh/known_hosts
xxxxxxxxxx
# Generating an ssh-keygen
# Change directory to the ssh directory
cd ~/.ssh
# Create SSH Key
ssh-keygen -o -t rsa -C "email@email.com"
# Add SSH Key (not the .pub file) to SSH Agent
eval `ssh-agent -s`
ssh-agent -s
ssh-add ~/.ssh/filename
# Create SSH Config file (~/.ssh/config)
"""
# Personal GitHub
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/personal_rsa
# Non-Personal GitHub
Host nonpersonal.github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/nonpersonal_rsa
"""
# ssh-add
ssh-add -l
# test
ssh -T git@github.com
ssh -T git@nonpersonal.github.com
# Copy the contents of the ssh key public file (.pub file) to clipboard
# (WSL2 Specific)
cat filename.pub | clip.exe
# Go to "https://github.com/settings/keys"
# Click New SSH Key
# Paste the contents of the public file to Key
# Click Add SSH Key
# Go to the repository of the project you want to clone
# Select the SSH Link and copy it to the clipboard
# Then clone the repo
git clone git@github.com:SOME_ORGANIZATION/SOME_PROJECT.git
xxxxxxxxxx
# start the ssh-agent in the background
$ eval "$(ssh-agent -s)"
> Agent pid 59566