![Windows 10 sshd - eingehender SSH ohne Passwort erfordert ein Passwort](https://rvso.com/image/1585740/Windows%2010%20sshd%20-%20eingehender%20SSH%20ohne%20Passwort%20erfordert%20ein%20Passwort.png)
Ich versuche, kennwort- und passwortloses SSH von einem Linux Mint 19.1-Host zu einem Windows 10-Host einzurichten. Auf dem Windows 10-Host befindet sich OpenSSH_for_Windows_7.7p1. Dies ist der OpenSSH-Port von Microsoft.
Ich kann dies für Administratorkonten einrichten, aber nicht privilegierte Konten funktionieren bei mir nicht. Administratorkonten funktionieren anders.
Ich habe viele verschiedene Dinge ausprobiert, aber hier ist das, was meiner Meinung nach funktionieren sollte, und was dabei schief geht:
Ich erstelle eine Datei /Users/Alden Stromberg/.ssh/authorized_keys mit mkdir und echo > (oder mkdir und cygwin vi – dasselbe Ergebnis).
Dann benutze ich OpenSSHUtils umversuchenSo legen Sie die richtigen Berechtigungen fest:
PS C:\Users\Alden Stromberg\.ssh> Import-Module 'C:\Program Files\WindowsPowerShell\Modules\OpenSSHUtils\0.0.2.0\OpenSSHUtils.psd1'
PS C:\Users\Alden Stromberg\.ssh> Repair-AuthorizedKeyPermission .\authorized_keys
[*] .\authorized_keys
'NT AUTHORITY\SYSTEM' has the following access to '.\authorized_keys': 'Deny'-'ExecuteFile'.
Shall I make it Allow FullControl?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
Exception calling "SetAccessRule" with "1" argument(s): "This access control list is not in canonical form and therefore cannot be
modified."
At C:\Program Files\WindowsPowerShell\Modules\OpenSSHUtils\0.0.2.0\OpenSSHUtils.psm1:399 char:17
+ $acl.SetAccessRule($ace)
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
'NT AUTHORITY\SYSTEM' now has FullControl access to '.\authorized_keys'.
'DESKTOP-A31M9SV\None' should not have access to '.\authorized_keys'..
Shall I remove this access?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
Exception calling "RemoveAccessRule" with "1" argument(s): "This access control list is not in canonical form and therefore cannot
be modified."
At C:\Program Files\WindowsPowerShell\Modules\OpenSSHUtils\0.0.2.0\OpenSSHUtils.psm1:490 char:20
+ if(-not ($acl.RemoveAccessRule($ace)))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
'Everyone' should not have access to '.\authorized_keys'..
Shall I remove this access?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
Exception calling "RemoveAccessRule" with "1" argument(s): "This access control list is not in canonical form and therefore cannot
be modified."
At C:\Program Files\WindowsPowerShell\Modules\OpenSSHUtils\0.0.2.0\OpenSSHUtils.psm1:490 char:20
+ if(-not ($acl.RemoveAccessRule($ace)))
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
'NT SERVICE\sshd' needs Read access to '.\authorized_keys'.
Shall I make the above change?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"):
Exception calling "AddAccessRule" with "1" argument(s): "This access control list is not in canonical form and therefore cannot be
modified."
At C:\Program Files\WindowsPowerShell\Modules\OpenSSHUtils\0.0.2.0\OpenSSHUtils.psm1:564 char:21
+ $acl.AddAccessRule($ace)
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : InvalidOperationException
'NT SERVICE\sshd' now has Read access to '.\authorized_keys'.
Set-Acl : The process does not possess the 'SeSecurityPrivilege' privilege which is required for this operation.
At C:\Program Files\WindowsPowerShell\Modules\OpenSSHUtils\0.0.2.0\OpenSSHUtils.psm1:582 char:9
+ Set-Acl -Path $FilePath -AclObject $acl -Confirm:$false
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : PermissionDenied: (C:\Users\Alden ...authorized_keys:String) [Set-Acl], PrivilegeNotHeldException
+ FullyQualifiedErrorId : System.Security.AccessControl.PrivilegeNotHeldException,Microsoft.PowerShell.Commands.SetAclCommand
Repaired permissions
In der Hoffnung, die nichtkanonische ACL zu reparieren, habe ich Folgendes versucht:
icacls.exe .\authorized_keys /reset /T /C /L /Q
...aber das anschließende erneute Ausführen von Repair-AuthorizedKeyPermission bringt keine Lösung.
Was mache ich falsch? Ist 0.0.2.0\OpenSSHUtils.psm1 veraltet?
Der Vollständigkeit halber ist hier aufgeführt, was für Administratorkonten funktioniert hat:
get-acl c:\ProgramData\ssh\ssh_host_dsa_key | set-acl c:\ProgramData\ssh\administrators_authorized_keys
Danke!
Antwort1
Dieses Problem wurde für mich durch comment out
diese beiden Zeilen am Ende der C:\ProgramData\ssh\sshd_config
Datei behoben:
Match Group administrators
AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys
Starten Sie dann sshd neu. Danach (und nachdem ich den Pub-Schlüssel zu ~/.ssh/authorized_keys hinzugefügt und sichergestellt hatte, dass die Datei die richtigen Berechtigungen hatte) wurde ich nicht mehr nach einem Passwort gefragt.
Antwort2
Eine Möglichkeit, die kennwortlose Authentifizierung für Nicht-Administratorkonten zum Laufen zu bringen, wird unter folgendem Link beschrieben: https://www.techpaste.com/2015/06/windows-ssh-server-setup-and-configuration/
Kurz gesagt, fügen Sie diese in Ihre ein sshd_config
und entfernen Sie ggf. die Kommentarzeichen aus bereits vorhandenen Einträgen. Diese finden Sie unterc:\ProgramData\ssh\
PermitRootLogin yes
StrictModes no
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
IgnoreUserKnownHosts yes
Dann net stop sshd
und net start sshd
.
Dies bedeutet wahrscheinlich, dass Ihre autorisierten Schlüssel für jeden auf dem Computer lesbar sind, aber zumindest funktioniert es.