Home / How to setup password-less SSH between Windows Clients and CentOS, AlmaLinux servers

How to setup password-less SSH between Windows Clients and CentOS, AlmaLinux servers

Method 1: Create pub/private keys on Windows Clients and copy the public key to Linux Server

  • On a Windows machine, open Putty Key Generator. Click Generate to create public and private keys (set passphrase if preferred).
  • Copy the content of the public key, and paste it to the ~/.ssh/authorized_keys file on AlmaLinux/CentOS ssh server.
  • Confirm that the file permission is 644.
  • Again on Putty Key Generator, click Save private key.
  • Next, name the key file and save it as .ppk.
  • Save the public key in .txt format.
  • Open putty configuration box.
  • Select Connection > SSH > Auth.
  • Click Browse and select the saved .ppk key file in the Private key file for authentication.
  • Select Session in the putty configuration box.
  • Enter hostname in HostName, and enter preferred session name in Saved Sessions, click Save.
  • Select the saved session name, click Load, then click Open.
  • An SSH session is opened without a password requirement (only prompting to enter passphrase if set in step 1).

Method 2: Create pub/private keys on Linux Server and copy the private key to Windows Client

  • Establish ssh connection to the AlmaLinux ssh server from the Windows ssh client through putty using a password.
  • On the terminal of the AlmaLinux ssh server, run the following commands to create public/private keys and copy the public key to the authorized keys file as follows:

ssh-keygen -t rsa
cat .ssh/id_rsa.pub >> .ssh/authorized_keys

  • Copy the content of the private key, .ssh/id_rsa, to text editor/notepad on Windows.
  • Save the copied text with .pem format with Encoding as “ANSI”.
  • On Windows, open Putty Key Generator. Click Load, and select the saved .pem file from the above step.
  •  By opening the .pem file, it is automatically converted to ppk (private key) format. (If the passphrase is set when generating the key pair, it is prompted to enter the passphrase here. So enter the passphrase, click OK.)
  • A message confirming the import was successful is displayed. Click OK.
  • Click Save private key.
  • Save the key file in .ppk format by clicking Save.
  • Open putty configuration box.
  • Select Connection > SSH > Auth.
  • Click Browse and select the saved .ppk key file in the Private key file for authentication.
  • Select Session in the putty configuration box.
  • Enter hostname in HostName, and enter preferred session name in Saved Sessions, click Save.
  • Select the saved session name, click Load, then click Open.
  • SSH session is opened without password (prompted to enter passphrase if passphrase was set).

Leave a Reply