Generate an SSH Key Pair (2024)

To access your Compute instances using SSH, generate an SSH key pair, associate the public key with your instances, and use the private key to log in to the instances using SSH.

Caution:

Keep your SSH keys secure. Lay down policies to ensure that the keys aren’t lost or compromised when employees leave the organization or move to other departments. If you lose your private key, then you can’t access your instances. For business continuity, ensure that the SSH keys of at least two IT system administrators are added to your instances.

Generate an SSH Key Pair on UNIX and UNIX-Like Systems

Use the following procedure to generate an SSH key pair on UNIX and UNIX-like systems:

  1. Run the ssh-keygen command.

    You can use the -t option to specify the type of key to create.

    For example, to create an RSA key, run:

    ssh-keygen -t rsa

    You can use the -b option to specify the length (bit size) of the key, as shown in the following example:

    ssh-keygen -b 2048 -t rsa
  2. The command prompts you to enter the path to the file in which you want to save the key.

    A default path and file name are suggested in parentheses. For example: /home/user_name/.ssh/id_rsa. To accept the default path and file name, press Enter. Otherwise, enter the required path and file name, and then press Enter.

  3. The command prompts you to enter a passphrase.

    The passphrase is not mandatory if you want to log in to an instance created using an Oracle-provided image. However, it is recommended that you specify a passphrase to protect your private key against unauthorized use.

    Note:

    With some images provided on Oracle Marketplace, the use of a passphrase might be mandatory.

  4. When prompted, enter the passphrase again to confirm it.

The command generates an SSH key pair consisting of a public key and a private key, and saves them in the specified path. The file name of the public key is created automatically by appending .pub to the name of the private key file. For example, if the file name of the SSH private key is id_rsa, the file name of the public key would be id_rsa.pub.

Make a note of the path and file names of the private and public keys. When you create an instance, you must specify the SSH public key value. When you log in to an instance, you must provide the path to the corresponding SSH private key and you must enter the passphrase when prompted.

Generate an SSH Key Pair on Windows

You can generate an SSH key pair on a Microsoft Windows machine by using an application such as PuTTY. See the tutorial, Creating SSH Keys for Use with Oracle Cloud Services.

Generate an SSH Key Pair (2024)

FAQs

How to generate SSH key pairs? ›

Generate an SSH Key Pair
  1. Run the ssh-keygen command. You can use the -t option to specify the type of key to create. ...
  2. The command prompts you to enter the path to the file in which you want to save the key. ...
  3. The command prompts you to enter a passphrase. ...
  4. When prompted, enter the passphrase again to confirm it.

How do I manually generate SSH keys? ›

For Windows 10 & 11
  1. Press the Windows key or open up the Start Menu. Type “cmd”.
  2. Under “Best Match”, click “Command Prompt”.
  3. In the command prompt, use the ssh-keygen command: ...
  4. The system will now generate the key pair and display the key fingerprint and a randomart image. ...
  5. Open your file explorer.

Is ED25519 better than RSA 4096? ›

ED25519 is generally considered more secure and efficient than RSA, while RSA provides a higher level of security due to its larger key size. The choice between these two algorithms depends on the specific application and the level of security and efficiency required.

How to generate ED25519 key pair SSH? ›

Generate a key pair with OpenSSH
  1. Open a terminal/shell. On macOS: A terminal app is already part of the OS by default. ...
  2. Generate key pair. To generate a key pair with OpenSSH, type the following command: ssh-keygen -t ed25519 -C "your_comment_see_below" ...
  3. Select where to store the key pair. ...
  4. Secure the private key.

What are SSH key pairs? ›

SSH keys are a pair of public and private keys that are used to authenticate and establish an encrypted communication channel between a client and a remote machine over the internet.

How to check SSH key pairs? ›

Procedure
  1. Log in the server as 'root' using SSH, or use the WHM: Terminal feature.
  2. Change into the /root/. ssh/ directory on the server. ...
  3. Use the command 'ls -al' to list all files in the directory, and locate your private/public keypair you wish to check. ...
  4. Use the following command, to test both files. ...
  5. That's it.
Oct 31, 2021

How do I generate a modern SSH key? ›

You can generate keys with the 'ssh-keygen' command: $ ssh-keygen -t ed25519 Generating public/private ed25519 key pair. Enter file in which to save the key ($HOME/. ssh/id_ed25519): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in $HOME/.

How to generate key pair in Linux? ›

