前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Linux中SSHD配置文件详解

Linux中SSHD配置文件详解

作者头像
子润先生
修改2021-07-12 10:19:00
4.4K0
修改2021-07-12 10:19:00
举报

SSH简介

ssh(Secure Shell :安全外壳协议)

由 IETF 的网络工作小组(Network Working Group)所制定。

SSH 为建立在应用层和传输层基础上的安全协议。

SSH 是目前较可靠,专为远程登录会话和其他网络服务提供安全性的协议。

ssh结构 :ssh和sshd

客户端:scp(远程拷贝)、slogin(远程登陆)、sftp(安全文件传输)。

服务器端:公共密钥认证、密钥交换、对称密钥加密、非安全连接。

服务器配置文件详解 :/etc/ssh/sshd_conf

Port 22                   //端口号

//sshd服务器绑定的IP地址

#AddressFamily any

#ListenAddress10.105.120.221

//sshd版本2

Protocol 2

//设置包含计算机私人密匙的文件

#HostKey /etc/ssh/ssh_host_rsa_key

#HostKey/etc/ssh/ssh_host_dsa_key

//定义服务器密匙的位数

# Lifetime andsize of ephemeral version 1 server key

#KeyRegenerationInterval1h

#ServerKeyBits1024

//日志

# Logging

# obsoletesQuietMode and FascistLogging

#SyslogFacilityAUTH

SyslogFacilityAUTHPRIV             //日志Facility为AUTHPRIV

#LogLevel INFO                           //日志级别

# Authentication:

#LoginGraceTime 2m                  //表示认证的时限(以秒为单位)

#PermitRootLoginyes                 //root能不能用ssh登录

#StrictModes yes                        //ssh在接收登录请求之前是否检查用户家目录和rhosts文件的权限和所有权

#MaxAuthTries 6                        //只允许输错几回密码

#MaxSessions 10                        //最大支持几个ssh会话

//密钥认证

RSAAuthenticationyes               //是否使用RSA算法进行安全验证

PubkeyAuthenticationyes         //支持密钥的方式连接

AuthorizedKeysFile       .ssh/authorized_keys      //密钥文件存放路径

#AuthorizedKeysCommandnone

#AuthorizedKeysCommandRunAsnobody

//主机验证

# For this to workyou will also need host keys in /etc/ssh/ssh_known_hosts

#RhostsRSAAuthenticationno              //版本1使用的

# similar forprotocol version 2

#HostbasedAuthenticationno

# Change to yes ifyou don't trust ~/.ssh/known_hosts for

#RhostsRSAAuthentication and HostbasedAuthentication

#IgnoreUserKnownHostsyes

# Don't read theuser's ~/.rhosts and ~/.shosts files

#IgnoreRhosts yes

//口令验证

# To disabletunneled clear text passwords, change to no here!

#PasswordAuthenticationno              //是否开启身份验证

#PermitEmptyPasswordsno                //是否允许用口令为空的帐号登录

PasswordAuthenticationno                //是否使用口令验证

//是否开启挑战响应身份验证

# Change to no todisable s/key passwords

#ChallengeResponseAuthenticationyes

ChallengeResponseAuthenticationno

//Kerberos身份验证

# Kerberos options

#KerberosAuthenticationno

#KerberosOrLocalPasswdyes

#KerberosTicketCleanupyes

#KerberosGetAFSTokenno

#KerberosUseKuserokyes

//GSSAPI是公共安全事务应用程序接口(GSS-API)

//公共安全事务应用程序接口以一种统一的模式为使用者提供安全事务,由于它支持最基本的机制和技术,所以保证不同的应用环境下的可移植性.该规范定义了GSS-API事务和基本元素,并独立于基本的机制和程序设计语言环境,并借助于其它相关的文档规范实现.

# GSSAPI options

#GSSAPIAuthenticationno                   //是否允许使用基于GSSAPI 的用户认证.默认值为"no".仅用于SSH-2

GSSAPIAuthenticationyes

#GSSAPICleanupCredentialsyes          //是否在用户退出登录后自动销毁用户凭证缓存。

GSSAPICleanupCredentialsyes

#GSSAPIStrictAcceptorCheckyes

#GSSAPIKeyExchangeno

//SSH服务端的的PAM认证

# Set this to'yes' to enable PAM authentication, account processing,

# and sessionprocessing. If this is enabled, PAM authentication will

# be allowedthrough the ChallengeResponseAuthentication and

#PasswordAuthentication.  Depending on yourPAM configuration,

# PAMauthentication via ChallengeResponseAuthentication may bypass

# the setting of"PermitRootLogin without-password".

# If you just wantthe PAM account and session checks to run without

# PAMauthentication, then enable this but set PasswordAuthentication

# andChallengeResponseAuthentication to 'no'.

#UsePAM no

UsePAM yes                     //是否加载/etc/pam.d/sshd

//指定客户端发送的哪些环境变量将会被传递到会话环境中

# Acceptlocale-related environment variables

AcceptEnv LANGLC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES

AcceptEnv LC_PAPERLC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT

AcceptEnvLC_IDENTIFICATION LC_ALL LANGUAGE

AcceptEnvXMODIFIERS

//转发

#AllowAgentForwardingyes

//如果采用本地转发方式,AllowTcpForwarding选项是no,则不允许转发.

//如果采用远程转发方式,AllowTcpForwarding选项是no,则不允许转发.

#AllowTcpForwardingyes

//远程主机连接本地转发端口

#GatewayPorts no              //是否允许远程主机连接本地的转发端口

//X11转发允许在 SSH 客户端上显示应用程序的图形部分,而程序逻辑依然在远程服务器上执行.

#X11Forwarding no

X11Forwarding yes

#X11DisplayOffset10

#X11UseLocalhostyes

//允许或禁止登陆用户、组

AllowUsers 用户

AllowGroups 组

DenyUsers

DenyGroups

#PrintMotd yes                           //登录后显示/etc/motd中的信息

#PrintLastLog yes                       //成功登录后显示最后一位用户的登录信息

TCPKeepAlive yes                       //是否持续发送tcp包,维持连接

#UseLogin no //是否使用ssh服务端的login程序进行登录验证

#UsePrivilegeSeparationyes       //SSH服务端通过创建非特权子进程处理接入请求的方法来进行权限分离

#PermitUserEnvironmentno

#Compressiondelayed                //压缩选项yes

//连接超时断开连接

#ClientAliveInterval0                  //设置一个以秒记的时长,如果超过这么长时间没有收到客户端的任何数据,sshd 将通过安全通道向客户端发送一个"alive"消息,并等候应答.

#ClientAliveCountMax3            //sshd在未收到任何客户端回应前最多允许发送多少个"alive"消息,到达这个上限后,sshd 将强制断开连接,关闭会话

#ShowPatchLevel no                //在连接ssh端口时,是否返回SSH的补丁版本信息

UseDNS no    //是否对远程主机名进行反向解析,以检查此主机名是否与其IP地址真实对应.

#PidFile/var/run/sshd.pid          //pid文件存放位置

//这个选项一定要配合LoginGraceTime选项一起使用.

#MaxStartups10:30:100            //允许有多少次验证连接请求

#PermitTunnel no

#ChrootDirectorynone

# no defaultbanner path

#Banner none                          //登录之前显示在用户屏幕上,后面跟着文件位置

//配置一个外部的子系统,仅用于SSH-V2协议,一般这里使用sftp

# override defaultof no subsystems

Subsystem      sftp  /usr/libexec/openssh/sftp-server

# Example ofoverriding settings on a per-user basis

#Match Useranoncvs

#     X11Forwarding no

#     AllowTcpForwarding no

#     ForceCommand cvs server

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • SSH简介
相关产品与服务
多因子身份认证
多因子身份认证(Multi-factor Authentication Service,MFAS)的目的是建立一个多层次的防御体系,通过结合两种或三种认证因子(基于记忆的/基于持有物的/基于生物特征的认证因子)验证访问者的身份,使系统或资源更加安全。攻击者即使破解单一因子(如口令、人脸),应用的安全依然可以得到保障。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档