OpenSSH : Kay-Pair Authentication2019/03/04 |
Configure SSH Key-Pair Authentication.
|
|
[1] |
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]
|
[2] |
Logon with any user you'd like to set SSH key-pair.
PS > ssh-keygen Run [ssh-keygen] command to generate SSH key-pair. |
[3] |
Move to [.ssh] folder and rename puiblic-key file to [authorized_keys].
PS > cd .ssh PS > mv id_rsa.pub authorized_keys |
[4] |
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 Everyone
That's OK all for Server side settings. Move to Client side Host.
|
[5] |
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 |
[6] |
That's OK. Make sure possible login with key-pair authentication.
PS > ssh (username)@(SSH server's Hostname or IP address) |
[7] | If transfer secret key on Linux Host, it's also possbile to connect from Linux Host to Windows Host with SSH key-pair auth. |
Sponsored Link |