LinuxSir.cn,穿越时空的Linuxsir!

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

怎样限制系统用户在自家目录里?

[复制链接]
发表于 2003-12-31 11:16:52 | 显示全部楼层 |阅读模式
假设有个系统用户guest;/home/guest
   我向限制guest用户telnet上来之后,只能在/home/guest内活动,不能访问系统的其他资源!大哥们帮帮小弟!
发表于 2003-12-31 13:10:56 | 显示全部楼层
除非改成认证的用户,比如带认证的FTP用户,否则好象不能。
发表于 2003-12-31 15:58:31 | 显示全部楼层
几乎所有的ftp软件都可以那样控制,telnet和ssh这就不懂了
发表于 2004-1-1 11:42:27 | 显示全部楼层
我也想知道;
....
有了,
用alias命令!
你可以设一个shell script
来断定用户是否在它的目录下:
mycd.bash:
.................
然后更改cd命令:
#chmod 755 $mycd_path/mycd
在用户的.bash_profile中加入以下一句:
alias cd $mycd_path/mycd
最后,更改.bash_profile的用户属主和权限:
#chown root .bash_profile
#chmod rwsr-xr-x .bash_profile
————————————————————
ok
为了防止用户改回它的cd
加入下面一句
alias alias "echo 'Error:you can not use alias.'"
发表于 2004-1-1 23:47:34 | 显示全部楼层
正确的方法应该是用restricted shell

http://www.faqs.org/docs/bashman/bashref_75.html

6.10 The Restricted Shell

If Bash is started with the name rbash, or the `--restricted' option is supplied at invocation, the shell becomes restricted. A restricted shell is used to set up an environment more controlled than the standard shell. A restricted shell behaves identically to bash with the exception that the following are disallowed:

    * Changing directories with the cd builtin.
    * Setting or unsetting the values of the SHELL, PATH, ENV, or BASH_ENV variables.
    * Specifying command names containing slashes.
    * Specifying a filename containing a slash as an argument to the . builtin command.
    * Specifying a filename containing a slash as an argument to the `-p' option to the hash builtin command.
    * Importing function definitions from the shell environment at startup.
    * Parsing the value of SHELLOPTS from the shell environment at startup.
    * Redirecting output using the `>', `>|', `<>', `>&', `&>', and `>>' redirection operators.
    * Using the exec builtin to replace the shell with another command.
    * Adding or deleting builtin commands with the `-f' and `-d' options to the enable builtin.
    * Specifying the `-p' option to the command builtin.
    * Turning off restricted mode with `set +r' or `set +o restricted'.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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