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
$ ssh-keygen -t ed25519 -C "your_email@example.com"
# start the ssh-agent in the background
$ eval "$(ssh-agent -s)"
> Agent pid 59566
ssh-add ~/.ssh/id_ed25519
clip < ~/.ssh/id_ed25519.pub
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
github.com ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCj7ndNxQowgcQnjshcLrqPEiiphnt+VTTvDP6mHBL9j1aNUkY4Ue1gvwnGLVlOhGeYrnZaMgRK6+PKCUXaDbC7qtbW8gIkhL7aGCsOr/C56SJMy/BCZfxd1nWzAOxSDPgVsmerOBYfNqltV9/hWCqBywINIR+5dIg6JTJ72pcEpEjcYgXkE2YEFXV1JHnsKgbLWNlhScqb2UmyRkQyytRLtL+38TGxkxCflmO+5Z8CSSNY7GidjMIZ7Q4zMjA2n1nGrlTDkzwDCsw+wqFPGQA179cnfGWOWRVruj16z6XyvxvjJwbz0wQZ75XK5tKSb7FNyeIEs4TT4jk+S4dhPeAUC5y+bDYirYgM4GC7uEnztnZyaVWQ7B381AK4Qdrwt51ZqExKbQpTUNn+EjqoTwvqNj4kqx5QUCI0ThS/YkOxJCXmPUWZbhjpCg56i+2aB6CmK2JGhn57K5mj0MNdBXA4/WnwH6XoPWJzK5Nyu2zB3nAZp+S5hpQs+p1vN1/wsjk=
xxxxxxxxxx
SSH stands for Secure Shell.
When working with a GitHub repository,
you'll often need to introduce yourself to
GitHub using your username and password.
SSH key is an alternate way to identify yourself
that doesn't require you to enter you username and password every time.
SSH keys come in pairs, a public key that
gets shared with services like GitHub,
and a private key that is stored only on
your computer. If the keys match, you're granted access.