Linux Mint 19.1 호스트에서 Windows 10 호스트로 암호가 없고 암호가 없는 SSH를 설정하려고 합니다. Windows 10 호스트에는 OpenSSH_for_Windows_7.7p1이 있습니다. 이는 Microsoft의 OpenSSH 포트입니다.
관리자 계정에 대해 이를 설정할 수 있지만 권한이 없는 계정은 작동하지 않습니다. 관리자 계정은 다르게 수행됩니다.
나는 다양한 방법을 시도해 보았지만 효과가 있을 것 같은 방법과 잘못된 점은 다음과 같습니다.
mkdir 및 echo >(또는 mkdir 및 cygwin vi - 동일한 결과)를 사용하여 /Users/Alden Stromberg/.ssh/authorized_keys 파일을 만듭니다.
그런 다음 OpenSSHUtils를 사용하여시도올바른 권한을 설정하려면 다음을 수행하세요.
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
비정규 ACL을 수정하기 위해 다음을 시도했습니다.
icacls.exe .\authorized_keys /reset /T /C /L /Q
...그러나 이후에 Repair-AuthorizedKeyPermission을 다시 실행해도 아무런 기쁨이 없습니다.
내가 도대체 뭘 잘못하고있는 겁니까? 0.0.2.0\OpenSSHUtils.psm1이 최신 버전이 아닌가요?
완전성을 기하기 위해 관리자 계정에 적용되는 작업은 다음과 같습니다.
get-acl c:\ProgramData\ssh\ssh_host_dsa_key | set-acl c:\ProgramData\ssh\administrators_authorized_keys
감사해요!
답변1
이 문제를 해결한 것은 comment out
파일 끝에 있는 다음 두 줄 이었습니다 C:\ProgramData\ssh\sshd_config
.
Match Group administrators
AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys
그런 다음 SSH를 다시 시작하십시오. 그 후 (~/.ssh/authorized_keys에 pub 키를 추가하고 파일에 올바른 권한이 있는지 확인) 더 이상 비밀번호를 묻는 메시지가 표시되지 않았습니다.
답변2
관리자가 아닌 계정에 대해 비밀번호 없는 인증을 수행하는 한 가지 방법은 다음에서 설명됩니다. https://www.techpaste.com/2015/06/windows-ssh-server-setup-and-configuration/
간단히 말해서, sshd_config
필요에 따라 주석 처리를 제거한 기존 항목에 이를 입력하세요.c:\ProgramData\ssh\
PermitRootLogin yes
StrictModes no
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
IgnoreUserKnownHosts yes
그리고 .net stop sshd
net start sshd
이는 아마도 컴퓨터의 모든 사람이 Authorized_keys를 읽을 수 있지만 적어도 작동한다는 의미일 것입니다.