zoukankan      html  css  js  c++  java
  • 限制用户执行特定的命令

    1、有些特定的需求下面可能要限制某些用户能执行的命令

    在root用户下操作:

    创建一个目录,放在/下面:

    mkdir  /allow_commands

    新增一个受限的用户:

    adduser connect

    echo "123456" | passwd --stdin connect

    取消用户的执行命令权限:

    setfacl -m u:connect:0 /usr/bin/*

    setfacl -m u:connect:0 /usr/sbin/*

    setfacl -m u:connect:0 /usr/local/bin/*

    授权命令:

    setfacl -m u:connect:5 /usr/bin/bash

    setfacl -m u:connect:5 /usr/bin/ls

    setfacl -m u:connect:5 /usr/bin/tty

    setfacl -m u:connect:5 /usr/bin/id

    cp /usr/bin/ls /allow_commands/

    cp /usr/bin/tty /allow_commands/

    cp /usr/bin/id /allow_commands/

    设置用户的.bash_profile

    cat /home/connect/.bash_profile

    # .bash_profile

    # Get the aliases and functions
    if [ -f ~/.bashrc ]; then
    . ~/.bashrc
    fi

    # User specific environment and startup programs

    #PATH=$PATH:$HOME/.local/bin:$HOME/bin
    PATH=/allow_commands
    export PATH

  • 相关阅读:
    北科的秋天
    最大子段和问题(dp)
    cmd应用
    问题 H: 抽奖活动(大数)
    大数算法
    模板整理(三)
    在CMD中建立一个不能删除的文件
    波利亚(Polya)罐子模型
    51nod-迷宫问题(Dijkstra算法)
    优先队列
  • 原文地址:https://www.cnblogs.com/cuishuai/p/11901614.html
Copyright © 2011-2022 走看看