OpenSSH : Kay-Pair Authentication
Configure SSH Key-Pair Authentication.
By default setting of OpenSSH on Windows, only [Administrators] group is configured as that [authorized_keys] file is not the default location of OpenSSH like follows, but if you'd like to set it on default location for all users, it needs to comment out these 2 lines.⇒ Conf file [C:\ProgramData\ssh\sshd_config]
Logon with any user you'd like to set SSH key-pair.PS > ssh-keygen
Run [ssh-keygen] command to generate SSH key-pair.
Move to [.ssh] folder and rename puiblic-key file to [authorized_keys].PS > cd .ssh
PS > mv id_rsa.pub authorized_keys
Change Security setting for [authorized_keys] file.
Because Everyone:(RX) is added to the file by default, but it prevents SSH key-pair authentication normally, so remove the right.
PS > icacls authorized_keys /remove EveryoneThat's OK all for Server side settings. Move to Client side Host.
Logon with any user you'd like to set SSH secret key on Client Host and run PowerShell or Command prompt.PS > mkdir .ssh
Next, create [.ssh] folder under the Home Folder of the user, and next, transfer secret key under [.ssh] folder like follows.
PS > cd .ssh
PS > sftp (username)@(SSH server's Hostname or IP address)
sftp > cd .ssh
sftp > get id_rsa
sftp > exit
That's OK. Make sure possible login with key-pair authentication.PS > ssh (username)@(SSH server's Hostname or IP address)
|||If transfer secret key on Linux Host, it's also possbile to connect from Linux Host to Windows Host with SSH key-pair auth.|