服务器的sshd的配置文件:/etc/sshd/sshd_config
只介绍关键东西
#是注释要重新配置需要自己删除#(例如改端口 port 2222)


#Port 22    默认端口号, 可以使用多个端口号
#Port 443
#AddressFamily any   #协议家族, IPV4 or IPV6
#ListenAddress 0.0.0.0 #监听地址
#ListenAddress :: # 指明IPV6的所有地址格式
#当前版本支持的密钥认证方式
HostKey /etc/ssh/ssh_host_rsa_key #rsa私钥认证
HostKey /etc/ssh/ssh_host_ecdsa_key #ecdsa私钥认证
HostKey /etc/ssh/ssh_host_ed25519_key #ed25519私钥认证

# Logging #关于日志文件的信息数据放置与daemon的名称
#SyslogFacility AUTH # 有人使用SSH登录系统的时候,SSH会记录信息,记录在/var/log/secure
SyslogFacility AUTHPRIV # 默认是以AUTH来设置的。
#LogLevel INFO  # 日志等级

# Authentication: #认证
#LoginGraceTime 2m  #出现输入密码画面,多长时间没有成功连接上SSH Server就断线。
PermitRootLogin yes  # 是否允许管理员远程登录
#StrictModes yes # sshd去检查用户主目录或相关文件的权限数据, 当用户的host key改变之后,Server不接受联机
                              
#MaxAuthTries 6  # 最大尝试次数
#MaxSessions 10  # 允许最大会话数

#PubkeyAuthentication yes #是否允许Public Key

# 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, 
                                           
#AuthorizedPrincipalsFile none  #发送欢迎词的文件,none表示不发送

#AuthorizedKeysCommand none #指定脚本查找用户的公钥文件做认证,在登录认证层面调用,可接受的参数有用户尝试登录时使用的私钥

#AuthorizedKeysCommandUser nobody #指定查找的用户

# For this to work you will also need host keys in /etc/ssh/ssh_known_hosts
#HostbasedAuthentication no #是否信任~/.ssh/known_hosts文件
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no #忽略用户known_hosts文件
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes #是否取消使用~/.ssh/.rhosts来作为认证。

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes # 是否需要密码验证
#PermitEmptyPasswords no   # 是否允许空密码
PasswordAuthentication yes 

# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no # 是否允许质疑-应答(challenge-response)认证。
                                   # 默认值是"yes",所有 login.conf中允许的认证方式都被支持。

# Kerberos options #Kerberos认证服务器的选项
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#KerberosTicketCleanup yes
#KerberosGetAFSToken no
#KerberosUseKuserok yes

# GSSAPI options #通用安全服务应用程序接口选项
GSSAPIAuthentication yes
GSSAPICleanupCredentials no
#GSSAPIStrictAcceptorCheck yes
#GSSAPIKeyExchange no
#GSSAPIEnablek5users no
# PAM: Pluggable Authentication Modules 可插拔认证模块
UsePAM yes #使用PAM模块认证

#AllowAgentForwarding yes  # 允许经过代理转发
#AllowTcpForwarding yes    # 允许经过TCP转发
#GatewayPorts no           # 转发路径端口
X11Forwarding yes  #X-window的设置
#X11DisplayOffset 10 #x-window的设置
#X11UseLocalhost yes #x-window的设置
#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 #登录后是否要显示信息,即使读取/etc/motd文件内容

#PrintLastLog yes #显示上次登录信息
#TCPKeepAlive yes #SSH Server会传送KeepAlive信息给Client,确保联机正常                
#PermitUserEnvironment no  #若有一方脱机后,SSh可以立即知道
#Compression delayed #压缩延迟
#ClientAliveInterval 0 #设置空闲登录的最大时长
#ClientAliveCountMax 3 #在没收到任何数据的时候,最多向3个客户端进行keepalive检测
#ShowPatchLevel no #显示补丁级别
#UseDNS no  #开启DNS解析
#PidFile /var/run/sshd.pid #存储ssh的pid文件 
#MaxStartups 10:30:100  #最大可以保持多少个未认证的连接
#PermitTunnel no  #允许tun设备转发
#ChrootDirectory none #是否允许切换目录
#VersionAddendum none #配置附加版本

# no default banner path
#Banner none #不设置欢迎词

# Accept locale-related environment variables 接受本地相关环境变量类型

#是否开启sftp服务
# 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 #是否开启X11转发
#       AllowTcpForwarding no #是否允许TCP转发
#       PermitTTY no #是否允许tty
#       ForceCommand cvs server #限制命令
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