サーバーのリモート管理でipmitoolを使う際、-P
オプションでパスワードをコマンドラインの中で指定すると画面上で丸見えですね。ipmitoolにはパスワード関連で-a
、-E
、-f
オプションがあるのでまとめておきます。
-P <password>
-P
オプションはBMCのパスワードをコマンドラインで指定します。サポートされている場合、ps aux
などのプロセスリストではパスワードが非表示になります。man ipmitool(1)でもこのオプションは非推奨ですね。
# ipmitool -I lanplus -H 172.25.130.28 -U user -P password sol activate
[SOL Session operational. Use ~? for help]
# ps aux
root 353369 0.0 0.1 8900 2236 pts/1 S+ 19:23 0:00 ipmitool -I lanplus -H 172.25.130.28 -U user -P XXXXXXXXXX sol activate
-a
-a
オプションはコマンド実行前にBMCパスワードの入力を求めるプロンプトを表示します。OSのログインプロンプトと同じで入力したパスワードは非表示です。ipmitoolを対話的に使う場合はこれもありですね。
# ipmitool -I lanplus -H 172.25.130.25 -U user -a fru
Password:
-E
-E
オプションは環境変数IPMI_PASSWORD
に設定した値を読み取りパスワードとしてコマンドを実行します。これはprintenv
を実行すると見えてしまいますね。変数名も分かりやすいですしね。
# ipmitool -I lanplus -H 172.25.130.25 -U user -E fru
Unable to read password from environment
Password:
#
#
# export IPMI_PASSWORD=password
#
# ipmitool -I lanplus -H 172.25.130.25 -U user -E fru
#
# printenv
SHELL=/bin/bash
HISTCONTROL=ignoredups
...
IPMI_PASSWORD=password
-f
ファイルにBMCのパスワードを保存し、そのファイルを-f
オプションで指定しコマンドを実行します。chmod 400
などとしておけば他のアカウントからは読み書きできず安全ですね。
# echo password > pwfile.txt
#
# chmod 400 pwfile.txt
#
# ls -l
total 8
-rw-------. 1 root root 1420 Oct 24 21:02 anaconda-ks.cfg
-r--------. 1 root root 11 Dec 3 19:49 pwfile.txt
#
# ipmitool -I lanplus -H 172.25.130.25 -U admin -f ./pwfile.txt fru