Check existing SSH keys
- Open File Explorer.
- Access your Local Disk.
- Open the
Users
folder. - Open your profile folder.
- Open the
.ssh
folder.
You can also use Git Bash to check existing SSH keys. Run the following command:
ls -al ~/.ssh
If you do not find the .ssh
folder or do not see any files—like id_ed25519
and id_ed25519.pub
—you do not have any keys yet.
Generate your first SSH key
Follow these steps:
- Open Git Bash.
- Type the following command and type your GitHub email address:
ssh-keygen -t ed25519 -C "your_email@example.com"
- Press Enter when prompted the following:
> Enter file in which to save the key (/c/Users/YOU/.ssh/id_ed25519): [Press enter]
- To leave the passphrase empty for easy use, press Enter.
> Enter passphrase (empty for no passphrase): [Press Enter] > Enter same passphrase again: [Press Enter]
Connect your SSH key to your GitHub account
Follow these steps:
- Open Git Bash.
- Copy your SSH public key.
clip < ~/.ssh/id_ed25519.pub
- Open your browser.
- Open your SSH and GPG keys page.
- Add new SSH key.
- Fill the title input with Personal.
- Leave the Key type to be Authentication key.
- Paste your SSH public key in the Key text area.
- Add your new key.
- Type your GitHub's password.
To test whether you can connect your SSH key with GitHub, follow these steps:
- Open Git Bash.
- Run the following command:
ssh -T git@github.com
- After you run it, you get the following:
Hi USERNAME! You've successfully authenticated, but GitHub does not provide shell access.
Generate another SSH key
Follow these steps:
Open Git Bash.
Type the following command and type your GitHub email address:
ssh-keygen -t ed25519 -C "your_email@example.com"
Change the filename without any extension.
> Enter file in which to save the key (/c/Users/YOU/.ssh/id_ed25519): [Type custom filename]
To leave the passphrase empty for easy use, press Enter key:
> Enter passphrase (empty for no passphrase): [Press Enter] > Enter same passphrase again: [Press Enter]
Open File Explorer.
Go to
C:\Users\YOU\
.YOU
refers to your profile name.Find the custom filename you have typed before.
If your custom filename is
jack
, findjack
andjack.pub
.Copy both files to the
.ssh
folder.
Repeat the above steps to make as many SSH keys as you like.
Connect another SSH key
- Open Git Bash.
- Copy your new SSH public key.
clip < ~/.ssh/jack.pub
- Open your browser.
- Open your SSH and GPG keys page.
- Add new SSH key.
- Fill the title input with Work.
- Leave the Key type to be Authentication key.
- Paste your SSH public key in the Key text area.
- Add your new key.
- Type your GitHub's password.
To test whether you can connect your SSH key with GitHub, follow these steps:
- Open Git Bash.
- Run the following command:
Notice that this command refers to a specific SSH key.ssh -i ~/.ssh/jack -T git@github.com
- After you run it, you get the following:
Hi USERNAME! You've successfully authenticated, but GitHub does not provide shell access.
Connect the local Git repository to a specific SSH key
- Open a local Git repository.
- Run the following command:
Do not addgit config --local core.sshCommand "ssh -i ~/.ssh/CUSTOM_KEY"
.pub
.
You can do the same without using the Git command by using your text editor.
- Open File Explorer.
- Open a local Git repository.
- Open the
.git
folder inside your working directory. - Open the
config
file with Notepad. - Add
sshCommand= "ssh -i ~/.ssh/CUSTOM_KEY"
inside[core]
. - Save the file.
To test this, make local changes and push them to a remote repository.