lshell来限制一个用户的shell和切换目录和,命令

源码地址:https://github.com/ghantoos/lshell

部署:python setup.py install –no-compile –install-scripts=/usr/bin/
配置文件:/etc/lshell.conf 

root@centos-mysql01:~# cat /etc/lshell.conf|grep -vE '^$|^#'

[global]

logpath         : /var/log/lshell/

loglevel        : 2

path            : ['/root','/home/hanye','/usr','/data','/mnt']

[default]

allowed         : ['ls', 'echo','ll','grep','chmod','ip','ifconfig','ss']

forbidden       : [';', '&', '|','`','>','<', '$(', '${']

warning_counter : 2

aliases         : {'ll':'ls -l'}

strict          : 0

看出 只能执行:['ls', 'echo','ll','grep','chmod','ip','ifconfig','ss']
切换目录:['/root','/home/hanye','/usr','/data','/mnt']


指定用户使用次shell:chsh -s /usr/local/bin/lshell hanye

登陆查看

1.png

猜你喜欢

转载自blog.51cto.com/9025736/2324449