我在我的 linux 机器上使用 ssh,我想确保它尽可能防水,只允许通过ed25519
椭圆曲线加密 sigs 进行 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
我不确定是否排除所有公钥算法,除了
ed25519
不是过分热心,它是一个很好的安全策略。Security StackExchange当然可以告诉你更多关于这个主题的信息。SSH默认值在sshd_config 手册页中列出,但最好阅读系统上的那个:例如 Debian 更改了一些上游默认值。
PubkeyAuthentication
' 的默认值是yes并且AuthorizedKeysFile
' 的默认值是~/.ssh/authorized_keys
(美式拼写)。假设您想要:禁用所有基于密码的身份验证并仅使用
ed25519
公钥加密,考虑到您只需要的上游默认值:整体禁用PAM会禁用帐户和会话PAM 模块,从而为用户提供更好的环境。无论如何都不会使用 auth PAM 模块,因为密码和质询-响应身份验证都被禁用。