Forrest logo
back to the ssh-add tool

ssh:tldr:21ba0

ssh: Add a key to the ssh-agent and the keychain.
$ ssh-add -K ${path-to-private_key}
try on your machine

This command, "ssh-add -K ${path-to-private_key}", is used to add a private key to the SSH Agent on macOS.

Here's a breakdown of each part:

  • "ssh-add": This is the command-line tool used to add private keys to the SSH Agent. It manages private keys for SSH connections, allowing you to authenticate with remote servers without having to enter a password each time.

  • "-K": This flag is specific to macOS and tells the ssh-add command to store the private key in the user's keychain, providing more secure storage and automatic key loading upon login.

  • "${path-to-private_key}": This is the placeholder for the actual path to your private key file. In the command, you need to replace "${path-to-private_key}" with the actual path to your private key file.

For example, if your private key file is located at "/Users/username/.ssh/id_rsa", the command would look like this:

"ssh-add -K /Users/username/.ssh/id_rsa"

By executing this command, the private key specified by the path will be added to the SSH Agent on macOS, allowing you to use it for authentication without manually entering the key's passphrase each time you establish an SSH connection.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the ssh-add tool