SSHD - how to setup authentication by key

By kimot, 27 December, 2022

First you will need key pair. You can use PuttyGen to generate this keys

Putty generator

If you fill fields Key passphrase / Confirm passphrase - you will be prompted for a password each time you use the key.
Use "Save private key" to save key on your computer.

In your home directory on LPAR you have to have file to store public keys /home/$USER/.ssh/authorized_keys
directories/file must have setup this permissions :

chmod g-w /home/$USER
chmod 700 /home/$USER/.ssh
chmod 600 /home/$USER/.ssh/authorized_keys

open "authorized_keys" file and add key string from Putty Key Generator field Public Key (1)

Last step is to add path to your Private Key in Putty session settings and save session

Private key

Login to LPAR's SSH should look like this (if you have set a passphrase)

Login

If SSH refuse you to login you can check ssh config file for AuthorizedKeysFile parameter
/QOpenSys/QIBM/UserData/SC1/OpenSSH/etc/sshd_config :
#RSAAuthentication yes
#PubkeyAuthentication yes
AuthorizedKeysFile    .ssh/authorized_keys

 

If your SSH terminal refuse your Key and writes "Server refused our key" you should setup/run logging and examine the log.