ssh-agent
ssh-agent is a program to hold private keys used for public key authentication (RSA, DSA, ECDSA, ED25519).
The idea is that ssh-agent is started in the beginning of an X-session or a login session, and all other windows or programs are started as clients to the ssh-agent program.
Through use of environment variables the agent can be located and automatically used for authentication when logging in to other machines using ssh(1).
できること
ローカルの鍵をリモートに置くことなく、リモートでも使う
例:ssh先からローカルの鍵を使ってGitHubにアクセスする
sshのパスフレーズを設定しつつ、毎回入力しないようにする
macOSのkeychainに保存する
You can use ssh-agent to securely save your passphrase so you don't have to reenter it.
Working with SSH key passphrases - User Documentation
設定
Generating a new SSH key and adding it to the ssh-agent - User Documentationのとおりに設定すればいい
ssh-agentをバックグラウンドプロセスとして立ち上げる
ssh-addでagentに秘密鍵を登録する
その他の参考資料
ssh-agentの使い方 - Qiita
ログアウトすると UNIXドメインソケットが消える対策
ssh-agentを利用して、安全にSSH認証を行う - Qiita
macOSでは-Kをつけてkeychainに覚えさせることができる
使う
Aオプションを付けるだけ
ssh -A でagentの情報を引き継ぎつつログインできる
#Linux