キモであるssh設定。しかしデフォルト設定だとまずいのである!なぜかというと、海外からrootアカウント奪取しようと苛烈な攻撃加えてくることがあるから。
要求仕様は以下のとおり。
というわけで、設定する。設定例は Ubuntu と Arch を並列でかく。
#Port 22 Port 12321
PermitRootLogin no #PermitRootLogin yes #PermitRootLogin prohibit-password
# PasswordAuthentication yes PasswordAuthentication no
#PubkeyAuthentication yes PubkeyAuthentication yes
$ ssh-keygen -t ed25519 ---以下のファイルができるので、秘密鍵id_rsaはLinux各種クライアントの.ssh/以下にコピー、WindowsのPuTTYだったらid_rsaをppkファイルに変換したい。 公開鍵: ~/.ssh/id_ed25519.pub 秘密鍵: ~/.ssh/id_ed25519 + 古い環境向けなら ssh-keygen -t rsa で、 公開鍵: ~/.ssh/id_rsa.pub 秘密鍵: ~/.ssh/id_rsa + ecdsa にするなら ssh-keygen -t ecdsa -b 521 でやるべきってことかなぁ。
$ cat ~/.ssh/id_ed25519.pub | ssh hoge_user@hogehoge.hoge.com 'cat >> .ssh/authorized_keys' $ cat ~/.ssh/id_rsa.pub | ssh hoge_user@hogehoge.hoge.com 'cat >> .ssh/authorized_keys'
$ sudo systemctl restart sshd
$ sudo service restart ssh