ユーザーが/ binでのみコマンドを実行するように制限する方法は?

ユーザーが/ binでのみコマンドを実行するように制限する方法は?

私はいくつかの質問がある課題を受けました。質問の1つは次のとおりです。

ユーザーがディレクトリでのみコマンドを実行するように制限する方法は/bin

問題を解決するために、次のコマンドを試しましたが、うまくいきません。

# useradd -s /bin/bash localuser
# usermod -s /bin/rbash localuser
# mkdir /home/localuser/programs

内容は次のとおりです/home/localuser/.bash_profile

# .bash_profile  

# Get the aliases and functions  
if [ -f ~/.bashrc ]; then  
. ~/.bashrc  
fi  
# User specific environment and startup programs  
PATH=$HOME/programs  
export PATH

次に、次のことを試してください。

[localuser@example ~]$ ls  
-rbash: ls: command not found  
[localuser@example ~]$ less file1  
-rbash: less: command not found  
[localuser@example ~]$ clear  
-rbash: clear: command not found  
[localuser@example ~]$ date  
-rbash: date: command not found  
[localuser@example ~]$ ping redhat.com  
-rbash: ping: command not found
# ln -s /bin/date /home/localuser/programs/  
# ln -s /bin/ls /home/localuser/programs/  
# ll /home/localuser/programs/  
total 8  
lrwxrwxrwx 1 root root 9 Oct 17 15:53 date -> /bin/date  
lrwxrwxrwx 1 root root 7 Oct 17 15:43 ls -> /bin/ls
[localuser@example ~]$ date  
Mon Oct 17 15:55:45 IST 2011  
[localuser@example ~]$ ls  
file1 file10 file2 file3 file4 file5 file6 file7 file8 file9 programs  
[localuser@example ~]$ clear  
-rbash: clear: command not found
# chattr +i /home/localuser/.bash_profile

あなたの答えは何ですか?

ベストアンサー1

完全に従ったようです。この回答またはリンクするように指示。ただし、特定のコマンドのみを実行するようにユーザーを制限する方法を具体的に示します。この例では、コマンドはwheredateとですls。しかし、ユーザーが/bin特定のコマンドだけでなく、すべてのコマンドを実行できるようにしたいという点で質問が異なります。したがって、個々のコマンドをリンクするのではなく、ディレクトリ全体を接続しようとしています。あなたはこれを行うことができるはずですln

おすすめ記事