■SSHの設定 その2
ssh接続するのにパスワードと秘密鍵を利用してログインするように設定を変更しました。
以下のサイトを参考にしました。
・公開鍵認証を用いて SSH へ接続する
http://network.station.ez-net.jp/server/remote/Linux/ssh.key.asp
この手順を実施したログです。
[bobchan@bobchan ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/bobchan/.ssh/id_rsa): ←空Enter
Created directory '/home/bobchan/.ssh'.
Enter passphrase (empty for no passphrase): ←パスフレーズ入力
Enter same passphrase again: ←再度パスフレーズ入力
Your identification has been saved in /home/bobchan/.ssh/id_rsa.
Your public key has been saved in /home/bobchan/.ssh/id_rsa.pub.
The key fingerprint is:
29:5f:76:0a:80:72:d1:4d:69:32:50:4b:4a:e1:91:95 bobchan@bobchan.local
[bobchan@bobchan ~]$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
[bobchan@bobchan ~]$ chmod 600 ~/.ssh/authorized_keys
この ~/.ssh/id_rsaをローカルPCに置く
※あまりやってはいけないと思いますが、私はWinSCPでダウンロードしました。
[bobchan@bobchan .ssh]$ su -
Password:
[root@bobchan ~]# cd /etc/ssh
[root@bobchan ssh]# cp -p sshd_config sshd_config_20120128
[root@bobchan ssh]# vi sshd_config
変更箇所
PasswordAuthentication no パスワード認証を無効にする
[root@bobchan ssh]# diff sshd_config sshd_config_20120128
60c60
< PasswordAuthentication no
---
> PasswordAuthentication yes
[root@bobchan ssh]# service sshd restart
Stopping sshd: [ OK ]
Starting sshd: [ OK ]
これで次回以降のログインは、パスワードと秘密鍵を利用しないとsshでログインできなくなります。
ただ、WinSCPでログインするときはrsa_idを使うことができないので、
PuTTYgenを利用して秘密鍵を再作成します。
・PuTTYgenで公開鍵/秘密鍵を作成する
http://sourceforge.jp/projects/winscp/wiki/ui_puttygen
これでWinSCPでもログインできるようになります。
PS
今まで勉強したことを使って、さくらのVPS512でブログサーバを構築してみました。
・bobchan's cisco blog
http://hackerbobchan.net/wordpress/
こちらはciscoの勉強結果をまとめていく予定で、まだ見た目があまりきれいじゃないので、
もう少し見た目を良くしていこうと思います。