小计一下(Restricted shell)

假如咱们须要限制一个Linux用户只能使用咱们指定的命令,那么可使用限制的shell。python

在正常的命令环境下使用:shell

测试:
# bash -r                     # 进入限制的shell
# cd /
bash: cd: restricted
# exit

具体设置:vim

# useradd test                # 添加用户
# cd bin
# ln -s bash rbash            # 设置软链接
# cd /home/test
# vim .bash_profile
    # .bash_profile
    
    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
            . ~/.bashrc
    fi    
    # User specific environment and startup programs
    
    #PATH=$PATH:$HOME/bin     # 注释掉原来的PATH路径
    PATH=$HOME/.bin
    
    export PATH
# mkdir .bin
# ln -s /bin/ls .bin/
# ln -s /bin/cat .bin/
# ln -s /bin/touch .bin/      # 给用户指定命令

#
# vim /etc/passwd
    test:x:502:502::/home/test:/bin/rbash        # 修改shell为rbash
    
#
# passwd test

到此配置结束,登录测试:bash

wKiom1UL03Pyymq3AAHJuVyyfs8844.jpg


测试效果仍是很明显的。具体的限制的shell有哪些限制,wiki上有详细的说明:ide


wKiom1UL1AKSpu0HAAFT1lgW_A0248.jpg



点击链接地址.测试

相关文章
相关标签/搜索