How to Setup SSH Public Key Authentication
Wuttichai Kaewlomsap
Step1: Install SSH server
Login to your server
install ssh server
sudo apt-get install openssh-serverMake sure service is started
systemctl status ssh
Step2: Generate public and private key
- Download ssh tools MobaXterm or Putty
- Generate key
- MobaXterm:
Tools > MobaXterm SSH Key Generator > Generate - PuTTygen:
Generate
- MobaXterm:
- Save private key file
- Copy public key in text box
Step3: Add public key to your server
Edit key file
nano ~/.ssh/authorized_keysPaste your public key
Step4: Config authentication method
- open file config
sudo nano /etc/ssh/sshd_config
- change some config
/etc/ssh/sshd_config
PubkeyAuthentication yes
PasswordAuthentication no
- restart ssh
sudo systemctl restart ssh
Step5: Test Authen with public key
- open mobaXterm
- Session > SSH
- Remote host:
host ip - Specific username:
username - Advanced SSH settings:
Use private key > Select private file
- Remote host:
- OK
Reference

Wuttichai Kaewlomsap
Data Engineer