- 1 year ago
Windows openssh with authorized_keys still ask for user password
If you have set up OpenSSH on Windows with an authorized_keys
file, but you're still being prompted for a user password when connecting, there are a few possible reasons and solutions to consider:
Permissions on
authorized_keys
file: Make sure the permissions on theauthorized_keys
file are set correctly. The file should be located in the.ssh
directory within the user's home directory, and it should have restricted permissions to ensure that only the user has read access.Solution: Verify that the
authorized_keys
file has the correct permissions. On Windows, you can right-click on the file, go to "Properties," and make sure that only the user has read access.Configuration in
sshd_config
: Check the configuration file for the OpenSSH server (sshd_config
) to ensure that it is set up to use public key authentication.Solution: Open the
sshd_config
file, usually located atC:\ProgramData\ssh\sshd_config
, and make sure the following settings are present and uncommented:bashPubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
After making any changes, restart the OpenSSH service for the changes to take effect.
Key format in
authorized_keys
: Ensure that the public key stored in theauthorized_keys
file is in the correct format. Each public key entry should be a single line and typically starts withssh-rsa
orssh-ed25519
, followed by the public key itself.Solution: Verify that the public key in the
authorized_keys
file is correctly formatted. Each public key entry should be on a single line, and there should be no line breaks within the key.Key mismatch or wrong user: Double-check that you're connecting with the correct user and using the corresponding private key that corresponds to the public key in the
authorized_keys
file.Solution: Confirm that you're connecting with the correct user and using the private key that matches the public key stored in the
authorized_keys
file.
If none of the above solutions resolve the issue, it's possible that there are other configuration or system-related factors affecting the authentication process. In such cases, it may be helpful to consult the OpenSSH documentation or seek assistance from the OpenSSH community or support channels to troubleshoot further.