DEV Community

Pizofreude
Pizofreude

Posted on • Updated on

Generate SSH key pair on Git Bash in 2 Steps

Step 1

Generate a new SSH key pair by running the following command in Git Bash:

ssh-keygen -t rsa -b 4096
Enter fullscreen mode Exit fullscreen mode

This will prompt you to enter a file to save the key to. You can accept the default file location by pressing Enter, or specify a different location by entering the file path and name.

The default directory for saving the SSH key pair when using the ssh-keygen command is ~/.ssh/.

The ~ represents your home directory, and the .ssh subdirectory is where SSH keys are typically stored. So, the default location for saving the SSH key pair would be ~/.ssh/id_rsa for the private key, and ~/.ssh/id_rsa.pub for the public key.

If you do not specify a different location when prompted, the key pair will be saved to these default locations. You can also specify a different location by entering the desired file path and name at the prompt.

Step 2

You will be prompted to enter a passphrase for your SSH key. This is an optional security measure that can help protect your key. You can either enter a passphrase or leave it blank by pressing Enter.

Once the key has been generated, you can view it by running the following command:

cat ~/.ssh/id_rsa.pub
Enter fullscreen mode Exit fullscreen mode

This will display the contents of your public SSH key.

Top comments (0)