Skip to content
Home » Here is a tutorial on how to generate an SSH key:

Here is a tutorial on how to generate an SSH key:

Generating an SSH Key Pair

SSH keys allow you to establish a secure connection between two machines without using passwords. They are more secure and convenient than basic password authentication. Follow these steps to generate a public/private SSH key pair.

  1. Open the Terminal (Linux/Mac) or Git Bash (Windows).
  2. Type the following to generate a 4096-bit RSA key pair:
ssh-keygen -t rsa -b 4096
  1. You will be prompted to enter a file location and passphrase to protect the private key.
  2. Press Enter to accept the default location and leave the passphrase empty.
  3. The keys will be generated at ~/.ssh/id_rsa (private key) and ~/.ssh/id_rsa.pub (public key).
  4. To check the keys, type:
ls ~/.ssh

You should see the two new files.

  1. Print the public key contents with:
cat ~/.ssh/id_rsa.pub

This key can now be shared and installed on servers you want to access. The private key remains on your local machine.

  1. You can also generate keys with different names by specifying a -f option, e.g:
ssh-keygen -t rsa -b 4096 -f my_new_key

This will create my_new_key and my_new_key.pub.

That’s it! You’ve now generated an SSH key pair for stronger authentication. The private key should remain private, while the public key can be freely shared.

Tags: