Password Authentication only denied OpenSS?



专指使用PasswordAuthentication建立联系。我知道有很多关于公钥许可被拒绝的帖子。远程SSH连接尝试:

  • sshd PC UserName@staticIP: Permission denied (publickey,)keyboard-interactive)
  • root@staticIP: Permission denied (publickey,)keyboard-interactive)

我在一个(公共)路由器后面有一个分配给它的static IP的windows PC。现在,我只想在进行密钥身份验证之前获得一个初始ssh连接。我没有得到密码提示:

设置中:

  • PermitRootLogin是的
  • PubkeyAuthentication没有
  • PasswordAuthentication是的
  • 日志是的
  • LogLevel详细

在公网路由器上设置static IP:

  • 在我的路由器上允许SSH和端口22,入站和出站。
  • 当我尝试ssh时,我在路由器的防火墙日志中没有日志信息。
  • 我有端口转发,端口22到PC,我有sshd运行。

sshd PC:防火墙有入站规则允许端口22 SSH。允许应用程序通过Windows Defender防火墙进行通信;在OpenSSH Server和OpenSSH Server的Private和Public上也允许。

HrPing is successful: HrPingstaticIP-p 22 -n 4 -l 1000

使用PowerShell作为管理员以及在Ubuntu PC上我尝试过:

  • sshsshd PC UserName@staticIP-p 22
  • ssh root@staticIP-p 22

在sshd/Server PC>服务比;OpenSSH SSH Server>登录:应该选择本地系统帐户还是此帐户-然后选择用户?

In ProgramData>SSH祝辞日志:

10952 2022-06-15 16:36:18.724 Connection from 102.250.4.93 port 12692 on <Local LAN IP address sshd PC> port 22
10952 2022-06-15 16:36:18.987 Connection reset by authenticating user <UserName> 102.250.4.93 port 12692 [preauth]

我在OpenSSH下的windows eventViewer中没有收到任何消息。客户端和sshd PC上都没有密钥。在初始连接尝试中,sshd PC的指纹被复制到客户端的known_hosts文件夹,但这也以拒绝权限结束。

PS C:usersmyUser.ssh> ssh UserName@staticIP -p 22 -v
OpenSSH_for_Windows_8.1p1, LibreSSL 3.0.2
debug1: Connecting to staticIP [staticIP] port 22.
debug1: Connection established.
debug1: identity file C:\Users\myUser/.ssh/id_rsa type -1
debug1: identity file C:\Users\myUser/.ssh/id_rsa-cert type -1
debug1: identity file C:\Users\myUser/.ssh/id_dsa type -1
debug1: identity file C:\Users\myUser/.ssh/id_dsa-cert type -1
debug1: identity file C:\Users\myUser/.ssh/id_ecdsa type -1
debug1: identity file C:\Users\myUser/.ssh/id_ecdsa-cert type -1
debug1: identity file C:\Users\myUser/.ssh/id_ed25519 type -1
debug1: identity file C:\Users\myUser/.ssh/id_ed25519-cert type -1
debug1: identity file C:\Users\myUser/.ssh/id_xmss type -1
debug1: identity file C:\Users\myUser/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_8.1
debug1: Remote protocol version 2.0, remote software version OpenSSH_for_Windows_8.1
debug1: match: OpenSSH_for_Windows_8.1 pat OpenSSH* compat 0x04000000
debug1: Authenticating to staticIP:22 as 'UserName'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: kex: client->server cipher: chacha20-poly1305@openssh.com MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:gYkCT81kmqzhDjEIFipnAl2N8ZjtrF3WwOeIKYBQy98
debug1: Host 'staticIP' is known and matches the ECDSA host key.
debug1: Found key in C:\Users\myUser/.ssh/known_hosts:1
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: pubkey_prepare: ssh_get_authentication_socket: No such file or directory
debug1: Will attempt key: C:\Users\myUser/.ssh/id_rsa
debug1: Will attempt key: C:\Users\myUser/.ssh/id_dsa
debug1: Will attempt key: C:\Users\myUser/.ssh/id_ecdsa
debug1: Will attempt key: C:\Users\myUser/.ssh/id_ed25519
debug1: Will attempt key: C:\Users\myUser/.ssh/id_xmss
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: Next authentication method: publickey
debug1: Trying private key: C:\Users\myUser/.ssh/id_rsa
debug1: Trying private key: C:\Users\myUser/.ssh/id_dsa
debug1: Trying private key: C:\Users\myUser/.ssh/id_ecdsa
debug1: Trying private key: C:\Users\myUser/.ssh/id_ed25519
debug1: Trying private key: C:\Users\myUser/.ssh/id_xmss
debug1: Next authentication method: keyboard-interactive
debug1: Authentications that can continue: publickey,keyboard-interactive
debug1: No more authentication methods to try.
UserName@staticIP: Permission denied (publickey,keyboard-interactive).

sshd_config文件:

#   $OpenBSD: sshd_config,v 1.104 2021/07/02 05:11:21 dtucker Exp $
# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.
# This sshd was compiled with PATH=/bin:/usr/sbin:/sbin:/usr/bin
# 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 /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/id_ed25519
# Ciphers and keying
#RekeyLimit default none
#Logging yes
#SyslogFacility AUTH
#LogLevel VERBOSE
# Authentication:
#LoginGraceTime 2m
#PermitRootLogin yes
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10
#PubkeyAuthentication no
# 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
#AuthorizedKeysCommand none
#AuthorizedKeysCommandUser nobody
# For this to work you will also need host keys in /etc/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
# Change to no to disable s/key passwords
#KbdInteractiveAuthentication yes
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the KbdInteractiveAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via KbdInteractiveAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and KbdInteractiveAuthentication to 'no'.
#UsePAM no
#AllowAgentForwarding yes
AllowTcpForwarding yes
#GatewayPorts no
#X11Forwarding no
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /etc/ssh/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    /usr/lib/ssh/sftp-server
# Example of overriding settings on a per-user basis
#Match User anoncvs
#   X11Forwarding no
#   AllowTcpForwarding no
#   PermitTTY no
#   ForceCommand cvs server

您可以从调试输出

中看到
debug1: Authentications that can continue: publickey,keyboard-interactive

和最后的错误消息

Permission denied (publickey, keyboard-interactive)

服务器是而不是接受密码验证方法(否则单词password将包含在列表中)。

如果您自己将PasswordAuthentication设置为yes,请确保重新启动ssh服务以使更改生效。

最新更新