5. OSPN
root権限の取り扱い
A. 直接rootでログインさせる?
– sshdの設定で制御可能
– 公開鍵認証でrootとしてログインさせる
• パスワード認証は無効化
B. 一般ユーザでログインさせる?
a. suコマンドを実行してrootに変更
• システム設定作業が多いインストール直後には向いて
いる
b. sudoコマンドを実行してroot権限でコマンド実行
• コマンド実行履歴が/var/log/secureに記録される
6. OSPN
su コマンド実行の制限
• PAMを設定してwheelグループ所属のユー
ザのみsuコマンドを実行できるように設定
• suコマンド実行時にrootのパスワードを要
求しないようにも設定できる
• /etc/pam.d/suを編集
# Uncomment the following line to implicitly trust users in the "wheel" group.
#auth sufficientpam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the "wheel" group.
#auth required pam_wheel.so use_uid
26. OSPN
公開鍵・秘密鍵の作成
$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/home/user/.ssh/id_rsa): (エンターキー)
Created directory '/home/user/.ssh'.
Enter passphrase (empty for no passphrase): (パスフレーズは非表示)
Enter same passphrase again: (パスフレーズは非表示)
Your identification has been saved in /home/user/.ssh/id_rsa.
Your public key has been saved in /home/user/.ssh/id_rsa.pub.
The key fingerprint is:
b9:52:95:18:24:3c:83:91:9d:8d:76:06:0e:7a:b7:c2 user@centos6.example.com
↑フィンガープリントは公開鍵のハッシュ値
(略)
$ ls -l .ssh
合計 8
-rw-------. 1 user user 1743 11月 18 15:28 2015 id_rsa ←秘密鍵
-rw-r--r--. 1 user user 406 11月 18 15:28 2015 id_rsa.pub ←公開鍵
26
29. OSPN
公開鍵のサーバへの転送
• 最初は安全なネットワークで作業
A) ターミナルに対してコピー&ペースト
– 公開鍵は単なるテキストなので
B) scpコマンドやsftpコマンドで転送
– SELinuxが有効な場合、/tmpなどに転送して、
そのファイルをコピーして使わないこと(必ず
catコマンドでauthorized_keysに流し込む)
C) ssh-copy-idコマンドを実行
– 転送からauthorized_keys配置まで自動実行
29
30. OSPN
sshコマンドで接続
$ ssh sshuser@server.example.com
The authenticity of host 'server.example.com
(192.168.0.102)' can't be established.
RSA key fingerprint is
e3:ea:71:a7:b6:e8:6b:2e:27:f9:83:a5:0f:63:95:13.
Are you sure you want to continue connecting
(yes/no)? yes ←yesと入力
Warning: Permanently added
'server.example.com,192.168.0.102' (RSA) to the
list of known hosts.
Enter passphrase for key
'/home/user/.ssh/id_rsa': (パスフレーズを入力。非表示)
[sshuser@server ~]$
30