Commit 61928aa
committed
Fix SSH key path for Administrator accounts
Write SSH public keys for the built-in Administrator account to
C:\ProgramData\ssh\administrators_authorized_keys instead of
C:\Users\Administrator\.ssh\authorized_keys.
The default Windows OpenSSH sshd_config uses a Match Group directive
that reads admin keys from the ProgramData path:
Match Group administrators
AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys
The previous behavior wrote keys to ~/.ssh/authorized_keys which:
1. Requires the user profile to exist (fails after sysprep before
first login — the ProfileList registry entry is missing)
2. Is ignored by sshd for admin users due to the Match Group override
The ProgramData path is a system directory that always exists, does
not depend on user profiles, and is where all major cloud providers
(AWS EC2Launch v2, Azure) write admin SSH keys.
Also set proper ACL on administrators_authorized_keys per Microsoft
docs: only BUILTIN\Administrators and NT AUTHORITY\SYSTEM should
have access.
For non-admin users, the behavior is unchanged (~/.ssh/authorized_keys).
Closes: #162
Signed-off-by: Max Makarov <maxpain@linux.com>1 parent d63509f commit 61928aa
1 file changed
Lines changed: 48 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| 16 | + | |
16 | 17 | | |
17 | 18 | | |
18 | 19 | | |
19 | 20 | | |
20 | | - | |
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
31 | 59 | | |
32 | 60 | | |
33 | 61 | | |
| |||
37 | 65 | | |
38 | 66 | | |
39 | 67 | | |
40 | | - | |
41 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
42 | 82 | | |
43 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
44 | 86 | | |
45 | 87 | | |
46 | | - | |
47 | | - | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
57 | 91 | | |
58 | 92 | | |
0 commit comments