Key Authentication

Generate a key (on Local)

$ ssh keygen -t rsa -b 4096

Copy the key on server

$ ssh-copy-id -i ~/.ssh/id_rsa.pub user@192.168.10.108

Login with the key

$ ssh user@192.168.10.108 -i ~/.ssh/id_rsa

Set Key Authentication Only

$ sudo vi /etc/ssh/sshd_config 

Notice: The file to edit is sshd_config not ssh_config.

In the file, edit below option from yes to no.

PasswordAuthentication no

After edit the file, you must restart sshd.

$ sudo systemctl restart sshd

On Windows client

On windows client, install ssh-copy-id command first. By using chocolatey, type the command on PowerShell as Administrator.

> choco install ssh-copy-id

Last Updated on July 7, 2021 by lama-admin


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *