科普Solaris系统安全

作者:amxku
来源:amxku’s blog

==维护密码和登录控制
==监控系统使用情况
==限制文件访问
==root用户登录
==控制通过网络的远程访问


==维护密码和登录控制
pwconv命令:使用/etc/passwd文件的信息创建和升级/etc/shadow文件。
如果系统中/etc/shadow文件不存在,使用/etc/passwd文件信息创建/etc/shadow文件。
如果系统中/etc/shadow文件存在,执行如下操作:
存在在/etc/passwd文件但不存在在/etc/shadow文件中的用户将被增加到/etc/shadow文件中。
存在在/etc/shadow文件但不存在在/etc/passwd文件中的用户将被从/etc/shadow文件中删除。一般我们会在用名后面加上*LK*来锁定该用户。
==监控系统使用情况
显示系统中登录的用户
# who (调用/var/adm/utmpx文件中的信息)
显示系统中登录的用户的详细信息
# finger username
# finger username@remotehostname
-m:仅仅匹配用户名

显示系统中所有登录活动的记录
# last (调用/var/adm/wtmpx文件中的信息)
# last username
# last reboot

显示远程系统中登录的用户
# rusers -l

==改变文件权限
chown命令:用于改变文件的属主

 命令格式:chown [ option(s) ] user_name filename(s)
chown [ option(s) ] UID filename(s)
例如:
# chown user2 file7
# chown -R user2 dir4
# chown user3:class file2
# chown -R user3:class dir1  

chgrp命令:用于改变文件的数组

 命令格式:chgrp groupname filename(s)
chgrp GID filename(s)
例如:
# chgrp class file4  

==Root 用户登录
直接使用root用户名登录,输入root用户的密码。
使用普通用户登录,然后调用su命令转变为root用户。
su命令:允许用户不用登录就可以改变成另外一个用户。
命令格式:su [ – ] [ username ]
root用户可以不需要密码使用su命令转换到其它任何用户。
除root用户外,其它任何用户使用su命令转换时都必须首先知道转换后的用户的密码。
-:执行一个完整登录。根据创建用户时设定的配置文件来改变用户工作环境。

管理用户访问

 /etc/default/su
/etc/default/login
/etc/default/passwd  
 # more su
#ident     "@(#)su.dfl         1.6         93/08/14 SMI"     /* SVr4.0 1.2     */
# SULOG determines the location of the file used to log all su attempts
SULOG=/var/adm/sulog
# CONSOLE determines whether attempts to su to root should be logged
# to the named device
#CONSOLE=/dev/console
# PATH sets the initial shell PATH variable
#PATH=/usr/bin:
# SUPATH sets the initial shell PATH variable for root
#SUPATH=/usr/sbin:/usr/bin
# SYSLOG determines whether the syslog(3) LOG_AUTH facility should be used
# to log all su attempts.     LOG_NOTICE messages are generated for su's to
# root, LOG_INFO messages are generated for su's to other users, and LOG_CRIT
# messages are generated for failed su attempts.
SYSLOG=YES  
 # more login
#ident     "@(#)login.dfl     1.10     99/08/04 SMI"     /* SVr4.0 1.1.1.1         */
# Set the TZ environment variable of the shell.
#
#TIMEZONE=EST5EDT
# ULIMIT sets the file size limit for the login.     Units are disk blocks.
# The default of zero means no limit.
#
#ULIMIT=0
# If CONSOLE is set, root can only login on that device.
# Comment this line out to allow remote login by root.
#
CONSOLE=/dev/console  

限制root访问
CONSOLE=/dev/console
Root用户只能在console口上登录,任何其它的root用户登录都将报错。
# CONSOLE=/dev/console
Root用户能够从任何设备上登录,包括网络、Modem、其它终端等。
CONSOLE=
Root用户不能从任何地方登录。要成为root用户只有一个办法,首先使用普通用户登录,然后使用su命令转换为root用户。切记,在禁用root远程登录之前一定要确保系统里还有其它的用户可以登录。不然就会出现惊险的Solaris加固过程[http://www.amxku.net/archives/reinforcement-solaris/]。

用户密码策略

 # more passwd
#ident     "@(#)passwd.dfl 1.3         92/07/14 SMI"
MAXWEEKS=27 #密码最长存活周期
MINWEEKS=1 #密码最短存活周期
PASSLENGTH=8 #密码长度最小值
MINALPHA=2 ;MINNONALPHA=1 #至少包括两个字母和一个非字母
#  

注意:/etc/shadow文件中设置的时间优先级高于/etc/default/passwd文件中设置的时间

管理远程访问

 /etc/hosts.equiv 文件
$HOME/.rhosts 文件
/etc/ftpusers 文件  

==远程访问流程

amxku_at_msn.com
给用户培训时写的一个文档。个人拙见,有不妥之处还望斧正。

相关日志

发表评论