`
happmaoo
  • 浏览: 4309134 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Solaris 安全问题

阅读更多

一、安全理念
1、安全的隐患更多来自于企业内部
2、对于管理员的要求:不要信任任何人
3、分层保护策略:假设某些安全保护层完全失效
4、服务最小化
5、为最坏的情况做打算

二、物理安全
1、记录进出机房的人员名单,考虑安装摄像机
2、审查PROM是否被更换,可以通过记录hostid进行比较
3、每个系统的OpenBoot口令应该不一样,口令方案不可预测
4、系统安装完毕移除CD-ROM
5、将版本介质放入不在本场地的介质储藏室中

三、账号与口令策略
1、超级用户的PATH(在/.profile中定义的)设置为:
PATH = /usr/bin:/sbin:/usr/sbin
任何用户的PATH或者LD_LIBRARY_PATH中都不应该包含“.”
2、口令文件、影像文件、组文件
/etc/passwd 必须所有用户都可读,root用户可写 –rw-r—r—
/etc/shadow 只有root可读 –r--------
/etc/group 必须所有用户都可读,root用户可写 –rw-r—r--
3、口令安全
Solaris强制口令最少6位,但是超级用户修改口令的时候不受这个限制
强迫test账号每隔30天修改一次口令
#passwd –n 30 test
强迫test账号在下次登录的时候修改口令
#passwd –f test
禁止test账号修改口令
#passwd –n 2 –x 1 test
封锁test账号,禁止登录
#passwd –l test
4、组口令
用newgrp ;命令临时改变gid
由于sysadmin组可执行admintool,必须要保护好,增加组口令的过程:
删除不需要的成员(如果成员属于sysadmin,改变组时不需要口令)
#passwd ; (通常封锁的账号)
提取/etc/shadow中user的口令字符串插入到/etc/group中sysadmin的口令字段
封锁user账号
5、修改口令策略
/etc/default/passwd文件
MAXWEEKS=4 口令至少每隔4星期更改一次
MINWEEKS=1 口令至多每隔1星期更改一次
WARNWEEKS=3 修改口令后第三个星期会收到快要修改口令的信息
PASSLENGTH=6 用户口令长度不少于6个字符
6、限制使用su的组(只允许sysadmin组执行su命令)
#chgrp sysadmin /bin/su
#chmod o-rwx /bin/su
7、su的纪录
/etc/default/su文件
SULOG=/var/adm/sulog
SYSLOG=YES
CONSOLE=/dev/console
PATH=/usr/bin:
SUPATH=/usr/sbin:/usr/bin
8、禁止root远程登录
/etc/default/login中设置CONSOLE=/dev/null
在/etc/ftpusers里加上root。
在SSH 配置文件加:permitRootLogin = no
(Solaris 9自带SSH,缺省就禁止root登陆,对 Solaris 9,/etc/ftpusers 不再使用,FTP配置文件都在 /etc/ftpd/ 下面。如果 ftpd 启动时存在 /etc/ftpusers,它会被移动到 /etc/ftpd/下)

四、系统加固
1、为OpenBoot设置密码

在Solaris中设置密码 # eeprom security-password
在OpenBoot中设置密码 ok password
在Solaris中设置安全级别(command) # eeprom security-mode=command
在OpenBoot中设置安全级别(command) ok setenv security-mode command
在OpenBoot中设置安全级别(full) ok setenv security-mode full

2、取消不必须账号
移去或者锁定那些不是必须的帐号,比如sys\uucp\nuucp\listen等等,简单的办法是在/etc/shadow的password域中放上NP字符。
(简单办法是 passwd -l username)

3、文件系统
/etc目录中应该没有文件是组或者其他用户可写的
find /etc/ -type f –perm –g+w –print (查找组可写文件)
find /etc/ -type f –perm –o+w –print (查找其他用户可写文件)
chmod –R go-w /etc (改变任何错误的组/其他用户的写权限)
/var/adm/utmp和/var/adm/utmpx文件的权限应该是644

4、X-Windows手工锁定(当管理员离开电脑的时候)
CDE中面板上的加锁图标
OpenWindows中-鼠标右键-Utilities-Lock Screen

5、/etc的存取权限
用chmod -R g-w /etc命令来移去组用户对/etc的写权限。

6、打开数据包转发
#ndd –set /dev/ip ip_forwarding 1 (在系统作为路由器的情况中执行)
关闭数据包转发
#ndd –set /dev/ip ip_forwarding 0 (建议把这条命令加入/etc/init.d/inetinit中)
忽略重定向数据包(否则有遭到DOS的隐患)
#ndd –set /dev/ip ip_ignore_redirects 1 (加入/etc/init.d/inetinit)
不发送重定向数据包
#ndd –set /dev/ip ip_send_redirects 0 (加入/etc/init.d/inetinit)
禁止转发定向广播(如果网桥连结则不禁止)
#ndd –set /dev/ip ip_forward_directed_broadcasts 0 (加入/etc/init.d/inetinit)
禁止转发在数据源设置了路由的数据包
#ndd –set /dev/ip ip_forward_src_routed 0 (加入/etc/init.d/inetinit)

7、利用/etc/notrouter关闭IP转发
创建/etc/notrouter文件,重启计算机(入侵者如果可以访问根目录,可以使用ndd命令重新开启IP转发)
/etc/inet/hosts中的配置
127.0.0.1 Localhost (所有系统都有这一项)
192.168.0.13 Loghost (syslog使用的)
192.168.0.109 wy_solaris (主机IP和主机名)
/etc/defaultrouter包含了默认路由器的名称或者IP
如果使用了默认路由器,在/etc/inet/hosts文件中必须包含路由器的名称,因为如果设置了路由表,系统将不会运行任何目录服务(DNS、NIS或者NIS+)

8、cron(任务在/var/spool/cron/crontabs/ 一般行为在/etc/default/cron)
格式:minute hour day-of-month month day-of-week command
(每项间用空格,同一项两个数字间用逗号,每项为数字或者星号)
配置:
查看命令 crontab –l
(1)进入只有本用户可读的目录
(2)crontab –l >; mycronfile
(3)编辑mycronfile
(4)crontab ;>; /etc/system
echo "set noexec_user_stack_log=1" >;>; /etc/system
(对 Solaris 9,可以对单个程序设定堆栈不可执行属性,前提是有该程序的源码,例如:# cc -M /usr/lib/ld/map.noexstk myprogram.c)

12、使IP forwarding和sourec routing(源路)由无效
在Inetinit中使IP forwarding和sourec routing(源路)由无效(假如有超过一个网络接口的话)。在/etc/init.d/inetinit中增加下面所示设置:
ndd -set /dev/ip ip_forward_directed_broadcasts 0
ndd -set /dev/ip ip_forward_src_routed 0
ndd -set /dev/ip ip_forwarding 0

13、防止TCP序列号预测攻击(ip欺骗)
建议在/etc/default/inetinit中增加如下的生成初始化序列号设置来防止TCP序列号预测攻击(ip欺骗):TCP_STRONG_ISS=2

14、(如果有ftp服务)不要使用匿名ftp
/etc/inet/inetd.conf中的ftpd为(记录)
ftp stream tcp nowait root /usr/sbin/in.ftpd in.ftpd –dl
决不能用root身份使用ftp(口令不加密)
/etc/ftpusers中的增加超级用户(这里的账号禁止用ftp连接系统)
FTP 服务暴露系统敏感信息
编辑/etc/default/ftpd文件,假如文件不存在就新建一个,在文件中的加进以下一项:BANNER=XXXX(XXXX可以任意改变为任何一个版本信息),将该系统版本信息屏蔽.

15、关闭NFS服务

16、用SSH替代Telnet服务

17、限制.rhosts、.netrc和/etc/hosts.equiv文件的使用
限制.rhosts、.netrc和/etc/hosts.equiv文件的使用。r系列命令使用这些文件来访问系统。要为这些文件加锁,先创建它们,然后修改其属性为零即可。这样除了root用户就没有其它用户能创建或修改它们了。
/usr/bin/touch /.rhosts /.netrc /etc/hosts.equiv
/usr/bin/chmod 0 /.rhosts /.netrc /etc/hosts.equiv
.rhosts文件可以作为一个典型的后门文件使用,在某用户的目录下存在.rhosts文件的话,任何用户都可以通过rlogin不需要口令以该用户的身份登录到系统。
运行下面的命令全局查找.rhosts文件
# find –name “.rhosts” –print

18、使多路广播(multicasting)无效
为了使多路广播(multicasting)无效请在/etc/init.d/inetsvc中注解掉"route add 224.0.0.0"周围的几行。

19、关闭系统的snmp服务
更改 /etc/rc2.d/K07snmpdx 和/etc/rc3.d/S76snmpdx文件名

20、X-Windows不安全,可以使用ssh对其加密

21、加强网络访问控制
编辑/etc/inet.d/inetsvc,在inetd后面加上-t选项
类似命令/usr/sbin/inetd –s –t
停止再运行inetd
运行的使用使用 #/usr/sbin/inetd –s –t

22、网络访问控制
原则:去掉不必要的网络访问,在所需要的网络访问周围简历访问控制

Solaris网络服务(/etc/inet/services)[没有被注释/* */的服务可关闭]
#ident "@(#)services 1.27 00/11/06 SMI" /* SVr4.0 1.8 */
#
#
# Copyright (c) 1999-2000 by Sun Microsystems, Inc.
# All rights reserved.
#
# Network services, Internet style
#
tcpmux 1/tcp /*必须*/
echo 7/tcp
echo 7/udp
discard 9/tcp sink null
discard 9/udp sink null
systat 11/tcp users
daytime 13/tcp
daytime 13/udp
netstat 15/tcp
chargen 19/tcp ttytst source
chargen 19/udp ttytst source
ftp-data 20/tcp /*依服务可选*/
ftp 21/tcp /*依服务可选*/
ssh 22/tcp /*依服务可选*/
telnet 23/tcp /*依服务可选*/
smtp 25/tcp mail /*依服务可选*/
time 37/tcp timserver
time 37/udp timserver
name 42/udp nameserver
whois 43/tcp nicname # usually to sri-nic
domain 53/udp /*依服务可选*/
domain 53/tcp /*依服务可选*/
bootps 67/udp # BOOTP/DHCP server
bootpc 68/udp # BOOTP/DHCP client
hostnames 101/tcp hostname # usually to sri-nic
pop2 109/tcp pop-2 # Post Office Protocol - V2
pop3 110/tcp # Post Office Protocol - Version 3
sunrpc 111/udp rpcbind
sunrpc 111/tcp rpcbind
imap 143/tcp imap2 # Internet Mail Access Protocol v2
ldap 389/tcp # Lightweight Directory Access Protocol
ldap 389/udp # Lightweight Directory Access Protocol
submission 587/tcp # Mail Message Submission
submission 587/udp # see RFC 2476
ldaps 636/tcp # LDAP protocol over TLS/SSL (was sldap)
ldaps 636/udp # LDAP protocol over TLS/SSL (was sldap)
#
# Host specific functions
#
tftp 69/udp
rje 77/tcp
finger 79/tcp
link 87/tcp ttylink
supdup 95/tcp
iso-tsap 102/tcp
x400 103/tcp # ISO Mail
x400-snd 104/tcp
csnet-ns 105/tcp
pop-2 109/tcp # Post Office
uucp-path 117/tcp
nntp 119/tcp usenet # Network News Transfer
ntp 123/tcp # Network Time Protocol
ntp 123/udp # Network Time Protocol
netbios-ns 137/tcp # NETBIOS Name Service
netbios-ns 137/udp # NETBIOS Name Service
netbios-dgm 138/tcp # NETBIOS Datagram Service
netbios-dgm 138/udp # NETBIOS Datagram Service
netbios-ssn 139/tcp # NETBIOS Session Service
netbios-ssn 139/udp # NETBIOS Session Service
NeWS 144/tcp news # Window System
slp 427/tcp slp # Service Location Protocol, V2
slp 427/udp slp # Service Location Protocol, V2
mobile-ip 434/udp mobile-ip # Mobile-IP
cvc_hostd 442/tcp # Network Console
#
# UNIX specific services
#
# these are NOT officially assigned
#
exec 512/tcp
login 513/tcp
shell 514/tcp cmd # no passwords used
printer 515/tcp spooler # line printer spooler
courier 530/tcp rpc # experimental
uucp 540/tcp uucpd # uucp daemon
biff 512/udp comsat
who 513/udp whod
syslog 514/udp /*依服务可选*/
talk 517/udp
route 520/udp router routed
ripng 521/udp
klogin 543/tcp # Kerberos authenticated rlogin
kshell 544/tcp cmd # Kerberos authenticated remote shell
new-rwho 550/udp new-who # experimental
rmonitor 560/udp rmonitord # experimental
monitor 561/udp # experimental
pcserver 600/tcp # ECD Integrated PC board srvr
sun-dr 665/tcp # Remote Dynamic Reconfiguration
kerberos-adm 749/tcp # Kerberos V5 Administration
kerberos-adm 749/udp # Kerberos V5 Administration
kerberos 750/udp kdc # Kerberos key server
kerberos 750/tcp kdc # Kerberos key server
krb5_prop 754/tcp # Kerberos V5 KDC propogation
ufsd 1008/tcp ufsd # UFS-aware server
ufsd 1008/udp ufsd
cvc 1495/tcp # Network Console
ingreslock 1524/tcp
www-ldap-gw 1760/tcp # HTTP to LDAP gateway
www-ldap-gw 1760/udp # HTTP to LDAP gateway
listen 2766/tcp # System V listener port
nfsd 2049/udp nfs # NFS server daemon (clts)
nfsd 2049/tcp nfs # NFS server daemon (cots)
eklogin 2105/tcp # Kerberos encrypted rlogin
lockd 4045/udp # NFS lock daemon/manager
lockd 4045/tcp
dtspc 6112/tcp # CDE subprocess control /*依服务可选*/
fs 7100/tcp # Font server /*依服务可选*/

执行方法:
/etc/inet/services在相应服务前加“#”注释掉
/etc/inet/inetd.conf中注释掉services中相应的条目
查找并重启inetd进程
#ps –ef | grep inetd (获得进程号)
#kill –HUP ;
停止在上述列表中没有定义的服务
方法:将文件改名(用mv命令,可以将S改为X)
停止相应进程
服务:
服务 文件 进程
sendmail /etc/rc2.d/S88sendmail Sendmail
DNS /etc/rc2.d/S72inetsvc中in.named一项注释掉 in.named
named.xfer
NFS /etc/rc3.d/S15nfs.server
注释掉/etc/dfs/dfstab中条目 Nfsd
Automounter /etc/rc2.d/S74autofs
删除/etc/auto_*
ntp /etc/rc2.d/S74xntpd Xntpd
syslog /etc/rc2.d/S74syslog Syslogd
打印 /etc/rc2.d/S80lp lpshut

23、使Sendmail更安全
使用最新版本的Berkeley sendmail (see section 3),从/etc/aliases里删除decode 将/etc/aliases的权限设为644,关掉expn和vrfy命令。将
O PrivacyOptions=authwarning
改成
O PrivacyOptions=goaway
检查 Sendmail 是否支持发信认证
参考devtools/Site/README文件在devtools/Site下建立如下site.config.m4 文件:
APPENDDEF(`conf_sendmail_ENVDEF', `-DSASL')
APPENDDEF(`conf_sendmail_LIBS', `-lsasl')
给Sendmail编译进SASL支持。
cd sendmail; 执行:sh Build 编译sendmail。
到cf/cf 目录下,拷贝 generic-linux.mc 为 sendmail.mc, 在sendmail.mc 中增加以下内容:
define(`confSMTP_LOGIN_MSG',`$m Server')dnl
改变sendmail欢迎信息
define(`confAUTH_MECHANISMS', `LOGIN')dnl
Unix帐号认证
define(`confPRIVACY_FLAGS',`novrfy,noexpn,noverb')dnl 禁用命令
define(`confMAX_DAEMON_CHILDREN', `128')dnl
define(`confCONNECTION_RATE_THROTTLE', `32')dnl
(抗拒绝服务攻击)

24、增加DNS服务安全
关闭 zone 转换选项
不使用文件. named ,转而使用 /var/bind
关闭 lame server log messages
在/var/bind里面加入
options {
directory "/var/named";
forwarders{
202.106.120.1;
};
version "InterSoft Super DNS Server 2.0.4";
allow-transfer {none;};
};

logging {
category "lame-servers" { "null"; };
};

25、鉴于更改s位程序有可能影响正常服务,建议不要改动,但是可定期查看s位程序列表,对比是否有增减。
# find / -perm -4000 -print

26、使CDE程序无效(除非你坚持要使用图形控制台) [此项可选]
使CDE程序无效(除非你坚持要使用图形控制台)
将 /etc/rc2.d/S99dtlogin 改名

五、使用sun的补丁检查工具检查系统安装的补丁情况
运行该工具检查系统补丁的如下情况:
- latest revisions
- recommended patches
- security patches
- year 2000 patches
- other patches relevant to the software environment
(Sun 网站有专门的补丁检查工具)
及时修补最新漏洞、打上补丁

关掉r-命令,方法如下:删除/etc/hosts.equiv文件,或改为只读空文件。禁用rshd,rlogind and
rexecd,通过修改inetd.conf文件。
2、/etc/sshd_config配置
HostKey /etc/ssh_host_key
PidFile /etc/sshd.pid
RandomSeed /etc/ssh_random_seed

StrictModes yes 要求用户保护其与SSH有关的文件及目录
Umask 0077 保证所有SSHD1创建是文件和目录都只能由其所有者(SSHD 运行的
UID)读取

port 22
ListenAddress 0.0.0.0
IdleTimeout 15m 15分钟空闲超时
KeepAlive yes 客户机死机时连接将会终止,而不会长期挂起。

LoginGraceTime 30 登录时成功认证的时限为30秒。

ServerKeyBits 768 服务器密钥长度
KeyRegenerationInterval 3600 服务器密钥一小时重新生成一次

PasswordAuthentication no 禁用密码认证
RhostsAuthentication no 禁用可信主机认证
RhostsRSAAuthentication no 禁用增强可信主机认证
RSAAuthentication yes 启用公钥认证

IgnoreRhosts yes 完全禁止SSHD使用.rhosts文件
IgnoreRootRhosts yes

UseLogin no 禁用UseLogin,防止万一使用了其它登录程序

AllowHosts xxx 根据需要设置
SilentDeny yes 任何被DenyHosts拒绝的连接都不会向用户返回消息,不必告诉攻击
者发生了什么,可以增加了排错的难度。

PermitRootLogin nopwd 允许超级用户通过SSH连接,但不能用密码认证

FascistLogging no 禁用FascistLogging日志方式,因为它会在日志中记录用户特定信息,对
攻击者有用。
QuietMode no 禁用QuietMode日志方式,使用日志更详细,敏感度更低

AllowTcpForwarding yes 允许tcp端口转发和X转发,保护其它的tcp连接
X11Forwarding yes

3、/etc/ssh2/sshd2_config配置
HostKeyFile /etc/ssh2/hostkey
PublicHostKeyFile /etc/ssh2/hostkey.pub
RandmoSeedFile /etc/ssh2/random_seed

UserConfigDirectory
IdentityFile
AuthorizstionFile

StrictModes yes

port 22
listenAddress 0.0.0.0
KeepAlive yes
RequireReverseMapping no

LoginGraceTime 30

由于sshd2没有设置服务器密钥的位数的关键字,用户得在启动时使用 -b 选项 $ sshd2 -b
1024 ....

AllowedAuthentications publickey
RequiredAuthentications publickey

IgnoreRhosts yes
UserKnownHosts no 禁用该项可防止用户给未知主机提供信任权限。

PermitRootLogin nopwd

Ciphers any 不能选none

QuietMode no
VerboseMode yes

Ssh1Compatibility no 禁用SSH-1兼容模式
#Ssh1Path /usr/local/ssh1/sshd1 出于实用原因,也可以启用此模式,之前要指明ssh1服
务器可执行文件位置

4、每账号配置
对于SSH1 AND OPENSSH,~/.ssh/authorized_keys中的每一个密钥都必须用适当的选项进
行限制,from选项限制只能从特定的主机访问特定的密钥。例如,假设文件中包含你家那
台pc(myhome.isp.net)的公钥,而其它机器根本不可能用那个密钥来认证,我们就可以明确
限定这一关系:from = "myhome.isp.net" ...key...。还要对适当的密钥设置空闲超时时间:from
= "myhome.isp.net" ,idle-timeout=5m ...key...。
最后,考虑每一个密钥是否需要对到达的连接使用端口转发,代理转发以及分配tty等,如
果不需要,就可以分别用no-port-forwarding,no-agent-forwarding and no-pty禁用这些特性。

5、密钥管理
至少创建1024位长的用户密钥,并用好的口令对密钥进行保护。

6、客户端配置
离开正在运行的ssh客户端时,一定要用密码保护。
在客户端配置文件中启用某些安全功能,并将其设置为最强
Host *
FallBackToRsh no 禁止使用不安全的r-命令(ssh2)没有这个问题。
UseRsh no
GatewayPorts no 禁止远程客户端连接本地的转发端口
StrictHostKeyChecking ask 在主机密钥发生变化时提醒你。请求你的处理意见。
配置“/etc/ssh/ssh_config”文件 
“/etc/ssh/ssh_config”文件是OpenSSH系统范围的配置文件,允许你通过设置不同的选项
来改变客户端程序的运行方式。这个文件的每一行包含“关键词-值”的匹配,其中“关键
词”是忽略大小写的。下面列出来的是最重要的关键词,用man命令查看帮助页(ssh (1))
可以得到详细的列表。 

编辑“ssh_config”文件(vi /etc/ssh/ssh_config),添加或改变下面的参数: 

# Site-wide defaults for various options 
Host * 
ForwardAgent no 
ForwardX11 no 
RhostsAuthentication no 
RhostsRSAAuthentication no 
RSAAuthentication yes 
PasswordAuthentication yes 
FallBackToRsh no 
UseRsh no 
BatchMode no 
CheckHostIP yes 
StrictHostKeyChecking no 
IdentityFile ~/.ssh/identity 
Port 22 
Cipher blowfish 
EscapeChar ~ 

下面逐行说明上面的选项设置: 

Host * 
选项“Host”只对能够匹配后面字串的计算机有效。“*”表示所有的计算机。 

ForwardAgent no 
“ForwardAgent”设置连接是否经过验证代理(如果存在)转发给远程计算机。 

ForwardX11 no 
“ForwardX11”设置X11连接是否被自动重定向到安全的通道和显示集(DISPLAY set)。 

RhostsAuthentication no 
“RhostsAuthentication”设置是否使用基于rhosts的安全验证。 

RhostsRSAAuthentication no 
“RhostsRSAAuthentication”设置是否使用用RSA算法的基于rhosts的安全验证。 

RSAAuthentication yes 
“RSAAuthentication”设置是否使用RSA算法进行安全验证。 

PasswordAuthentication yes 
“PasswordAuthentication”设置是否使用口令验证。 

FallBackToRsh no 
“FallBackToRsh”设置如果用ssh连接出现错误是否自动使用rsh。 

UseRsh no 
“UseRsh”设置是否在这台计算机上使用“rlogin/rsh”。 

BatchMode no 
“BatchMode”如果设为“yes”,passphrase/password(交互式输入口令)的提示将被禁止。
当不能交互式输入口令的时候,这个选项对脚本文件和批处理任务十分有用。 

CheckHostIP yes 

“CheckHostIP”设置ssh是否查看连接到服务器的主机的IP地址以防止DNS欺骗。建议设
置为“yes”。 

StrictHostKeyChecking no 
“StrictHostKeyChecking”如果设置成“yes”,ssh就不会自动把计算机的密匙加入
“$HOME/.ssh/known_hosts”文件,并且一旦计算机的密匙发生了变化,就拒绝连接。 

IdentityFile ~/.ssh/identity 
“IdentityFile”设置从哪个文件读取用户的RSA安全验证标识。 

Port 22 
“Port”设置连接到远程主机的端口。 

Cipher blowfish 
“Cipher”设置加密用的密码。 

EscapeChar ~ 
“EscapeChar”设置escape字符。 

配置“/etc/ssh/sshd_config”文件 
“/etc/ssh/sshd_config”是OpenSSH的配置文件,允许设置选项改变这个daemon的运行。
这个文件的每一行包含“关键词-值”的匹配,其中“关键词”是忽略大小写的。下面列出
来的是最重要的关键词,用man命令查看帮助页(sshd (8))可以得到详细的列表。 

编辑“sshd_config”文件(vi /etc/ssh/sshd_config),加入或改变下面的参数: 

# This is ssh server systemwide configuration file. 
Port 22 
ListenAddress 192.168.1.1 
HostKey /etc/ssh/ssh_host_key 
ServerKeyBits 1024 
LoginGraceTime 600 
KeyRegenerationInterval 3600 
PermitRootLogin no 
IgnoreRhosts yes 
IgnoreUserKnownHosts yes 
StrictModes yes 
X11Forwarding no 
PrintMotd yes 
SyslogFacility AUTH 
LogLevel INFO 
RhostsAuthentication no 
RhostsRSAAuthentication no 
RSAAuthentication yes 
PasswordAuthentication yes 
PermitEmptyPasswords no 
AllowUsers admin 

下面逐行说明上面的选项设置: 

Port 22 
“Port”设置sshd监听的端口号。 

ListenAddress 192.168.1.1 
“ListenAddress”设置sshd服务器绑定的IP地址。 

HostKey /etc/ssh/ssh_host_key 

“HostKey”设置包含计算机私人密匙的文件。 

ServerKeyBits 1024 
“ServerKeyBits”定义服务器密匙的位数。 

LoginGraceTime 600 
“LoginGraceTime”设置如果用户不能成功登录,在切断连接之前服务器需要等待的时间(以
秒为单位)。 

KeyRegenerationInterval 3600 
“KeyRegenerationInterval”设置在多少秒之后自动重新生成服务器的密匙(如果使用密匙)。
重新生成密匙是为了防止用盗用的密匙解密被截获的信息。 

PermitRootLogin no 
“PermitRootLogin”设置root能不能用ssh登录。这个选项一定不要设成“yes”。 

IgnoreRhosts yes 
“IgnoreRhosts”设置验证的时候是否使用“rhosts”和“shosts”文件。 

IgnoreUserKnownHosts yes 
“IgnoreUserKnownHosts”设置ssh daemon是否在进行RhostsRSAAuthentication安全验证
的时候忽略用户的“$HOME/.ssh/known_hosts” 

StrictModes yes 
“StrictModes”设置ssh在接收登录请求之前是否检查用户家目录和rhosts文件的权限和所
有权。这通常是必要的,因为新手经常会把自己的目录和文件设成任何人都有写权限。 

X11Forwarding no 
“X11Forwarding”设置是否允许X11转发。 

PrintMotd yes 
“PrintMotd”设置sshd是否在用户登录的时候显示“/etc/motd”中的信息。 

SyslogFacility AUTH 
“SyslogFacility”设置在记录来自sshd的消息的时候,是否给出“facility code”。 

LogLevel INFO 
“LogLevel”设置记录sshd日志消息的层次。INFO是一个好的选择。查看sshd的man帮
助页,已获取更多的信息。 

RhostsAuthentication no 
“RhostsAuthentication”设置只用rhosts或“/etc/hosts.equiv”进行安全验证是否已经足够了。 

RhostsRSAAuthentication no 
“RhostsRSA”设置是否允许用rhosts或“/etc/hosts.equiv”加上RSA进行安全验证。 

RSAAuthentication yes 
“RSAAuthentication”设置是否允许只有RSA安全验证。 

PasswordAuthentication yes 
“PasswordAuthentication”设置是否允许口令验证。 

PermitEmptyPasswords no 
“PermitEmptyPasswords”设置是否允许用口令为空的帐号登录。 

AllowUsers admin 
“AllowUsers”的后面可以跟着任意的数量的用户名的匹配串(patterns)或user@host这样
的匹配串,这些字符串用空格隔开。主机名可以是DNS名或IP地址

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics