SSH : Key-Pair Authentication2023/12/22 |
Generate SSH Key-Pair and set Authentication by it.
If you like to enable SSH service always, you shoud set Key-Pair and also should disable password authentication method. |
|
[1] | Generate SSH Key-Pair on the shell. |
# create key-pair [root@ctrl:~] /usr/lib/vmware/openssh/bin/ssh-keygen Generating public/private rsa key pair. # set key-store location like follows (default on ESXi sshd_config) # for other users ⇒ /etc/ssh/keys-(username) Enter file in which to save the key (//.ssh/id_rsa): /etc/ssh/keys-root/id_rsa Enter passphrase (empty for no passphrase): # set passphrase (if set no passphrase, Enter with empty) Enter same passphrase again: Your identification has been saved in /etc/ssh/keys-root/id_rsa Your public key has been saved in /etc/ssh/keys-root/id_rsa.pub The key fingerprint is: SHA256:Vd4V3+tVLb0JCk6F0f218EqNPoq3HRdtHw/vf68pm3U root@ctrl.srv.world The key's randomart image is: ..... .....[root@ctrl:~] ll /etc/ssh/keys-root total 16 drwxr-xr-x 1 root root 512 Dec 22 05:17 . drwxr-xr-x 1 root root 512 Dec 22 04:43 .. -rw------- 1 root root 2655 Dec 22 05:17 id_rsa -rw-r--r-- 1 root root 573 Dec 22 05:17 id_rsa.pub
[root@ctrl:~]
cat /etc/ssh/keys-root/id_rsa.pub >> /etc/ssh/keys-root/authorized_keys # to disable password input authentication method too, set like follows [root@ctrl:~] vi /etc/ssh/sshd_config # line 10 : change to [no] challengeresponseauthentication no
# line 34 : # password authentication = no # keyboard interactive authentication = no (add the line) PasswordAuthentication no KbdInteractiveAuthentication no
/etc/init.d/SSH restart SSH login disabled SSH login enabled |
[2] | Transfer the secret key [/etc/ssh/keys-root/id_rsa] on ESXi Host to any client computer and verify SSH access with Key-Pair Authentication. |
# [id_rsa] file transfered from ESXi Host [root@localhost ~]# ll ~/.ssh total 12 -rw-------. 1 root root 2655 Dec 22 14:24 id_rsa -rw-------. 1 root root 734 Dec 22 13:46 known_hosts -rw-r--r--. 1 root root 171 Dec 22 13:46 known_hosts.old[root@localhost ~]# ssh root@ctrl.srv.world uname -a Enter passphrase for key '/root/.ssh/id_rsa': VMkernel ctrl.srv.world 8.0.2 #1 SMP Release build-22380479 Sep 4 2023 15:00:49 x86_64 x86_64 x86_64 ESXi |
Sponsored Link |