For Windows operating system user, may refer below guide.
Needed tools :
- puttygen.exe (a RSA and DSA key generation utility)
- pageant.exe (an SSH authentication agent for PuTTY, PSCP, PSFTP, and Plink)
- putty.exe (the SSH and Telnet client)
These are downloaded from https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html.
Step 1 - Generating SSH RSA key
- Open puttygen.exe
- Hit Generate and the public key will appear. Copy this public key and save to your computer.
- Save public key to your computer.
- Save private key to your computer.
P/S : Total 3 items to save from b, c and d.
Step 2 - Paste the public key from Step 1-b to Linux server authorized_keys.
- Remotely access your Linux CentOS operating system's server through putty.exe. May click this link for the guide.
- Run below command to create a folder .ssh
- mkdir /root/.ssh
- Run below command to open authorized_keys
- nano /root/.ssh/authorized_keys
Paste the public key from Step 1-b to authorized_keys and save the file.
Step 3 - Add the private key to pageant.exe for server remote authentication via SSH key.
- Open pageant.exe from your computer and will appear at Windows taskbar
- Add private key from Step 1-d
- Enter private key passphare that prompts.
- Done adding the private key.
- Open a new session from putty, entering your CentOS server IP and SSH port
- Enter username "root", hit enter to remotely access the server with SSH key.
To security reason, it is recommended to leave SSH password authentication disabled. This simply means that password authentication is disabled and have to use SSH key for remotely accessing server.
- Remotely access your server.
- Run below command to open SSH configuration file
- nano /etc/ssh/sshd_config
- search for PasswordAuthentication
- change "PasswordAuthentication yes" to "PasswordAuthentication no"
- save the change
- Restart SSH service
- systemctl restart sshd
The failure login with SSH key demonstration.
The success login through SSH key demonstration.