创建受限制的linux用户

1.创建一个受限用户组(如ifconfig)
2.创建一个受限用户(如ifconfig)
3.修改用户密码
3.修改/etc/passwd
更改此用户的登陆后的HOME路径,和登陆的shell (自己任意指定)
ifconfig:x : 510 : 500 : /home/users/ifconfig : /bin/bash
4.在此用户登陆的HOME路径下,建立bin目录(作为此用户登陆后的$PATH目录)
将此目录属性设为700,改变目录所有者为ifconfig
5.以root身份将允许此用户运行的可执行命令copy至此bin目录。并修改它的文件属性,添加Uid和Gid(使受限用户通过此命令对系统进行配置)。
6.修改用户登陆的配置文件:
修改用户下的.bash_profile 文件。
将PATH = 修改为指定的目录,来起到限制用户运行命令的作用。
并添加命令来显示友好的提示信息和屏蔽shell 内建函数。
添加信息列表如下:

echo "                  ------------welcome -----------"
echo ""
echo "                              ifconfig"
echo "                  -------------------------------"
enable –n .
enable -n :
enable -n cd
enable -n [
enable -n alias
enable -n bg
enable -n bind
enable -n break
enable -n builtin
enable -n caller
enable -n command
enable -n compgen
enable -n complete
enable -n continue
enable -n declare
enable -n dirs
enable -n disown
enable -n eval
enable -n exec
enable -n export
enable -n false
enable -n fc
enable -n fg
enable -n getopts
enable -n hash
enable -n help
enable -n history
enable -n jobs
enable -n kill
enable -n let
enable -n local
enable -n logout
enable -n popd
enable -n printf
enable -n pushd
enable -n pwd
enable -n read
enable -n readonly
enable -n return
enable -n set
enable -n shift
enable -n shopt
enable -n source
enable -n suspend
enable -n test
enable -n times
enable -n trap
enable -n unset
enable -n unalias
enable -n ulimit
enable -n wait
enable -n typeset
enable -n type
enable -n true
enable -n umask
enable -n echo
enable -n enable (将本enable命令进行屏蔽,使用户不能通过本命令去掉屏蔽)

说明:未屏蔽的shell内建函数有exit。

7.修改 /etc/bashrc
删除或屏蔽掉 里面的 alias 和其他定义命令

8.屏蔽 which命令
删除或者屏蔽掉 etc/profile.d/which-2.csh 和 which-2.sh文件里的which定

此篇文章已被阅读2885 次

Add a Comment

邮箱地址不会被公开。 必填项已用*标注