因为公司奇葩需求,须要给全部开发用户开通全部服务器的只能查看权限,结合现有jumpserver实现扩展,搭建jumpserver省略,推送一个普通用户
接下来的操做都是在系统里,这里我写了一个脚本用于实现,只容许check_user用户执行 cat ls tail tailf命令linux
#!/bin/bash User="check_user" Command="cat ls tail tailf" ln -s /bin/bash /bin/rbash User_alive=`cat /etc/passwd | grep check_user|wc -l` if [ $User_alive -eq 1 ] then sed -i "/$User/s/\/bin\/bash/\/bin\/rbash/" /etc/passwd mkdir /home/$User/bin touch /home/$User/.bash_profile if [ -f /home/$User/.bash_profile ] then chown root. /home/$User/.bash_profile chmod 755 /home/$User/.bash_profile echo > /home/$User/.bash_profile cat >> /home/$User/.bash_profile <<EOF # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=\$HOME/bin EOF else echo "profile is not exist" exit "6" fi else echo "User is not exist" exit 5 fi for i in $Command do dir=`whereis $i | awk "{print $2}"` ln -s $dir /home/$User/bin done
实现后发现后续问题目前尚未解决
1,本想把cd加上,可是centos是能够,ubuntu是不能够,由于cd在ubuntu里不算命令是内置内核里的,不知怎么解决
2,tab补全功能有的机器能够,有的不能够不知道为何 ubuntu