首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >正确配置SSHD配置文件?

正确配置SSHD配置文件?
EN

Server Fault用户
提问于 2019-12-09 14:19:44
回答 1查看 20.6K关注 0票数 2

我在我的linux上使用ssh,我希望尽可能地保护它的安全,只允许通过ed25519椭圆曲线加密sigs来实现ssh。

我以为我的设置正确,禁用密码,没有PAM,等等。

它似乎正常工作,但是今天我注意到我没有指定一个authorised_keys文件,并且PubkeyAuthentication被注释掉了。

当密码auth设置为no时,这些内容是否隐式地设置为yes?

这个装置还好吗?

代码语言:javascript
复制
#       $OpenBSD: sshd_config,v 1.103 2018/04/09 20:41:22 tj Exp $

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

# This sshd was compiled with PATH=/usr/bin:/bin:/usr/sbin:/sbin

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

# Expect .ssh/authorized_keys2 to be disregarded by default in future.
#AuthorizedKeysFile     .ssh/authorized_keys .ssh/authorized_keys2

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

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

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

# GSSAPI options
#GSSAPIAuthentication no
#GSSAPICleanupCredentials yes
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no

# Set this to 'yes' to enable PAM authentication, account processing
EN

回答 1

Server Fault用户

回答已采纳

发布于 2019-12-09 18:53:42

我不确定,是否排除了所有的公钥算法,除了ed25519没有过分热心,它是一个很好的安全策略。安全堆栈交换当然可以告诉你更多关于这个问题的信息。

SSH默认值列在sshd_配置手册中,但最好在您的系统上读取该默认值:例如,Debian更改了一些上游默认值。PubkeyAuthentication's违约为,而AuthorizedKeysFile's违约为~/.ssh/authorized_keys (美式拼写)。

假设您想要:禁用所有基于密码的身份验证,并且只使用ed25519公钥加密,同时考虑到上游默认设置,您只需要:

代码语言:javascript
复制
ChallengeResponseAuthentication no
#GSSAPIAuthentication no by default
#HostbasedAuthentication no by default
#KbdInteractiveAuthentication defaults to ChallengeResponseAuthentication
#KerberosAuthentication no by default
PasswordAuthentication no
#PubkeyAuthentication yes by default
PubkeyAcceptedKeyTypes ssh-ed25519
UsePAM yes

禁用 PAM 作为一个整体禁用帐户会话PAM模块的使用,这些模块为用户提供了一个更好的环境。无论如何,都不会使用auth PAM模块,因为密码和质询响应身份验证都是禁用的。

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

https://serverfault.com/questions/994894

复制
相关文章

相似问题

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