大网数据广告活动
服务器运维问答

Public Key Authentication not work on Windows 10 Professional

· 52CE 我爱测

I have been trying to configure OpenSSH for my Windows 10 Professional Edition media server. I can get normal password login working without issue but I am trying to set up public key authentication. I have edited my sshd_config …

问题原文

原帖链接 · TitanShadow · CC BY-SA 4.0

I have been trying to configure OpenSSH for my Windows 10 Professional Edition media server. I can get normal password login working without issue but I am trying to set up public key authentication.

I have edited my sshd_config file to allow for public key authentication. The client and the server are running ssh-agent. I've copied and pasted my SSH public key from the client computer into the file C:\ProgramData\ssh\administrators_authorized_keys since the account is an administrator account. Permissions on the above file are set the same as the other key files in the directory of being just SYSTEM and Administrators both with full control and no one else is listed.

I added debug logging and when I try to connect using the public key, I get this:

debug1: userauth-request for user uther service ssh-connection method none [preauth]
debug1: attempt 0 failures 0 [preauth]
debug1: user uther matched group list administrators at line 84
debug1: userauth-request for user uther service ssh-connection method publickey [preauth]
debug1: attempt 1 failures 0 [preauth]
debug1: userauth_pubkey: test pkalg ssh-rsa pkblob RSA SHA256:jcQNaVuxvH90SIh4zu8xduBqJaav1WFQJIov3hiFSFM [preauth]
debug1: trying public key file C:\\ProgramData\\ssh\\administrators_authorized_keys
Failed publickey for uther from 10.0.0.24 port 60432 ssh2: RSA SHA256:jcQNaVuxvH90SIh4zu8xduBqJaav1WFQJIov3hiFSFM
debug1: userauth-request for user uther service ssh-connection method keyboard-interactive [preauth]

I'm at a loss of how to resolve this. I literally cut and paste the text from id_rsa.pub on the client to the server in the administrators authorized keys file using Remote Desktop. There doesn't seem to be a permissions error, I can't figure out why it won't authenticate.

I would appreciate any help anyone could offer in getting this working. It isn't critical, SSH isn't exposed to the Internet, but some of the scripts I use would do much better with public key authentication.

I should also note when I set up the server I used my Microsoft account, I have been wondering if that has anything to do with it, so I may try to set up a straight local account and see if that fixes it.

EDIT: I attempted to create a local user account, but I cannot. Even when I try to use control userpasswords2 the box comes up but all the options to create an account are disabled. I'm thinking this must be because I have Windows 10 Professional and not some higher and most expensive edition.

社区高分解答

原帖链接 · Sergio Cabral · CC BY-SA 4.0

Use this sequence of commands in PowerShell to correct permission of administrators_authorized_keys

$acl = Get-Acl C:\ProgramData\ssh\administrators_authorized_keys
$acl.SetAccessRuleProtection($true, $false)
$administratorsRule = New-Object system.security.accesscontrol.filesystemaccessrule("Administrators","FullControl","Allow")
$systemRule = New-Object system.security.accesscontrol.filesystemaccessrule("SYSTEM","FullControl","Allow")
$acl.SetAccessRule($administratorsRule)
$acl.SetAccessRule($systemRule)
$acl | Set-Acl

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2020-09-04)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。