AIX上sudo的装置设备和应用.doc
文本预览下载声明
AIX上sudo的安装配置和使用
----BOSS2.0
何任重
一:介绍
在生产系统中帐号权限往往限制比较严格,但一些只有root用户才有权限运行的命令经常要使用,例如cicscp命令是最常用的管理CICS的命令,常见的操作例如启动/停止 CICS region等,默认情况下,只有root用户才有权限运行;又例如用stopServer.sh和startServer.sh重启WAS,虽然IBM工程师可以通过修改一堆文件的权限和属组能让一些用户执行这些操作,但比较麻烦。sudo能够简便的解决这些问题,通过配置sudo的配置文件可以让一些用户能运行只有root用户才有权限运行的命令。(sudo (su do) allows a system administrator to delegate authority to give certain users (or groups of users) the ability to run some (or all) commands as root or another user while providing an audit trail of the commands and their arguments.)本文简单介绍sudo的安装配置和使用。
二:注意事项
1:在修改文件前必须备份,以备回退或备查。
三:安装sudo
1:可以在 HYPERLINK /sudo/ /sudo/中下载到AIX上使用的sudo。
2:如果是bff类型的文件,用smit安装,安装后用lslpp可以看到sudo已经COMMITTED:
如果是rpm类型的文件,可以用rpm –ivh *.rpm安装;如果是source格式(需要编译,*.tar.gz),那先用gunzip和tar解压:
gunzip sudo-1.7.0.tar.gz
tar -xvf sudo-1.7.0.tar
再cd sudo-1.7.0到解压后的目录中运行./configure,做config和checking,再make(结束时是Target all is up to date.)再make install(结束时是Target install is up to date.),检查生成的sudo:
# cd /usr/local/bin
# ls -l|grep -i sudo
---s--x--x 2 root system 198778 Mar 07 20:42 sudo
---s--x--x 2 root system 198778 Mar 07 20:42 sudoedit
安装完成后,修改profile或environment等,在PATH中添加/usr/local/bin和/usr/local/sbin,重新登录后就可以使用sudo这个命令了。用sudo –V可以看到sudo的版本信息。
四:配置sudo配置文件和测试
1:sudo的配置文件是/etc/sudoers,可以用vi或visudo(用法和vi相同)修改它的内容。在/etc/sudoers最后添加:
oracle ALL=/test.sh
再建立测试使用的脚本/test.sh,属于root用户,属性是-rwxr--r--,只有root用户才能运行。用oracle用户登录,运行sudo /test.sh,就能运行只有root才有执行权限的/test.sh,但由于是首次运行,系统有如下提示信息:
We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these two things:
#1) Respect the privacy of others.
#2) Think before you type.
Password:
输入oracle用户的密码后就开始运行/test.sh了,再接下来的5分钟内如果再使用sudo的话就不用再输入密码。
2:NOPASSWD参数。在/etc/sudoers中使用NOPASSWD参数可以不需要用户输入用户自己的密码,这在crontab定时运行的脚本中可以用到,例如把上面的:oracle ALL=/test.sh
改为
oracle ALL=NOPASSWD:/test.sh
那oracle用户无论在什么时候运行sudo /test.sh
显示全部