给小咕咕咕写的配置


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

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

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

# Include /etc/ssh/sshd_config.d/*.conf

Port 54321 # SSH监听端口(高位端口)


AcceptEnv LANG LC_*
# Subsystem sftp	/usr/lib/openssh/sftp-server
# PasswordAuthentication no

PermitRootLogin yes
# KbdInteractiveAuthentication no
# UsePAM yes
# X11Forwarding yes
# PrintMotd no

# ===== 认证安全配置 =====
# PermitRootLogin no                     # 禁止root用户直接登录(重要安全设置)-------------------暂时不用
MaxAuthTries 3                           # 最大认证尝试次数,防止暴力破解
MaxSessions 30                           # 每个网络连接允许的最大会话数
PubkeyAuthentication yes                 # 启用公钥认证
PasswordAuthentication no                # 禁用密码认证(强制使用密钥)
PermitEmptyPasswords no                  # 禁止空密码认证
KbdInteractiveAuthentication no          # 禁用键盘交互认证
# ===== 其他安全配置 =====
UsePAM yes                               # 启用PAM(Pluggable Authentication Modules)
X11Forwarding no                         # 禁用X11图形界面转发
PrintMotd no                             # 禁用登录后的欢迎信息
PrintLastLog no                          # 禁止显示IP信息
# ===== 连接和会话配置 =====
ClientAliveInterval 120                  # 客户端活跃检查间隔(120秒)
Subsystem sftp /usr/lib/openssh/sftp-server  # SFTP服务器子系统路径
# AcceptEnv LANG LC_* COLORTERM NO_COLOR   # 接受客户端传递的环境变量------------------------------暂时不用
# 建议添加以下配置以增强安全性:
StrictModes yes           # 严格检查文件权限
LoginGraceTime 1m         # 登录宽限时间设为1分钟
ClientAliveCountMax 2     # 客户端活跃检查最大次数
# AllowUsers admin       # 限制允许登录的用户(可选)----------------------------------------------暂时不用



#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

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

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


# 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,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the KbdInteractiveAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via KbdInteractiveAuthentication may bypass
# the setting of "PermitRootLogin prohibit-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and KbdInteractiveAuthentication to 'no'.

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no

#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes

#PrintLastLog yes
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

# Allow client to pass locale environment variables
# override default of no subsystems
# Example of overriding settings on a per-user basis
#Match User anoncvs
#	X11Forwarding no
#	AllowTcpForwarding no
#	PermitTTY no
#	ForceCommand cvs server


posted @ 2025-10-26 14:01  Li-zhienxuan  阅读(13)  评论(0)    收藏  举报