1. ssh-keygen -o -t rsa -C "your_email@example.com"
2. Press return for each option
3. cat ~/.ssh/id_rsa.pub
4. Copy the entire cat's output on "Settings - SSH and GPG keys - New SSH key" on GitHub
# 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
To add a default ssh key tied to Windows from cmd for git: $ is things you type, > is output
$ ssh-keygen
> Generating public/private rsa key pair.
> Enter file in which to save the key (/c/Users/emmap1/.ssh/id_rsa): [Enter for default]
> Created directory '/c/Users/emmap1/.ssh'.
$ Enter passphrase (empty for no passphrase): [password]
$ Enter same passphrase again: [password]
> Your identification has been saved in /c/Users/emmap1/.ssh/id_rsa.
> Your public key has been saved in /c/Users/emmap1/.ssh/id_rsa.pub.
> The key fingerprint is: e7:94:d1:a3:02:ee:38:6e:a4:5e:26:a3:a9:f4:95:d4 emmap1@EMMA-PC
If you want to avoid typing in your password each time:
$ start-ssh-agent
> Removing old ssh-agent sockets
> Starting ssh-agent: done
$ Enter passphrase for /c/Users/user/.ssh/id_rsa: [password]
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.