How to generate SSH key?

To generate an SSH key in Windows you will need an additional application. In case of Linux or MacOS, the appropriate tool is already available.

Please remember to transfer only the public key. The private key should not be transferred to third parties.

Generating SSH keys on Windows

The generation of SSH keys in Windows will be done by using Puttygen application.

  1. Download the puttygen.exe application and run it. In the window that appears, press the "Generate" button.
    Generating SSH keys - Putty - step 1
  2. Application will ask us to move the mouse cursor, within the window to generate random data for key generation.
  3. 3. After the key generation is completed, the window should look like this.
    Generating SSH keys - Putty - step 2
    • Public key for pasting into OpenSSH authorized_keys file - field where the public key for copying in OpenSSH format will appear (default for use on our servers),
    • Key passphrase, Confirm passphrase - type and confirm the password to our key (longer is better!),
    • Save public key, Save private key - buttons for saving public and private keys to separate files in .ppk format (application file format).

Generating SSH keys on Linux system

  1. Open the terminal and then enter command: ssh-keygen.
  2. When you are asked to enter a password (the Enter passphrase line), we recommend providing it, because it increases security.
    #ssh-keygen Generating public/private rsa key pair.
    Enter file in which to save the key (/home/myuser/.ssh/id_rsa):
    Enter passphrase (empty for no passphrase):
    Enter same passphrase again: Your identification has been saved in /home/myuser/.ssh/id_rsa.
    Your public key has been saved in /home/myuser/.ssh/id_rsa.pub.
    The key fingerprint is:
    43:c5:5b:5f:b1:f1:50:43:ad:20:a6:92:6a:1f:9a:3a
  3. After these commands are executed, the following files will appear in the ~/.ssh directory:
    • id_rsa – this is our private key. It cannot be lost or passed on to anyone,
    • id_rsa.pub – this is our public key. The contents of this file should be placed on server in ~/.ssh/authorized_keys, Or give it to the person who will do it for us.

Both keys will be available in the ~/.ssh/ directory.

Generating SSH keys on MacOS system

  1. Open the terminal and then enter command: ssh-keygen.
  2. When you are asked to enter a password (the Enter passphrase line), we recommend providing it, because it increases security.
    #ssh-keygen Generating public/private rsa key pair.
    Enter file in which to save the key (/Users/myuser/.ssh/id_rsa):

    Enter passphrase (empty for no passphrase):

    Enter same passphrase again:

    Your identification has been saved in /Users/myuser/.ssh/id_rsa.

    Your public key has been saved in /Users/myuser/.ssh/id_rsa.pub.
    The key fingerprint is:
    43:c5:5b:5f:b1:f1:50:43:ad:20:a6:92:6a:1f:9a:3a
  3. After these commands are executed, the following files will appear in the .ssh directory:
    • id_rsa – this is our private key. It cannot be lost or passed on to anyone,
    • id_rsa.pub – this is our public key. The contents of this file should be placed on server in ~/.ssh/authorized_keys, Or give it to the person who will do it for us.

Both keys will be available in the ~/.ssh/ directory.

  • linux, windows, ssh, puttygen, klucz prywatny, klucz publiczny, macos, private key, public key, ssh key, klucze ssh
  • 22 Users Found This Useful
Was this answer helpful?

Related Articles

How to add a task to Cron on the server?

Adding Cron to a server is not a difficult task, even though it requires using a terminal and...

How to set SSH tunel

Setting up SSH tunnel is an effective solution, for example, if you want to log into the remote...

How to add an SSH key on the server?

In order to allow other users to log in to your server, you need to add the public SSH keys of...

How do I log in to server with FileZilla?

Not everyone needs/can use the SSH connection and there is nothing wrong with it. But how to...

Configuration of backup space

Please note that usernames u00000 and u00000-sub1 are examples only. Please replace them with the...