MacでSSHをパスフレーズ認証にする

「ターミナル」起動

秘密鍵、公開鍵を生成

$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/main/.ssh/id_rsa): ←エンターキー
Enter passphrase (empty for no passphrase): ←パスフレーズ入力
Enter same passphrase again: ←パスフレーズ入力
Your identification has been saved in /Users/main/.ssh/id_rsa.
Your public key has been saved in /Users/main/.ssh/id_rsa.pub.
The key fingerprint is:
34:21:bb:53:e4:7*************1:ce:b7 main@oho-masayuki-no-macbook.local
The key's randomart image is:
+--[ RSA 2048]----+
|      . o ..+.+ .|
|       = o o.O = |
 〜〜〜〜〜〜
|      o S     .E |
|                 |
+-----------------+

.ssh/にid_rsa(秘密鍵)、id_rsa.pub(公開鍵)が生成される。

公開鍵をサーバに登録

パスフレーズsshログインしたいサーバの、
$HOME/.ssh/authorized_keys
に公開鍵をコピペして追記。
なければ、新規作成後「$ chmod 600 ファイル」で本人しか読めない権限にしておく。

確認

秘密鍵を持っているmacから公開鍵を登録したサーバにsshコマンドでログインすると、
パスワードの変わりにパスフレーズが聞かれるようになる。

公開鍵のサンプル
ssh-rsa AAA*****************************CVxuEX31dCWsQ== main@*****-no-macbook.local