验证域用户进行 ssh 连接时出错

验证域用户进行 ssh 连接时出错

我正在尝试使用以下方法将我的 Windows 10 机器设置为 ssh 服务器Win32的OpenSSH。该服务器是域的一部分,因此我使用命令

ssh -i ~/.ssh/id_rsa  -l user@domain ip_address

从我的 ssh 客户端连接。

这会出现错误“权限被拒绝(公钥,键盘交互)”。在服务器端,日志显示

sshd:来自 ip_address 端口 59676 的无效用户 user@domain

sshd:无效用户 user@domain ip_address 端口 59676 [preauth] 关闭连接

我还尝试了 ssh 命令的以下变体

ssh -i ~/.ssh/id_rsa  domain/user@ip_address

尝试从客户端进行连接。我收到“通过 ip_address 端口 22 重置连接”错误。

如果我查看服务器端的日志,它会显示:

sshd:错误:lookup_principal_name:用户‘domain\user’的用户主体名称查找失败(显式:5,隐式:5)”

sshd:错误:get_user_token - 无法在第二次尝试中为用户 domain\user 生成令牌

sshd:致命:ga_init,无法解析用户域\用户

我该如何解决这个错误?

细节

在服务器(Windows 10)端:

whoami确认我的用户名是 domain\user

我只想使用公钥身份验证,因此我将 sshd_config 中的权限设置为

PubkeyAuthentication yes
PasswordAuthentication no

所有其他设置均为默认设置。完整的 sshd_config 文件如下

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

#HostKey __PROGRAMDATA__/ssh/ssh_host_rsa_key
#HostKey __PROGRAMDATA__/ssh/ssh_host_dsa_key
#HostKey __PROGRAMDATA__/ssh/ssh_host_ecdsa_key
#HostKey __PROGRAMDATA__/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin prohibit-password
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#PubkeyAuthentication yes

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile  .ssh/authorized_keys

#AuthorizedPrincipalsFile none

# For this to work you will also need host keys in %programData%/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no
PubkeyAuthentication yes
PasswordAuthentication no

# GSSAPI options
#GSSAPIAuthentication no

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#PermitUserEnvironment no
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

# override default of no subsystems
Subsystem   sftp    sftp-server.exe

# Example of overriding settings on a per-user basis
#Match User anoncvs
#   AllowTcpForwarding no
#   PermitTTY no
#   ForceCommand cvs server

Match Group administrators
       AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys

我已将 id_rsa.pub 附加到 C:\Users\user\.ssh 目录中的 authorized_keys 文件中。icacls .\authorized_keys返回

C:\Users\user\\.ssh\authorized_keys NT AUTHORITY\SYSTEM:(I)(F)
                  BUILTIN\Administrators:(I)(F)
                  DOMAIN\user:(I)(F)

在客户端(Ubuntu 20.04.3)端:

~/.ssh/id_rsa 具有以下权限

-rw------- 1 ubuntu ubuntu 2655 Dec 30 18:16 id_rsa
-rw-r--r-- 1 ubuntu ubuntu  576 Dec 30 18:16 id_rsa.pub

答案1

Match Group administrators
       AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys

将这些行设为注释行

相关内容