SSHの設定
- 「root」でログインさせない
- 空のパスワードでログインさせない
- パスワードではなく鍵認証とする
/etc/ssh/sshd_config
PermitRootLogin no
PubkeyAuthentication yes
PasswordAuthenticatio no
PermitEmptyPasswords no
SSH再起動
再起動させると同時に、自動起動としておく。
systemctl stop sshd.service
systemctl enable --now sshd.service
鍵認証設定
一般ユーザーで行う
鍵認証用の鍵ペア作成
色々と問われるが、全て「空Enter」とする
ssh-keygen -t ed25519 -a 256
・パスフレーズを設定する場合
ssh-keygen -t ed25519 -a 256 -N "パスフレーズ"
・GitHubで使用する書きを作成する場合
ssh-keygen -t ed25519 -a 256 -C user@example.com
公開鍵設定
cd
cat .ssh/id_ed25519.pub > authorized_keys
chmod 600 .ssh/authorized_keys
rm -f .ssh/id_ed25519.pub
秘密鍵設定
秘密鍵は、一般ユーザーのホームディレクトリに移動した後の.ssh/id_ed25519
となる。
重要なファイルであるため、SCP等で移動させ、ローカルに保存しておく。
この秘密鍵を利用し、サーバーへと公開鍵接続を行う
Windowsの場合、
https://kmiya-culti.github.io/RLogin/
https://www.ranvis.com/putty
https://poderosa.sourceforge.net/index-ja.html
このあたりのSSHクライアントがオススメです。