如何避免在终端启动时总是输入 id_rsa 的密码?
How to avoid always entering passphrase for id_rsa on terminal startup?
目前每次我启动终端时都会收到以下提示:
Last login: Mon Nov 28 21:32:16 on ttys000
Agent pid 2733
Enter passphrase for /Users/my_name/.ssh/id_rsa:
能否指导我如何避免每次都输入密码?
您可以使用 ssh-agent
。手册页说:
ssh-agent is a program to hold private keys used for public key
authenti‐
cation (RSA, DSA, ECDSA, Ed25519). ssh-agent is usually 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).
进一步阅读你可以看到:
The agent initially does not have any private keys. Keys are added
using
ssh-add(1). When executed without arguments, ssh-add(1) adds the files
~/.ssh/id_rsa, ~/.ssh/id_dsa, ~/.ssh/id_ecdsa, ~/.ssh/id_ed25519 and
~/.ssh/identity. If the identity has a passphrase, ssh-add(1) asks for
the passphrase on the terminal if it has one or from a small X11 program
if running under X11. If neither of these is the case then the authenti‐
cation will fail. It then sends the identity to the agent. Several
identities can be stored in the agent; the agent can automatically use
any of these identities. ssh-add -l displays the identities currently
held by the agent.
您可能写了 ~/.bashrc
行
`eval ssh-agent`
ssh-add
或类似这样的东西。这意味着它会为你打开的每个 shell 启动一个新的 ssh-agent
,这当然不是你想要的。代理应该在您打开 Xsession (~/.xsession
) 时启动,或者您应该在 运行 新代理之前检查代理是否 运行:
[ -z $SSH_AUTH_SOCK ] && `eval ssh-agent` && ssh-add
您可以将您的密码添加到您的钥匙串中:
ssh-add -K ~/.ssh/id_rsa
或者您可以将其添加到您的 ~/.ssh/config
:
Host *
UseKeychain yes
目前每次我启动终端时都会收到以下提示:
Last login: Mon Nov 28 21:32:16 on ttys000
Agent pid 2733
Enter passphrase for /Users/my_name/.ssh/id_rsa:
能否指导我如何避免每次都输入密码?
您可以使用 ssh-agent
。手册页说:
ssh-agent is a program to hold private keys used for public key authenti‐ cation (RSA, DSA, ECDSA, Ed25519). ssh-agent is usually 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).
进一步阅读你可以看到:
The agent initially does not have any private keys. Keys are added using ssh-add(1). When executed without arguments, ssh-add(1) adds the files ~/.ssh/id_rsa, ~/.ssh/id_dsa, ~/.ssh/id_ecdsa, ~/.ssh/id_ed25519 and ~/.ssh/identity. If the identity has a passphrase, ssh-add(1) asks for the passphrase on the terminal if it has one or from a small X11 program if running under X11. If neither of these is the case then the authenti‐ cation will fail. It then sends the identity to the agent. Several identities can be stored in the agent; the agent can automatically use any of these identities. ssh-add -l displays the identities currently held by the agent.
您可能写了 ~/.bashrc
行
`eval ssh-agent`
ssh-add
或类似这样的东西。这意味着它会为你打开的每个 shell 启动一个新的 ssh-agent
,这当然不是你想要的。代理应该在您打开 Xsession (~/.xsession
) 时启动,或者您应该在 运行 新代理之前检查代理是否 运行:
[ -z $SSH_AUTH_SOCK ] && `eval ssh-agent` && ssh-add
您可以将您的密码添加到您的钥匙串中:
ssh-add -K ~/.ssh/id_rsa
或者您可以将其添加到您的 ~/.ssh/config
:
Host *
UseKeychain yes