Generate Putty Key Command Line

Instances launched using Oracle Linux, CentOS, or Ubuntu images use an SSH key pair instead of a password to authenticate a remote user (see Security Credentials). A key pair consists of a private key and public key. You keep the private key on your computer and provide the public key every time you launch an instance.

Generate

When you connect to an instance using SSH, you provide the path to the key pair file in the SSH command. You can have as many key pairs as you want, or you can keep it simple and use one key pair for all or several of your instances.

To generate the public/private key pair, enter this in the Command Prompt: ssh-keygen At the first prompt, “Enter file in which to save the key,” press Enter to save it in the default location.

  1. To use the system command-line interface, you must generate a Secure Shell (SSH) key pair using PuTTY. Generating an SSH key pair using PuTTY To use the system command-line interface, you must generate a Secure Shell (SSH) key pair using PuTTY.
  2. Sudo apt install putty-tools. Generate Key Pair for Authentication in Linux. To create the key pair for authentication in Linux use the below command:-puttygen -t rsa -b 2048 -C 'user@host' -o keyfile.ppk. Various Command Line Options of PuTTY in Linux. Below are few important command line options in the Linux operating system for PuTTY.
Putty

To create key pairs, you can use a third-party tool such as OpenSSH on UNIX-style systems (including Linux, Solaris, BSD, and OS X) or PuTTY Key Generator on Windows.

Prerequisites

Putty Command Line Serial

If you're using a UNIX-style system, you probably already have the ssh-keygen utility installed. To determine if it's installed, type ssh-keygen on the command line. If it's not installed, you can download OpenSSH for UNIX from http://www.openssh.com/portable.html and install it.

If you're using a Windows operating system you will need PuTTY and the PuTTY Key Generator. Download PuTTY and PuTTYgen from http://www.putty.org and install them.

Creating an SSH Key Pair on the Command Line

  1. Open a shell or terminal for entering the commands.
  2. At the prompt, enter ssh-keygen and provide a name and passphrase when prompted.

    The keys will be created with the default values: RSA keys of 2048 bits.

Alternatively, you can type a complete ssh-keygen command, for example:

The command arguments are shown in the following table:

ArgumentDescription
-t rsaUse the RSA algorithm.
-N '<passphrase>'

/import-private-key-to-generate-csr.html. A passphrase to protect the use of the key (like a password). If you don't want to set a passphrase, don't enter anything between the quotes.

A passphrase is not required. You can specify one as a security measure to protect the private key from unauthorized use.

-b 2048

Generate a 2048-bit key. You don't have to set this if 2048 is acceptable, as 2048 is the default.

A minimum of 2048 bits is recommended for SSH-2 RSA.

-C '<key_name>'A name to identify the key.
-f <path/root_name>The location where the key pair will be saved and the root name for the files.

Putty Generate Ssh Key

Creating an SSH Key Pair Using PuTTY Key Generator

  1. Find puttygen.exe in the PuTTY folder on your computer, for example, C:Program Files (x86)PuTTY. Double-click puttygen.exe to open it.
  2. Specify a key type of SSH-2 RSA and a key size of 2048 bits:

    • In the Key menu, confirm that the default value of SSH-2 RSA key is selected.
    • For the Type of key to generate, accept the default key type of RSA.
    • Set the Number of bits in a generated key to 2048 if it is not already set.
  3. Click Generate.
  4. Move your mouse around the blank area in the PuTTY window to generate random data in the key.

    When the key is generated, it appears under Public key for pasting into OpenSSH authorized_keys file.

  5. A Key comment is generated for you, including the date and time stamp. You can keep the default comment or replace it with your own more descriptive comment.
  6. Leave the Key passphrase field blank.
  7. Click Save private key, and then click Yes in the prompt about saving the key without a passphrase.

    The key pair is saved in the PuTTY Private Key (PPK) format, which is a proprietary format that works only with the PuTTY tool set.

    You can name the key anything you want, but use the ppk file extension. For example, mykey.ppk.

  8. Select all of the generated key that appears under Public key for pasting into OpenSSH authorized_keys file, copy it using Ctrl + C, paste it into a text file, and then save the file in the same location as the private key.

    (Do not use Save public key because it does not save the key in the OpenSSH format.)

    You can name the key anything you want, but for consistency, use the same name as the private key and a file extension of pub. For example, mykey.pub.

  9. Write down the names and location of your public and private key files. You will need the public key when launching an instance. You will need the private key to access the instance via SSH.

Now that you have a key pair, you're ready to launch instances as described in Creating an Instance.

The PuTTYgen program is part of PuTTY, an open source networking client for the Windows platform.

To generate an SSH key pair on Windows using the PuTTYgen program:
  1. Download and install PuTTY or PuTTYgen.

    To download PuTTY or PuTTYgen, go to http://www.putty.org/ and click the You can download PuTTY here link.

  2. Run the PuTTYgen program.
  3. Set the Type of key to generate option to SSH-2 RSA.
  4. In the Number of bits in a generated key box, enter 2048.
  5. Click Generate to generate a public/private key pair.

    As the key is being generated, move the mouse around the blank area as directed.

  6. (Optional) Enter a passphrase for the private key in the Key passphrase box and reenter it in the Confirm passphrase box.

    Note:

    While a passphrase is not required, you should specify one as a security measure to protect the private key from unauthorized use. When you specify a passphrase, a user must enter the passphrase every time the private key is used.

  7. Click Save private key to save the private key to a file. To adhere to file-naming conventions, you should give the private key file an extension of .ppk (PuTTY private key).

    Note:

    The .ppk file extension indicates that the private key is in PuTTY's proprietary format. You must use a key of this format when using PuTTY as your SSH client. It cannot be used with other SSH client tools. Refer to the PuTTY documentation to convert a private key in this format to a different format.
  8. Select all of the characters in the Public key for pasting into OpenSSH authorized_keys file box.

    Make sure you select all the characters, not just the ones you can see in the narrow window. If a scroll bar is next to the characters, you aren't seeing all the characters.

  9. Right-click somewhere in the selected text and select Copy from the menu.
  10. Open a text editor and paste the characters, just as you copied them. Start at the first character in the text editor, and do not insert any line breaks.
  11. Save the text file in the same folder where you saved the private key, using the .pub extension to indicate that the file contains a public key.
  12. If you or others are going to use an SSH client that requires the OpenSSH format for private keys (such as the ssh utility on Linux), export the private key:
    1. On the Conversions menu, choose Export OpenSSH key.
    2. Save the private key in OpenSSH format in the same folder where you saved the private key in .ppk format, using an extension such as .openssh to indicate the file's content.