linuxサーバで実行コマンドを制限するユーザを作成する時に使います。
セキュリティの件です!
すぐ忘れるのでメモです!
》 @IT:特定のコマンドしか実行できないユーザーIDを作成するには http://www.atmarkit.co.jp/flinux/rensai/linuxtips/363rbashuser.html
上の記事の通りです。
詳しくはこのままです。
% # 環境準備
% # ln -s /bin/bash /bin/rbash
% # /etc/shells にrbash登録
% vi /etc/shells
(省略)
/bin/csh
/bin/ksh
/bin/zsh
/bin/rbash ←この行を追加
%
% # 制限ユーザ追加
% useradd foo ←fooという専用のユーザーIDを作成
% passwd foo ←fooのパスワードを設定
% sudo - foo
$ chsh
foo のシェルを変更します。
Password: ←パスワードを入力
新しいシェル [/bin/bash]: /bin/rbash ←「/bin/rbash」を入力
シェルを変更しました。
$ exit
% cd /home/foo
% chown root .bash_profile ←.bash_profileの所有者をrootに変更
% chgrp root .bash_profile ←.bash_profileのグループをrootに変更
% chmod 755 .bash_profile ←.bash_profileのアクセス権を変更
% ls -al .bash_profile
-rwxr-xr-x 1 root root 238 Oct 15 01:31 .bash_profile
% mkdir bin
% #テキストエディタで.bash_profileを開いて、最下行に以下の記述を追加する。
% vi .bash_profile
(省略)
export PATH=/home/foo/bin
%
% # dfコマンドを実行可能にする
% ln -s /bin/df /home/foo/bin/df