因爲公司奇葩需求,須要給全部開發用戶開通全部服務器的只能查看權限,結合現有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