からの記事となります。
1.Debianインストール+ウイルス対策
2.NTP
3.FTP
4.SSH
5.Apache2
6.MYSQL5
7.PHP5
8.PHPとMYSQLの連携
この記事は4になります。
SSH自体はDebianの標準インストールで入ってしまう。
しかしデフォルトはパスワード方式になっているのでセキュリティ的にちょっと不安。
せっかくなので公開鍵方式に変更する。
調べてみるとどうやらSSHもRedhatでの設定と同じ方法でいけそうだ。
sshd_configの変更
# vi /etc/ssh/sshd_config
変更した箇所
#Port 22
Port *****
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#PermitRootLogin yes
PermitRootLogin no
#AuthorizedKeysFile %h/.ssh/authorized_keys
AuthorizedKeysFile %h/.ssh/authorized_keys2
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no
Port *****
#SyslogFacility AUTH
SyslogFacility AUTHPRIV
#PermitRootLogin yes
PermitRootLogin no
#AuthorizedKeysFile %h/.ssh/authorized_keys
AuthorizedKeysFile %h/.ssh/authorized_keys2
#ChallengeResponseAuthentication yes
ChallengeResponseAuthentication no
鍵の作成
# su - @@@@@ (@@@@@は、ログインするユーザ名)
# ssh-keygen -t rsa(SSH2の鍵を作成する SSH1の場合はrsaをrsa1にする)
Enter file in which to save the key (/home/@@@@@/.ssh/id_rsa):←空
Created directory '/home/@@@@@/.ssh'.←空
Enter passphrase (empty for no passphrase):←空
Enter same passphrase again:←空
Your identification has been saved in /home/@@@@@/.ssh/id_rsa.
Your public key has been saved in /home/@@@@@/.ssh/id_rsa.pub.
The key fingerprint is:
f0:c8:11:40:bb:92:b5:50:a9:19:88:ec:a9:3b:7b:1f user@hogehoge
# ssh-keygen -t rsa(SSH2の鍵を作成する SSH1の場合はrsaをrsa1にする)
Enter file in which to save the key (/home/@@@@@/.ssh/id_rsa):←空
Created directory '/home/@@@@@/.ssh'.←空
Enter passphrase (empty for no passphrase):←空
Enter same passphrase again:←空
Your identification has been saved in /home/@@@@@/.ssh/id_rsa.
Your public key has been saved in /home/@@@@@/.ssh/id_rsa.pub.
The key fingerprint is:
f0:c8:11:40:bb:92:b5:50:a9:19:88:ec:a9:3b:7b:1f user@hogehoge
この段階でのパスフレーズは空で作成する
これで秘密鍵(id_rsa)と公開鍵(id_rsa.pub)が、~/.ssh/ディレクトリ以下に作成される。
鍵の設定
公開鍵をauthorized_keys2に出力
# cd ~/.ssh
# cat id_rsa.pub >> authorized_keys2
# cat id_rsa.pub >> authorized_keys2
元の公開鍵を削除
# rm -f id_rsa.pub
公開鍵のパーミッションを変更
# chmod 600 authorized_keys2
秘密鍵をローカルに保存したらサーバから削除する
# rm -f id_rsa
SSHクライアントのインストール・設定
SSHクライアントのputtyをクライアントにインストールしておく
http://05xx.sub.jp/ttssh/putty/
puttygen.exeにてputty用に鍵を再構成する
サーバが作成した秘密鍵の読み込み
↓
勝手にPutty用にコンバートされる
↓
パスフレーズ入力
↓
保存
SSHログイン時その鍵を指定&パスフレーズ入力にてログインする。
うん、Redhatと全く同じ手順でいけた。