同じRasperry Piに繰り返しsshでアクセスするのに面倒なので、後悔カギ認証を設定します。
1.鍵の生成
~/.ssh ディレクトリで、ssh-keygenコマンドをただ実行すれば、対話的に作成できます。コマンドラインでオプションで指定してもいいのですが、覚えるのが面倒なので。
~/.ssh$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/USERNAME/.ssh/id_rsa): id_rsa_(ホスト名) Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in id_rsa_(ホスト名) Your public key has been saved in id_rsa_(ホスト名).pub The key fingerprint is: SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx (ユーザー名@ローカルホスト名) The key's randomart image is: +---[RSA 3072]----+ | =oo.. o +| | .+=o+ = o+| | . o.E* + o.+| | B o+O=.+ o| | . = =S+.+o.. +| | o o. o. . o.| | . | | | | | +----[SHA256]-----+ ~/.ssh$
2.接続先への転送
以下のようにssh-copy-idコマンドを使うと勝手にやってくれます。
~/.ssh$ ssh-copy-id -i id_rsa_(ホスト名).pub pi@(ホスト名).local
これで、
~/.ssh$ ssh pi@(ホスト名).local
で接続できます。全然簡単なのでした。