0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【Mac】ssh接続のたびにパスワード聞かれるのをなくす方法

Posted at

はじめに

秘密鍵・公開鍵を発行すればSSH接続できるようになります。
ただ、それだけではSSH接続するたびにパスワードを求められます。

これを解消するためにはSSH Agentに秘密鍵を登録する必要があります。
さらに、Macを再起動しても登録状態を保持するには、Keychainにも登録して初回SSH接続時に読み込むよう設定します。


登録手順

  1. SSH Agent登録の際にapple-use-keychainオプションをつける

    ssh-add --apple-use-keychain ~/.ssh/id_rsa
    

    これでKeychainにも登録できます。


  2. ~/.ssh/configに読み込み設定を書き込む

    Host *
    UseKeychain yes
    AddKeysToAgent yes
    

これで完了です。お疲れさまでした!


(補足)登録解除するには...

  1. SSH Agentから削除する

    ssh-add -d ~/.ssh/id_rsa
    

  2. Keychainからも削除する
    Spotlight(⌘+Space)「キーチェーン」と検索してキーチェーンアクセスを開く
    右上の検索窓から削除したい鍵を検索する
    右クリックで削除する

これでMacを再起動すれば解除されます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?