PuTTY with OpenSSH

Hi!

Today we use OpenSSH and PuTTY to log in remote computers.

  • OpenSSH is an open-source version of the Secure Shell (SSH) tools used by administrators of remote systems
  • PuTTY is a free implementation of SSH

This blog is built on the following environment:

  • Host Machine: OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2, and PuTTY Release 0.78 on Windows 10 x64.
  • Virtual Machine (Server): CentOS 7 Minimal on VMware Player 17 (Intel-VT Virtualization: ON)

Generate Key Pair

SSH requires public/private key pair. The public key is stored on server to authenticate the user who has the corresponding private key. For simplicity, I will use PuTTY to generate public/private key pair:

  1. Open PUTTYGEN.EXE of PuTTY installation directory.
  2. Click "Generate" to generate public/private key pair
  3. Set Key passphase and Confirm the passphase.
  4. Click "Save private key", and export to a putty_private_key.ppk file
  5. Copy the content of "Public key for pasting into OpenSSH authorized_keys file" (begin with ssh-rsa ...), and paste it in server file (~/.ssh/authorized_keys of CentOS 7).
  6. Open PUTTY.EXE of PuTTY installation directory
  7. In the left menu, unfold category to find Connection/SSH/Auth/Credentials, and "Browse" to find putty_private_key.ppk
  8. In the left menu, click Session, type in the IP address and "Save" this session with a name, like "CentOS7_VM"

Config Server

If we want to log in without password, we will config the server:

  1. (Optional) Allow SSH login as root: (find the following item and change its property in /etc/ssh/sshd_config to yes)
    1PermitRootLogin yes
    
  2. Ensure the Public key authentication is enabled: (find the following items and change their properties in /etc/ssh/sshd_config to yes)
    1RSAAuthentication yes
    2PubkeyAuthentication yes
    
  3. Restrict to use the authorized public keys only: (to disallow password, find the following item and change its property in /etc/ssh/sshd_config to no)
    1PasswordAuthentication no
    
  4. Restart SSH service to validate changes: (in terminal)
    1$ service sshd restart
    

Connect

Open PUTTY.EXE, "Load" the saved session called CentOS7_VM, and "Open"

1login as: <Your User Name>
2Authenticating with public key "rsa-key-YYYYMMDD"
3Passphrase for key "rsa-key-YYYYMMDD": <Your Passphrase For private key>

So now we can log in with no passwords in transmission.

However, if you do not want to protect the private key (putty_private_key.ppk) with passphrase at all, you can load your private key with PUTTYGEN.EXE and then override the private key with no passphrase. (Highly unrecommended)


* This blog was last updated on 2023-06-17 22:08