LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 785|回复: 6

这样的脚本该如何写?

[复制链接]
发表于 2005-1-26 15:17:23 | 显示全部楼层 |阅读模式
我的目的是在脚本中su到root,直接在脚本中写入密码,不出现密码输入,然后在root用户下用nalutils打开某一个root用户专有的目录。试了n久都会出现密码输入。
发表于 2005-1-26 16:14:58 | 显示全部楼层
最好把该普通用户加入到wheel组,并确保/etc/pam.d/su设定大致如下(注意红色部分):

  1. #%PAM-1.0

  2. auth       sufficient   /lib/security/pam_rootok.so

  3. # If you want to restrict users begin allowed to su even more,
  4. # create /etc/security/suauth.allow (or to that matter) that is only
  5. # writable by root, and add users that are allowed to su to that
  6. # file, one per line.
  7. #auth       required     /lib/security/pam_listfile.so item=ruser sense=allow onerr=fail file=/etc/security/suauth.allow

  8. [color=red]# Uncomment this to allow users in the wheel group to su without
  9. # entering a passwd.
  10. auth       sufficient   /lib/security/pam_wheel.so use_uid trust[/color]

  11. # Alternatively to above, you can implement a list of users that do
  12. # not need to supply a passwd with a list.
  13. #auth       sufficient   /lib/security/pam_listfile.so item=ruser sense=allow onerr=fail file=/etc/security/suauth.nopass

  14. # Comment this to allow any user, even those not in the 'wheel'
  15. # group to su
  16. auth       required     /lib/security/pam_wheel.so use_uid

  17. auth       required     /lib/security/pam_stack.so service=system-auth

  18. account    required     /lib/security/pam_stack.so service=system-auth

  19. password   required     /lib/security/pam_stack.so service=system-auth

  20. session    required     /lib/security/pam_stack.so service=system-auth
  21. session    required     /lib/security/pam_env.so
  22. [color=red]session    optional     /lib/security/pam_xauth.so[/color]

复制代码
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-1-26 16:58:06 | 显示全部楼层
这样是实现了su不用密码了,但是su后控制台停下了,出现root的提示,一定要退出才能执行下面的语句,也就是说仍然不是root权限执行下面的东西。如果用su &可以持续执行,但权限仍然不是root。
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-1-26 17:13:13 | 显示全部楼层
搞定了root打开nauiltis的问题,但是如何在打开的时候定位到一个目录呢?
回复 支持 反对

使用道具 举报

发表于 2005-1-28 23:45:32 | 显示全部楼层
nauiltis dir
回复 支持 反对

使用道具 举报

发表于 2005-1-29 01:14:50 | 显示全部楼层
用sudo行不?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-1-31 09:50:20 | 显示全部楼层
搞定了,thx
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表