SSHD 配置文件的配置是否正确?

SSHD 配置文件的配置是否正确?

我在我的 Linux 机器上使用 ssh,我想让它尽可能的严密,只允许通过ed25519椭圆曲线加密签名进行 ssh。

我以为我已经正确设置了它,禁用密码,没有 PAM 等等。

它似乎运行正常,但今天我注意到我没有authorised_keys指定文件,而且我已经PubkeyAuthentication将其注释掉了。

当密码验证设置为否时,这些内容是否隐式设置为是?

这个设置可以吗?

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

答案1

我不确定,排除所有公钥算法是否ed25519是一种不太激进的做法,而且也是一种好的安全策略。安全 StackExchange我当然可以告诉你更多有关这一主题的信息。

SSH默认值列在sshd_config 手册页,但最好阅读你系统上的默认值:例如,Debian 更改了一些上游默认值。PubkeyAuthentication的默认值是是的并且AuthorizedKeysFile的默认设置是~/.ssh/authorized_keys(美式拼写)。

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

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 模块,因为密码和质询-响应身份验证都被禁用。

相关内容