Windows 10 Linux子模块SSH无法登录

Windows 10 Linux子模块SSH无法登录

我需要为测试系统设置一个 Linux 子模块,该系统将通过 SSH 进入模块并通过远程 shell 运行程序。为此,我尝试运行具有公钥访问权限的 SSH 守护程序。问题是无论我做什么,我似乎都无法登录。每次我尝试时,我都会得到类似这样的信息:

sampler@DESKTOP-RDJ0BBU:~$ ssh -p4203 sampler@localhost
Sampler@localhost's password:
Permission denied, please try again.
Sampler@localhost's password:
Permission denied, please try again.
Sampler@localhost's password:
Permission denied (publickey,password).
sampler@DESKTOP-RDJ0BBU:~$

我知道我输入的密码是正确的,但它却不让我登录。我的帐户是名为“Sampler”的非管理员帐户,Linux 帐户是“sampler”,密码相同。(我尝试过大写和小写的“S”)。

这是我的/etc/ssh/sshd_config

# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 4203
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
#Privilege Separation is turned on for security
# !chroot not yet implemented on windows!
UsePrivilegeSeparation no

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 1024

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin no
AllowUsers Sampler
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile  %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no

# Change to no to disable tunnelled clear text passwords
PasswordAuthentication yes

# Kerberos options
#KerberosAuthentication no
#KerberosGetAFSToken no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes

X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

# Allow client to pass locale environment variables
AcceptEnv LANG LC_*

Subsystem sftp /usr/lib/openssh/sftp-server

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication 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 ChallengeResponseAuthentication to 'no'.
UsePAM yes

我知道我至少从我的 ssh 服务得到了响应,因为当我禁用服务器时,sudo service ssh stop我开始收到错误ssh: connection to host localhost port 4203: Connection Refused

/home/sampler/我在和中都有我的 .ssh 目录的副本/mnt/c/Users/Sampler,尽管我不认为这是问题所在,因为我的密码也不起作用。

编辑:我已经阅读了线程,正如您从我的配置文件中看到的,它们都没有解决我的问题。

答案1

我找到了我的问题。当我设置允许的用户时,我输入的是 Windows 用户名,Sampler而不是 Unix 名称sampler

# Authentication:
LoginGraceTime 120
PermitRootLogin no
AllowUsers sampler # <--- Here
StrictModes yes

我仍然遇到从外部计算机和公钥连接的问题,但这似乎是另一组问题。

相关内容