OpenSSHサーバの構築OpenSSHの確認
サーバを遠隔操作する場合、セキュリティを考慮すると暗号化されたSSHでのみ接続できるようにしておきます。
telnetやftpは暗号化せずに平文でやりとりするので、危険です。opensshでtelnet及びscpで接続します。 $ rpm -qa | grep openssh openssh-3.6.1p2-33.30.3 openssh-server-3.6.1p2-33.30.3 openssh-askpass-3.6.1p2-33.30.3 openssh-clients-3.6.1p2-33.30.3 openssh-askpass-gnome-3.6.1p2-33.30.3 opensshの設定ファイル/etc/ssh/sshd_config設定ファイルに記述されているので、コメントをはずして設定を行います。 PermitRootLogin no <-- root権限でのログインを禁止 PasswordAuthentication no <-- 公開鍵方式で認証 PermitEmptyPasswords no <-- 空パスワードの禁止 再起動して、設定を反映させます。 # /etc/init.d/sshd restart sshdを停止中: [ OK ] sshdを起動中: [ OK ] 鍵の作成SSH1とSSH2が作成できますが、ここではセキュリティレベルの高いほうのSSH2を作成します。
$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/hoge/.ssh/id_rsa): <-- enter(鍵の保存先) Created directory '/home/hoge/.ssh'. Enter passphrase (empty for no passphrase): <-- パスフレーズの入力 Enter same passphrase again: <-- パスフレーズの再入力 Your identification has been saved in /home/hoge/.ssh/id_rsa. Your public key has been saved in /home/hoge/.ssh/id_rsa.pub. The key fingerprint is: ??:??:??:??:??:??:??:??:??:??:??:??:??:??:??:?? hoge@localhost
$ ls -la /home/hoge/.ssh/ 合計 32 -rw------- 1 hoge hoge 951 2月 15 16:36 id_rsa <-- 秘密鍵 -rw-r--r-- 1 hoge hoge 238 2月 15 16:36 id_rsa.pub <-- 公開鍵
$ cd $ cat ./id_rsa.pub >> ./authorized_keys $ chmod 600 ./authorized_keys $ rm ./id_rsa.pub
$ rm ./id_rsa おすすめ書籍
|