Linux下通过受限bash创建指定权限的账号代码详解
本文研究的主要是在Linux下通过受限bash创建指定权限的账号的相关内容,具体介绍如下。
在日常业务运维中,有时为了配合解决问题,需要给非运维人员开通系统账号,用于查询日志或代码。通常为了系统安全或避免不必要的误操作等目的,会将账号权限降至最低。下面介绍下在Linux下通过受限bash创建指定权限账号的操作记录:
[root@mq-server ~]# ln -s /bin/bash /bin/rbash[root@mq-server ~]# useradd -s /bin/rbash wangshibo[root@mq-server ~]# passwd wangshibo[root@mq-server ~]# mkdir /home/wangshibo/bin[root@mq-server ~]# chown root. /home/wangshibo/.bash_profile[root@mq-server ~]# chmod 755 /home/wangshibo/.bash_profile[root@mq-server ~]# vim /home/wangshibo/.bash_profile //复制下面的内容覆盖原内容# .bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then . ~/.bashrcfi# User specific environment and startup programsPATH=$HOME/binexport PATH
[root@mq-server ~]# ln -s /bin/cat /home/wangshibo/bin/cat[root@mq-server ~]# ll /home/wangshibo/total 4drwxr-xr-x 2 root root 4096 Nov 25 23:38 bin[root@mq-server ~]# ll /home/wangshibo/bin/total 0lrwxrwxrwx 1 root root 8 Nov 25 23:12 cat -> /bin/cat



