これも何度もやったことがあるのですが記憶に残っておらず、NAS のユーザー名を「taro」から「moheno」に変えたので ssh に関しても変更する必要があります。
例によって chatGPT に訊きました。この辺に関しては chatGPT は完璧です。
最近は Ed25519 の方が推奨されることも多いようです。
ssh-keygen -t ed25519 -C "your_email@example.com"your_email@example.com は大した意味はないようで、何のキーかわからなくなるのでコメントのような役割ということらしいです。
以下のようなコマンドを実行します。
cat ~/.ssh/id_ed25519.pub | ssh -p 12345 moheno@192.168.0.20 "mkdir -p ~/.ssh && cat >> ~/.ssh/authorized_keys && chmod 700 ~/.ssh && chmod 600 ~/.ssh/authorized_keys"たったこれだけで以下のようなことが実行されます。
以下のようにしてログインを確認します。
moheno@moheno-Vostro-3681:~$ ssh -p 12345 moheno@192.168.0.20
Using terminal commands to modify system configs, execute external binaryfiles, add files, or install unauthorized third-party apps may lead to systemdamages or unexpected behavior, or cause data loss. Make sure you are aware ofthe consequences of each command and proceed at your own risk.
Warning: Data should only be stored in shared folders. Data stored elsewheremay be deleted when the system is updated/restarted.
moheno@NAS720:~$chatGPT ってすごいですね。