Searching...

Generating an SSH Key Pair in Windows, MAC, Linux

SSH is a network protocol that ensures the security of data transmission and verifies your identity using public key cryptography.

You need to create a key pair - a private key, which will be stored on your computer, and a public key that the server will use. Both keys must be stored on your computer. If you provide your SSH key to others (web hosting, server, etc.), you must provide your public SSH key. The public key is a text string that starts with ssh-rsa, ends with your email address, and has a long string in the middle.

Example:

ssh-rsa AAAAB3NzaC1yc2EAAAADRDSEFDVABAQCXsM9ycbHV6E6t2L+B4p/uYHn9Q0jmu5gU XMYnFnnf4l39xrznfDo8KCASzRrqUkRnuzrno059CvZVzcljkbwWLzKKoE1EwbzH L3nYahMB4MdYNWhBbHbB+ybq6RNO7hkoKDBIQCfqQDY0FEB6sV3d3F1WYl0bAMjp 15yyZJzMKa/rRnZKWetHlcL1X+gFWmW2hQ93foPD463gb58/25GujjsS/tzjngw7 UJMVkm08U1QEY3z3DE/R++7ovJozTCzH0CTNDN0AH3/oSC3dmG+yDh3ZXFATjWjy PXJSOziNrp9TXgJhlqSmoHcPvpotMVjx21kIZ+T+SusQmnG+hK+L user@yourdomain.comNote: The key must not contain line breaks.

Creating an SSH Key Pair on a Windows Computer:

  1. Download the PuTTYgen.exe program and run it.
  2. In the Parameters section at the bottom of the window, select the RSA option.
  3. Click the Generate button.
  4. Follow the instructions to move the mouse in the empty field until PuTTYgen generates a key pair. When PuTTYgen generates the key, a series of text fields will appear in the empty area. One of these fields is the public key.
  5. In the Key comment field, add your email address. Append this address to any text already in this field. Do not modify other text fields.
  6. Click the Save public key button to save the public key to a file named id-rsa in the C:\Documents and Settings\user.ssh folder, where "user" is your Windows username.
  7. Click the Save private key button to save the private key to a file named id-rsa.ppk in the same folder.
  8. Copy the contents of the Public key for pasting into OpenSSH authorized_keys file text field to the clipboard. Make sure to copy the entire content, starting with the ssh-rsa string and ending with your email address as entered in step 5.
  9. Close the PuTTYgen program.
  10. Paste the copied public key into a text editor, remove line break characters, and copy the entire text to the clipboard.
  11. You can now use this generated key wherever needed.

Creating an SSH Key Pair on a Macintosh or Linux Computer:

  1. Open a terminal window.
  2. Enter the command: ssh-keygen -t rsa
  3. Choose the default values for all options. This command will generate two SSH key files (id_rsa and id_rsa.pub) in the home/user/.ssh directory, where "user" is your username.
  4. You can now use the id_rsa.pub file with the public key wherever needed.

Comments

To submit comment you have to be logged-in