Procedure
  1. In a terminal, run the ssh-keygen command.
  2. Generate the public/private RSA key pair.
  3. Specify the directory in which to save the key pair. For example, /Users/mymac/. ssh/id_rsa... mysftpkey.
  4. Enter the passphrase. Then, enter the same passphrase again. Enter empty if you don't want to use a passphrase.

How to generate SSH key from command prompt? ›

Creating SSH Keys (Command Line)
  1. Create a .ssh in your home directory. Create a .ssh folder in your user account's home directory if it does not exist: $ mkdir /home/username/.ssh. ...
  2. Run ssh-keygen to generate an SSH key-pair. ...
  3. Retrieve the public key file. ...
  4. Start a transfer using public key authentication with the ascp command.

What is the weakness of Ed25519? ›

The discovered weakness relates some implementations setting up pre-computed public keys, and which speeds up their operation. Thus, when a user signs for a transaction, we would normally access the private key twice: to sign the transaction; and to generate the public key.

What is the best practice for SSH keys? ›

It should never be shared or transmitted over insecure networks. Consider encrypting private keys with a passphrase for additional security. Rotate SSH keys. Just like passwords, SSH keys should be changed or rotated regularly to reduce the risk of a key being used maliciously if it's compromised and unnoticed.

What algorithm should I use for ssh-keygen? ›

ssh-keygen defaults to RSA therefore there is no need to specify it with the -t option. It provides the best compatibility of all algorithms but requires the key size to be larger to provide sufficient security. Minimum key size is 1024 bits, default is 3072 (see ssh-keygen(1)) and maximum is 16384.

Which is better, RSA or ED25519? ›

Compared to traditional RSA keys, Ed25519 key generation is significantly faster. This advantage is especially valuable when dealing with systems that require frequent key generation, such as in large-scale infrastructure setups or automated processes.

What is the secret key of ED25519? ›

Ed25519 keypair consists of a secret key (a random 32 byte number, sometimes called seed or private key ) and a public key . When signing a message though, the secret key is expanded (involves hashing and bit clamping) into an expanded secret key which consists of a secret scalar and a nonce .

How to generate second SSH key? ›

Setting up multiple SSH keys on one computer
  1. Step 1: Navigate to the right location. All of your SSH keys need to be stored in ~/.ssh , so navigate there using: ...
  2. Step 2: Create the SSH keys. ...
  3. Step 3: Create a config file. ...
  4. Step 4: Add keys to your accounts. ...
  5. Step 5: “Too Open” Error. ...
  6. Step 6: Clone your repo with the correct host.
Mar 6, 2022

How to generate SSH key pair putty? ›

Generating SSH key pairs locally
  1. Download PuTTYgen (available here) and run the executable.
  2. Click on the Generate button and follow on-screen instructions.
  3. Create and confirm a Key passphrase.
  4. Save public and private keys. Saving the public key with the extension . ...
  5. Upload the public key file.

How to generate SSH key pair on EC2? ›

Step 1: Create EC2 SSH Key Pair
  1. In your AWS Management Console, choose an AWS Region in which you plan to reserve contacts. You need to create a key pair for every AWS Region you choose. Note. ...
  2. Follow the guide Create Key Pairs in the Amazon EC2 User Guide to create the key pairs.
  3. Repeat for other AWS Regions if needed.

How do I generate an SSH 2 RSA key? ›

Generating an SSH key
  1. Open the PuTTYgen program.
  2. For Type of key to generate, select SSH-2 RSA.
  3. Click the Generate button.
  4. Move your mouse in the area below the progress bar. ...
  5. Type a passphrase in the Key passphrase field. ...
  6. Click the Save private key button to save the private key.
Nov 9, 2022

How to generate SSH key pair for SFTP? ›

Users can generate their own SSH keys by logging in with their username and password, selecting their username at the top right of the page, selecting My account > SFTP keys > Add SFTP key, selecting the Generate in browser option, then selecting Generate key pair.

Top Articles
Latest Posts
Article information

Author: Rev. Leonie Wyman

Last Updated:

Views: 6359

Rating: 4.9 / 5 (79 voted)

Reviews: 94% of readers found this page helpful

Author information

Name: Rev. Leonie Wyman

Birthday: 1993-07-01

Address: Suite 763 6272 Lang Bypass, New Xochitlport, VT 72704-3308

Phone: +22014484519944

Job: Banking Officer

Hobby: Sailing, Gaming, Basketball, Calligraphy, Mycology, Astronomy, Juggling

Introduction: My name is Rev. Leonie Wyman, I am a colorful, tasty, splendid, fair, witty, gorgeous, splendid person who loves writing and wants to share my knowledge and understanding with you.