This guide was created so that you can log into your server securely without using a password. Instead, it uses a key that has been generated previously.
Key Generation Process
To create the key we need Puttygen or puttygen.exe (download here).
Then click Generate.
Then move your mouse on the Putty key generator box that has been provided. Keep moving until the key generation process is complete.
When finished, the public key will be created automatically. Then we save the text by clicking Save Public Key and Save Private Key. Don't close first.
For naming public keys, the file suffix uses .pub while for private keys, the file suffix uses .ppk.
Now the key generation process is complete.
Key Setting Process on Server
Next is to set the key on the server. In this process you must log into the server first, make sure to log in as root.
Then copy the text highlighted in blue on the previous Puttygen.
$ mkdir .ssh
$ echo "----paste-dari-puttygen.exe-diatas----" > .ssh/authorized.keys
An example would be the following.
The key setting process on the server is complete.
Process of Enabling SSH Login Using Key Only
In this process we will enable login to ssh using the key only. As additional information, the public key and private key files must be carefully guarded and do not lose or corrupt the file.
Kita ke pengaturan SSH di /etc/ssh/ssh_config
Then add the last 3 lines below:
Then restart the sshd
systemctl restart ssh
systemctl restart sshd
Login Process Using Key
To login using your putty setup key as follows.
Enter the host name or IP address of the server along with your server port.
Then click SSH and then click Auth.
In the auth section then browse where the private key or ppk file that you have generated is located.
If it's Ok. Congratulations you can now login to the server without having to send the root password.