Step 1: Generate the Key Pair in PuTTYgen
  1. Launch the PuTTYgen application on your local computer.
  2. Locate the Parameters section at the bottom of the window.
  3. Choose your key type; Ed25519 or RSA (minimum 2048 bits) are highly recommended.
  4. Click the Generate button.
  5. Move your mouse cursor randomly over the blank space to generate entropy until the progress bar fills.
Step 2: Save Your Keys
  1. Locate the Key passphrase and Confirm passphrase fields.
  2. Type a secure password to protect your private key file.
  3. Click Save private key.
  4. Save the file with a .ppk extension in a secure location on your local machine.
  5. Do not close the PuTTYgen window yet.
Step 3: Copy the OpenSSH Public Key
  1. Go to the text box at the top labeled “Public key for pasting into OpenSSH authorized_keys file”.
  2. Right-click inside that box and select Select All.
  3. Press Ctrl + C to copy the entire public key string.
Step 4: Install the Public Key on Ubuntu
Log into your Ubuntu server using your existing credentials and execute the following commands to register your new public key: [1]
  1. Create the SSH directory for your user if it does not exist:
    mkdir -p ~/.ssh
    
     
  2. Open or create the authorized_keys file using a text editor like Nano:
    nano ~/.ssh/authorized_keys
     
  3. Paste the copied public key string into the file (Ensure it stays on a single line).
  4. Save and exit the editor (Press Ctrl + O, Enter, then Ctrl + X).
  5. Restrict permissions on the directory and file to secure them (you must set to this any lax permissions and it wont load the key):
    chmod 700 ~/.ssh
    chmod 600 ~/.ssh/authorized_keys
    
Step 5: Connect Using PuTTY
  1. Open the main PuTTY application.
  2. Enter your Ubuntu server's IP address or hostname under Session.
  3. Navigate to Connection > SSH > Auth > Credentials in the left sidebar sidebar.
  4. Click Browse next to “Private key file for authentication”.
  5. Select the .ppk file you saved in Step 2.
  6. Return to Session, give it a name under Saved Sessions, and click Save.
  7. Click Open and enter your Ubuntu username and key passphrase to connect. 

 

Reference : Google Search