CentOS-Stream-10 Secure Shell服务器sshd_config配置文件

sshd_config SSH服务器端配置

bash 复制代码
#   #号为注释,注释中的命令是默认配置,如需更改内容生效请去掉注释

#允许侦听tcp端口号
# semanage port -a -t ssh_port_t -p tcp 2222
# semanage port -a -t ssh_port_t -p tcp  端口号

#默认端口号,可改为其他
#Port 22

#限制ssh服务器使用哪一类型地址,任何/ipv4/ipv6 <any|inet|inet4>
#AddressFamily any

#侦听所有的本地ssh通信
#ListenAddress 0.0.0.0     #所有ipv4
#ListenAddress ::					#所有ipv6

#密钥安全性ed25519>ecdsa>rsa 不需要更改位置 
#HostKey /etc/ssh/ssh_host_rsa_key
#HostKey /etc/ssh/ssh_host_ecdsa_key
#HostKey /etc/ssh/ssh_host_ed25519_key

# 多长时间重新协商会话密钥,none没有限制
#RekeyLimit default none


#/etc/rsyslog.conf文件的配置
#SyslogFacility AUTH       #所有和AUTHPRIV有关的消息记录到/var/log/secure
#LogLevel INFO       #信息级别

# Authentication:

#限制拒绝服务dos,默认时间2m,超2m没登录上,断开连接
#LoginGraceTime 2m

#管理员权限登录<yes|no|prohibit-password>
#PermitRootLogin prohibit-password  #强制使用密钥认证(如公钥/私钥对),禁止使用密码认证 

#普通用户登录管理员权限可使用su或sudo命令
#StrictModes yes

#检查用户主目录和ssh密钥是否设置了合适的权限,然后授权登录
#每个连接身份验证尝试默认次数6次
#MaxAuthTries 6	  

#开放ssh会话10个
#MaxSessions 10

#ssh v2版本 公钥/私钥的身份认证
#PubkeyAuthentication yes

#使用authorized_keys文件确认,用于身份验证的公钥
AuthorizedKeysFile      .ssh/authorized_keys

#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

#使用/etc/hosts.equiv文件限制连接的主机<yes|no>
# HostbasedAuthentication

#.ssh/known_hosts文件保存远程系统的公钥<yes|no>
#IgnoreUserKnownHosts no

#管理员从RSH转换到SSH,它们使用.rhost和.shosts文件<yes|no>
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

#私钥/公钥身份认证<yes|no>
# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes

#空口令<yes|no>,有安全风险
#PermitEmptyPasswords no

#启用键盘交互式认证(Keyboard-Interactive Authentication)
# Change to no to disable s/key passwords
#KbdInteractiveAuthentication yes


#ssh v1版本kerberos身份验证
# Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
#KerberosUseKuserok yes


#ssh v2版本kerbreos身份验证通用安全服务应用程序编程接口(gssapi)
# GSSAPI options
#GSSAPIAuthentication no
#登出后销毁证书
#GSSAPICleanupCredentials yes
#非常严格检查主机名
#GSSAPIStrictAcceptorCheck yes
#gssapi密钥交换
#GSSAPIKeyExchange no

#是否启用基于gssapi的Kerberos认证
#GSSAPIEnablek5users no

#支持通过PAM模块进行身份验证
#UsePAM no

#允许ssh-agent命令将私钥转发给其他远程系统
#AllowAgentForwarding yes

#ssh连接转发TCP通信
#AllowTcpForwarding yes

#远程主机不能连接转发端口
#GatewayPorts no

图形化连接转发    ssh -X 用户名@地址
#X11Forwarding no

#10个图形化显示
#X11DisplayOffset 10
#X11UseLocalhost yes
#PermitTTY yes

#远程登录后能否看见/etc/motd文件内容
#PrintMotd yes

#存档最后登录系统的时间
#PrintLastLog yes

#启用TCP keepalive消息,以免连接ssh客户端终端时,会话无限挂起
#TCPKeepAlive yes
#PermitUserEnvironment no
#Compression delayed

#ssh服务器确保用户还要传输数据
#ClientAliveInterval 0

#客户端自动断开连接前能够发送的消息数量
#ClientAliveCountMax 3

#依据dns服务器或/etc/hosts文件检查远程主机名,降低欺骗风险
#UseDNS 

#正在运行的ssh服务器进程的进程id号
#PidFile /var/run/sshd.pid

#限制ssh服务器能够处理的未验证连接数量
#MaxStartups 10:30:100

是否支持设备转发
#PermitTunnel no

#指定目录执行choot操作
#ChrootDirectory none

#
#VersionAddendum none

# no default banner path
#Banner none

# override default of no subsystems
Subsystem       sftp    /usr/libexec/openssh/sftp-server

# Example of overriding settings on a per-user basis
#Match User anoncvs
#       X11Forwarding no
#       AllowTcpForwarding no
#       PermitTTY no
#       ForceCommand cvs server
相关推荐
女神下凡3 小时前
芯参谋(85):Linux_PPI_NAND_驱动开发指南
linux·运维·arm开发·驱动开发·单片机·嵌入式硬件·设计规范
12.=0.3 小时前
【持续更新】shell脚本 + Linux命令
linux·运维·服务器
Escalating_xu4 小时前
【Linux 网络编程】五种 I/O 模型与非阻塞 I/O:从“等数据”到正确处理 EAGAIN
java·linux·网络
无言听风雨丶4 小时前
Linux 容器本质探秘:Cgroup 与 Namespace 深度解析与实战
linux·运维·服务器·kubernetes
万联WANFLOW4 小时前
CVE-2026-98432 等漏洞自查:AI 查出的 Linux、Windows 漏洞,运维怎么确认受不受影响
linux·运维·windows·网络安全
OPEN-F4 小时前
Ubuntu 自动登录后 GNOME 远程桌面连不上?一次登录钥匙环锁定的排查与永久修复
linux·运维·ubuntu
硅基手札4 小时前
【Linux 内核专栏 19】20 · 嵌入式子系统 — GPIO·pinctrl·clock·regulator
linux·运维·单片机·linux内核·嵌入式开发·调试定位
默|笙5 小时前
【Linux网络】传输层协议TCP(3)滑动窗口、流量控制
linux·网络·tcp/ip
Linux界最忧郁之人6 小时前
华为云ECS&IMS&AS实战|弹性云服务器、私有镜像、弹性伸缩完整实验
linux·运维·服务器·centos·华为云·openstack
whyutianict_vv7 小时前
零基础转 AI 运维:投入清单、技术路线与核对表
linux·运维·人工智能·ai