| # If you want to change the port on a SELinux system, you have to tell SELinux about this change. |
| # semanage port -a -t ssh_port_t -p tcp #PORTNUMBER | 将新端口添加到SELinux策略,其中,PORTNUMBER是要添加的新端口号。这个命令将告诉SELinux将指定的端口标记为ssh_port_t类型,以便在SELinux策略中允许SSH服务使用这个端口。请确保安装了semanage工具并具有适当的权限来执行该命令。 |
| #Port 22 | Port配置项,注释掉便默认的SSH连接端口号为22。如果想修改SSH连接的端口号,你可以取消注释并修改该行的值为你想要的端口号。 |
| #AddressFamily any | AddressFamily配置项,注释掉便允许任何地址家族的连接。默认情况下,SSH服务器允许IPv4和IPv6两种地址家族的连接。如果想限制只允许其中一种地址家族的连接,可以取消注释并设置为ipv4或ipv6。 |
| #ListenAddress 0.0.0.0 | ListenAddress配置项,注释掉便允许所有网络接口上的连接。默认情况下,SSH服务器会监听所有可用的网络接口。如果想限制只允许特定的网络接口上的连接,可以取消注释并设置为对应的IP地址。 |
| #ListenAddress :: | ListenAddress配置项,注释掉便允许所有IPv6地址上的连接。默认情况下,SSH服务器会监听所有可用的IPv6地址。如果想限制只允许特定的IPv6地址上的连接,可以取消注释并设置为对应的IPv6地址。 |
| HostKey /etc/ssh/ssh_host_rsa_key | 指定了SSH服务器使用的RSA主机密钥文件的路径。RSA主机密钥用于加密SSH连接过程中的通信数据,以确保连接的安全性。 |
| HostKey /etc/ssh/ssh_host_ecdsa_key | 指定了SSH服务器使用的ECDSA主机密钥文件的路径。ECDSA主机密钥也用于加密SSH连接过程中的通信数据,以确保连接的安全性。ECDSA密钥相对于RSA密钥,具有更高的安全性和更小的密钥长度。 |
| HostKey /etc/ssh/ssh_host_ed25519_key | 指定了SSH服务器使用的Ed25519主机密钥文件的路径。Ed25519主机密钥也用于加密SSH连接过程中的通信数据,以确保连接的安全性。Ed25519密钥相对于RSA和ECDSA密钥,具有更高的安全性和更小的密钥长度。 |
| # Ciphers and keying | Ciphers和keying相关的配置项。默认情况下,SSHD服务器使用默认的加密算法和密钥协商方式。如果想自定义加密算法和密钥协商方式,可以取消注释并设置相应的配置项。 |
| #RekeyLimit default none | RekeyLimit配置项,默认情况下,SSH连接的重新密钥协商是禁用的。如果想启用重新密钥协商,并设置重新密钥协商的限制条件,可以取消注释并设置相应的配置项。 |
| # This system is following system-wide crypto policy. The changes to |
| # crypto properties (Ciphers, MACs, ...) will not have any effect here. |
| # They will be overridden by command-line options passed to the server |
| # on command line. |
| # Please, check manual pages for update-crypto-policies(8) and sshd_config(5). |
| # Logging | 日志相关的配置项。默认情况下,SSH服务器会将日志信息发送到系统的系统日志(Syslog)设施。 |
| #SyslogFacility AUTH | SyslogFacility配置项,默认情况下,SSH服务器将日志信息发送到系统日志的AUTH设施。AUTH设施用于记录与认证和授权相关的日志信息。 |
| SyslogFacility AUTHPRIV | 指定了SSH服务器将日志信息发送到系统日志的AUTHPRIV设施。AUTHPRIV设施与AUTH设施类似,用于记录与认证和授权相关的日志信息,但提供了更高的安全性和隐私保护。 |
| #LogLevel INFO | LogLevel配置项,默认情况下,SSH服务器的日志级别为INFO。INFO级别将记录关键的系统事件和连接的详细信息。如果想更详细地记录SSH服务器的日志,可以取消注释并设置更具体的日志级别,如DEBUG。 |
| # Authentication: | 身份验证相关的配置项。默认情况下,SSH服务器会使用默认的身份验证设置。 |
| #LoginGraceTime 2m | LoginGraceTime配置项,默认情况下,SSH服务器的登录宽限时间为2分钟。登录宽限时间是指在连接建立后,客户端需要在指定的时间内完成身份验证操作。超过宽限时间未完成身份验证,服务器将断开连接。 |
| PermitRootLogin yes | 指定了允许root用户通过SSH登录。默认情况下,这个选项是注释的,表示禁止root用户通过SSH登录。如果取消注释并将其设置为"yes",则允许root用户通过SSH登录。 |
| #StrictModes yes | StrictModes配置项,默认情况下,SSH服务器启用了StrictModes模式。StrictModes模式强制执行更严格的权限检查,包括对用户家目录和.ssh目录的权限权限检查等。 |
| #MaxAuthTries 6 | MaxAuthTries配置项,默认情况下,SSH服务器允许最大的身份验证尝试次数为6次。超过该次数仍未成功身份验证,服务器将断开连接。 |
| #MaxSessions 10 | MaxSessions配置项,默认情况下,SSH服务器允许的最大会话数为10个。MaxSessions配置项用于限制同时活动的SSH会话数量。超过该数量,新的SSH会话将被拒绝。 |
| #PubkeyAuthentication yes | PubkeyAuthentication配置项,默认情况下,SSH服务器启用公钥身份验证。公钥身份验证是一种基于密钥对的身份验证方式,用于替代传统的密码身份验证。 |
| # The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2 |
| # but this is overridden so installations will only check .ssh/authorized_keys |
| AuthorizedKeysFile .ssh/authorized_keys | 指定存放授权密钥的文件路径。默认情况下,公钥授权文件是.ssh/authorized_keys,即用户主目录下的.ssh文件夹中的authorized_keys文件。这个文件包含了允许登录到服务器的公钥列表。 |
| #AuthorizedPrincipalsFile none | Principals授权。Principals是一种更灵活的授权机制,可以使用不同的授权文件来控制不同的用户或主机。 |
| #AuthorizedKeysCommand none | 使用外部命令来获取授权密钥。如果启用了该选项,sshd将运行指定的命令来获取用户的公钥,而不是从authorized_keys文件中读取。 |
| #AuthorizedKeysCommandUser nobody | 使用默认用户"nobody"来运行AuthorizedKeysCommand指定的命令。可以通过修改该选项来指定运行命令的用户。 |
| # 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 | 默认情况下不忽略用户的known_hosts文件。known_hosts文件是存储已知主机公钥的文件,用于验证主机身份。 |
| # Don't read the user's ~/.rhosts and ~/.shosts files |
| #IgnoreRhosts yes | 默认情况下不忽略用户的.rhosts和.shosts文件。这两个文件是用于基于Rhosts的身份验证。 |
| # To disable tunneled clear text passwords, change to no here! |
| #PasswordAuthentication yes | 默认情况下启用密码认证,允许用户使用密码进行身份验证。 |
| #PermitEmptyPasswords no | 默认情况下禁止用户使用空密码进行身份验证。 |
| PasswordAuthentication yes | 启用密码身份验证,可以使用密码进行SSH身份验证。 |
| # Change to no to disable s/key passwords |
| #ChallengeResponseAuthentication yes | 默认情况下启用挑战-响应认证。挑战-响应认证是一种使用密码和随机生成的挑战进行身份验证的方式。 |
| ChallengeResponseAuthentication no | |
| # Kerberos options |
| #KerberosAuthentication no | 默认情况下禁用Kerberos身份验证。 |
| #KerberosOrLocalPasswd yes | 默认情况下使用Kerberos票据进行身份验证,如果失败则使用本地密码进行身份验证。 |
| #KerberosTicketCleanup yes | 默认情况下在用户退出会话时清理Kerberos票据。 |
| #KerberosGetAFSToken no | 默认情况下禁用获取AFS令牌。 |
| # GSSAPI options |
| GSSAPIAuthentication yes | 默认情况下启用GSSAPI身份验证。GSSAPI是一种基于凭证的身份验证机制,它使用Kerberos等安全协议来完成身份验证过程。 |
| GSSAPICleanupCredentials no | 默认情况下在用户退出会话时清理GSSAPI凭证。 |
| #GSSAPIStrictAcceptorCheck yes | 默认情况下禁用严格的接收者检查。 |
| #GSSAPIKeyExchange no | 默认情况下禁用GSSAPI密钥交换。 |
| #GSSAPIEnablek5users no | 默认情况下禁用启用k5用户。 |
| # 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'. |
| # WARNING: 'UsePAM no' is not supported in Fedora and may cause several |
| # problems. |
| UsePAM yes | 默认情况下启用PAM认证、账户处理和会话处理。 |
| #AllowAgentForwarding yes | 默认情况下禁止代理转发。 |
| #AllowTcpForwarding yes | 默认情况下禁止TCP转发。 |
| #GatewayPorts no | 默认情况下禁用网关端口。 |
| X11Forwarding yes | 默认情况下启用X11转发。X11转发允许在SSH连接中显示远程服务器的图形界面。 |
| #X11DisplayOffset 10 | 默认情况下X11显示偏移为10。 |
| #X11UseLocalhost yes | 默认情况下禁用本地主机。 |
| #PermitTTY yes | 默认情况下允许TTY。 |
| # It is recommended to use pam_motd in /etc/pam.d/sshd instead of PrintMotd, |
| # as it is more configurable and versatile than the built-in version. |
| PrintMotd no | 默认情况下禁用打印欢迎信息 |
| #PrintLastLog yes | 默认情况下启用打印最后登录信息。 |
| #TCPKeepAlive yes | 默认情况下禁用TCP保持活动连接。 |
| #PermitUserEnvironment no | 默认情况下禁用用户环境变量。 |
| #Compression delayed | 默认情况下禁用用户环境变量。 |
| #ClientAliveInterval 0 | 默认情况下客户端活动间隔为0。 |
| #ClientAliveCountMax 3 | 默认情况下客户端活动计数最大值为3。 |
| #UseDNS no | 默认情况下禁用DNS。 |
| #PidFile /var/run/sshd.pid | 默认情况下PID文件位于"/var/run/sshd.pid"。 |
| #MaxStartups 10:30:100 | 默认情况下最大启动数为10:30:100。 |
| #PermitTunnel no | 默认情况下禁用隧道。 |
| #ChrootDirectory none | 默认情况下根目录未被限制。 |
| #VersionAddendum none | 默认情况下版本补充为空。 |
| # no default banner path |
| #Banner none | 默认情况下没有设置横幅。 |
| # Accept locale-related environment variables | 默认情况下接受了一系列与语言环境相关的环境变量。 |
| AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES |
| AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT |
| AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE |
| AcceptEnv XMODIFIERS |
| # override default of no subsystems |
| Subsystem sftp /usr/libexec/openssh/sftp-server | 取消默认的子系统配置,并设置了sftp子系统的路径。 |
| # Example of overriding settings on a per-user basis |
| #Match User anoncvs | 默认情况下没有针对特定用户的配置,以下可以设置特定用户的各种参数,例如是否允许X11转发、是否允许TCP转发、是否允许TTY、强制执行的命令等等。 |
| # X11Forwarding no |
| # AllowTcpForwarding no |
| # PermitTTY no |
| # ForceCommand cvs server |