ssh-agent
is a utility in Linux and Unix-like operating systems that is used to store private keys for secure shell (SSH) authentication. It allows you to use your private keys to authenticate with remote servers without having to enter a passphrase every time.
Here's how to use ssh-agent
for authentication on Linux or Unix:
ssh-agent
service. To start the ssh-agent
service, run the following command:eval "$(ssh-agent -s)"
This will start the ssh-agent
service in the background, and set the necessary environment variables for the current shell session.
ssh-agent
. To add your private keys to the ssh-agent
, use the ssh-add
command. Specify the path to the private key file as an argument.For example, to add the private key ~/.ssh/id_rsa
, you can use the following command:
ssh-add ~/.ssh/id_rsa
ssh-agent
will automatically use your private keys for authentication. You will not be prompted for a passphrase.For example, to connect to a remote server with the hostname example.com
, you can use the following command:
ssh user@example.com
If you have multiple private keys added to ssh-agent
, it will try each one in turn until it finds one that is accepted by the remote server.
It's important to protect your private keys, as they can be used to gain access to your servers and other resources. Make sure to store them in a secure location, and use strong passphrases to protect them.