sshのポートを外部に開く設定をするため、従来のplain passwordによるログインからRSA認証によるログインに設定を改めることにした。
/etc/ssh/sshd_configの設定ポイントは以下の通り。
PermitRootLogin no
RSAAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
RhostsAuthentication no
RhostsRSAAuthentication no
HostbasedAuthentication no
PasswordAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
AllowUsers hogehoge
次にユーザhogehogeになって、
$ ssh-keygen -t rsa1
Generating public/private rsa1 key pair.
Enter file in which to save the key (/home/hogehoge/.ssh/identity):
Created directory '/home/hogehoge/.ssh'.
Enter passphrase (empty for no passphrase): ←パスワードを入力
Enter same passphrase again: ←もう一度パスワードを入力
$ cd .ssh/
$ cp identity.pub authorized_keys
そして、rootになってsshdを再起動。
# /etc/rc.d/init.d/sshd restart
あとは秘密鍵identityをWindowsのTTSHのフォルダにコピーして完了。
====================
実は、RSA認証を設定する前に半日ばかり、
PasswordAuthentication yes
のままの状態でルーターの#22ポートを開いて実験していたところ、さっそくアムステルダムから辞書攻撃と思われるアタックがあった。
幸いにも侵入を許した形跡はないが、
anonymous, bruce, chuck, darkman, hostmaster, jeffrey, loverd, eric, lauren, mark, sin, fluffy, gold, tomcat, concinus, httpd, (以下省略・・・)
など、多数のユーザ名でログインを試みているではないか!
PermitRootLogin no
の設定はもともとしておいたからよかったものの、大事に至らなくてよかった。
ポートを一つ開くだけでも途端にこんなにたくさんのアタックがあるとは、正直言って驚いた。
現在はftpポートも開いていないが、何かサービスを公開するたびにセキュリティには十分注意を払う必要があることを今さらながら実感した。
