Step 1: Generate the Key Pair in PuTTYgen
- Launch the PuTTYgen application on your local computer.
- Locate the Parameters section at the bottom of the window.
- Choose your key type; Ed25519 or RSA (minimum 2048 bits) are highly recommended.
- Click the Generate button.
- Move your mouse cursor randomly over the blank space to generate entropy until the progress bar fills.
Step 2: Save Your Keys
- Locate the Key passphrase and Confirm passphrase fields.
- Type a secure password to protect your private key file.
- Click Save private key.
- Save the file with a
.ppkextension in a secure location on your local machine. - Do not close the PuTTYgen window yet.
Step 3: Copy the OpenSSH Public Key
- Go to the text box at the top labeled “Public key for pasting into OpenSSH authorized_keys file”.
- Right-click inside that box and select Select All.
- Press
Ctrl + Cto 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]
- Create the SSH directory for your user if it does not exist:
mkdir -p ~/.ssh - Open or create the
authorized_keysfile using a text editor like Nano:nano ~/.ssh/authorized_keys - Paste the copied public key string into the file (Ensure it stays on a single line).
- Save and exit the editor (Press
Ctrl + O,Enter, thenCtrl + X). - 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
- Open the main PuTTY application.
- Enter your Ubuntu server's IP address or hostname under Session.
- Navigate to Connection > SSH > Auth > Credentials in the left sidebar sidebar.
- Click Browse next to “Private key file for authentication”.
- Select the
.ppkfile you saved in Step 2. - Return to Session, give it a name under Saved Sessions, and click Save.
- Click Open and enter your Ubuntu username and key passphrase to connect.
Reference : Google Search