1. install
cd /usr/ports/security/sudo
make install clean
2. configure
编辑sudo的配置文件/usr/local/etc/sudousers 直接用visudo就可以了
visudo
在最后面添加如下一行,允许svn用户能以root权限,并且不需要root密码,执行adduser svn两个命令
svn ALL = NOPASSWD: /usr/local/bin/svn, /usr/sbin/adduser
3. test
first
add a new user svn have no root perrmit
second
add the user to the sodu configure file sudousers use visudo
third
login with user svn
type the command adduser
adduser: ERROR: you must be the super-user (uid 0) to use this utility.
typethe command sudo adduser
$ sudo adduser
Username: svn2
Full name: svn2.svn
Uid (Leave empty for default):
Login group [svn2]:
Login group is svn2. Invite svn2 into other groups? []:
Login class [default]:
Shell (sh csh tcsh bash rbash nologin) [sh]:
Home directory [/home/svn2]:
Use password-based authentication? [yes]: y
Use an empty password? (yes/no) [no]: n
Use a random password? (yes/no) [no]: n
Enter password:
Enter password again:
Lock out the account after creation? [no]: n
Username : svn2
Password : *****
Full Name : svn2.svn
Uid : 1005
Class :
Groups : svn2
Home : /home/svn2
Shell : /bin/sh
Locked : no
OK? (yes/no): y
adduser: INFO: Successfully added (svn2) to the user database.
Add another user? (yes/no): n
Goodbye!
$ id svn2
uid=1005(svn2) gid=1005(svn2) groups=1005(svn2)
这就说明了sudo配置成功
参考文档:
Sudoers Manual
阅读(759) | 评论(0) | 转发(0) |