SSH key manager, the ssh-agent command is a program that controls the private key used to store public key authentication. The ssh-Agent starts at the beginning of the X session or login session, and all other Windows or programs start as client programs and are added to the Ssh-Agent program. By using environment variables, agents can be located and used for automatic authentication when logging on to other machines using SSH.

In fact, the ssh-Agent is a key manager. After running the ssh-Agent, run the ssh-add command to transfer the private key to the Ssh-Agent for storage. When other programs require authentication, they can submit authentication requests to the Ssh-Agent to complete the authentication process.

We think you’re using an SSH key to authenticate access. To avoid re-entering the password when you start the SSH Agent, you can type the following two commands

SSH /id_rsa: Add a private key and keep it with the SSH agent. In this way, you do not need to enter the password next time

Command syntax

ssh-agent [-c | -s] [-d] [-a bind_address] [-t life] [command [arg ...]]
ssh-agent [-c | -s] -k
Copy the code

Command options

  • -a bind_address: bind the agent to the UNIx-domain socket bind_address.
  • -c: generates c-shell command output.
  • -d: debugging mode.
  • -k: Kills the ssh-agent process.
  • -s: generates Bourne shell-style command output.
  • -t life: Sets the default value to add to the agent’s maximum identity life.

Run the SSH – agent

> ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-lWA15nOUhcYG/agent.26310; export SSH_AUTH_SOCK;
SSH_AGENT_PID=26315; export SSH_AGENT_PID;
echo Agent pid 26315;
Copy the code

Run ssh-Agent, which prints out the environment and variables it uses.

Run debug mode with the -d parameter

> ssh-agent -d
Copy the code

Run the -k parameter to kill the ssh-agent process

> ssh-agent -k
Copy the code

ssh-agentUsage scenarios of

If different keys are used to connect to different hosts, manually specify the corresponding keys. Ssh-agent can help you select the corresponding key for authentication, and you do not need to manually specify the key for connection.

If the private key has a password and you need to use the private key frequently for authentication, the ssh-agent can help you avoid repeated password input operations.

Original link :rumenz.com/rumenbiji/l… Wechat official account: entry station