首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Sshd_config仍然允许密码身份验证

Sshd_config仍然允许密码身份验证
EN

Ask Ubuntu用户
提问于 2017-06-05 11:55:51
回答 2查看 12.4K关注 0票数 8

我已经修改了我的sshd_config文件,其中我更改了以下值:

  • PasswordAuthentication号
  • ChallengeResponseAuthentication号
  • usePAM否(现在设置为yes)

此外,我还通过执行:sudo service ssh restart重新启动了sshd服务。我也做了一次重启。

我仍然可以用用户密码登录。知道我错过了什么吗?

代码语言:javascript
复制
# Package generated configuration file
# See the sshd_config(5) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# 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
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

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

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 120
PermitRootLogin yes
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 no

# 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 no

编辑:

  • PermitRootLogin现在设置为no
  • usePAM现在设置为yes

但还是没起作用。

EN

回答 2

Ask Ubuntu用户

发布于 2017-06-05 12:00:59

你需要在这里做三件事:

(1)将PermitRootLogin设置为without-passwordrestrict-passwordno。为了安全。我通常把它设置为no

(2)你错过了一些非常重要的东西。您应该使用PAM进行身份验证-- UsePAM yes通常是默认的;这允许您使用UNIX用户登录数据。

(3)同样重要的是,通常将ChallengeResponseAuthentication设置为no。这可以防止绕过without-password登录的root限制。(例外情况是如果您使用的是libpam-duo和DuoSecurity2FA系统,在这种情况下,您需要将ChallengeResponseAuthentication设置为yes,但这不是一个典型的设置。)

一旦您这样做了,sudo service ssh restart将使用新的配置重新启动SSH服务。在退出SSH会话之前从另一个窗口尝试SSH,以确保事情按预期工作。

票数 8
EN

Ask Ubuntu用户

发布于 2020-01-26 15:01:00

我跟着托马斯的脚步走,但还是没起作用。结果,我只需要将UsePAM设置为no,现在它不允许在没有公钥的情况下登录。

票数 1
EN
页面原文内容由Ask Ubuntu提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://askubuntu.com/questions/922328

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档