---
name: "ssh-agent"
section: "1"
platform: "openbsd"
package: "man"
version: "8.0-current-20261101"
release: "OpenBSD 8.0-current (2026-11-01)"
platforms: ["linux", "freebsd", "openbsd", "macos"]
url: "https://new.carta.tech/ssh-agent"
---

# ssh-agent(1)

OpenSSH authentication agent

## NAME

**ssh-agent** – OpenSSH authentication agent

## SYNOPSIS

**ssh-agent** \[**-c** \| **-s**\] \[**-DdU**\] \[**-T** \| **-A** *directory* \| **-a** *bind\_address*\] \[**-E** *fingerprint\_hash*\] \[**-O** *option*\] \[**-P** *allowed\_providers*\] \[**-t** *life*\]

**ssh-agent** \[**-U**\] \[**-T** \| **-A** *directory* \| **-a** *bind\_address*\] \[**-E** *fingerprint\_hash*\] \[**-O** *option*\] \[**-P** *allowed\_providers*\] \[**-t** *life*\] *command* \[*arg* *...*\]

**ssh-agent** \[**-c** \| **-s**\] **-k**

**ssh-agent** **-u**

**ssh-agent** **-V**

## DESCRIPTION

**ssh-agent** is a program to hold private keys used for public key authentication. 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/1.md).

The options are as follows:

- **-a** *bind\_address*

  Bind the agent to the UNIX-domain socket *bind\_address*. The default is to create a socket in the *$HOME/.ssh/agent* directory using a random path matching *s.\**.

- **-A** *socket\_path*

  Specify a different directory path under which to create the socket. Sockets may be created in either a shared location or a user-specific directory. User-specific directories are specified by prefixing the path name with **user:**. **ssh-agent** will ensure the directory exists and create the listening socket directly in it. Relative user-specific directory paths will be created to the user's $HOME.

  Shared directories may be specified by prefixing an absolute path name with **shared:**. In this case, a temporary subdirectory will be created under the specified directory and the listening agent socket will be created in that.

  This option accepts the tokens described in the [sshd\_config(5)](/sshd_config/5.md) TOKENS section.

- **-c**

  Generate C-shell commands on standard output. This is the default if SHELL looks like it's a csh style of shell.

- **-D**

  Foreground mode. When this option is specified, **ssh-agent** will not fork.

- **-d**

  Debug mode. When this option is specified, **ssh-agent** will not fork and will write debug information to standard error.

- **-E** *fingerprint\_hash*

  Specifies the hash algorithm used when displaying key fingerprints. Valid options are: “md5” and “sha256”. The default is “sha256”.

- **-k**

  Kill the current agent (given by the SSH\_AGENT\_PID environment variable).

- **-O** *option*

  Specify an option when starting **ssh-agent**. The supported options are: **allow-remote-pkcs11**, **no-restrict-websafe** and **websafe-allow**.

  The **allow-remote-pkcs11** option allows clients of a forwarded **ssh-agent** to load PKCS#11 or FIDO provider libraries, and to remove PKCS#11 providers. By default only local clients may perform these operations. Note that signalling that an **ssh-agent** client is remote is performed by [ssh(1)](/ssh/1.md), and use of other tools to forward access to the agent socket may circumvent this restriction.

  The **no-restrict-websafe** option instructs **ssh-agent** to permit signatures using FIDO keys that might be web authentication requests. By default, **ssh-agent** refuses signature requests for FIDO keys where the key application string does not start with “ssh:” and when the data to be signed does not appear to be an [ssh(1)](/ssh/1.md) user authentication request or an [ssh-keygen(1)](/ssh-keygen/1.md) signature. The default behaviour prevents forwarded access to a FIDO key from also implicitly forwarding the ability to authenticate to websites.

  Alternately the **websafe-allow** option allows specifying a pattern-list of key application strings to replace the default application allow-list, for example: “websafe-allow=ssh:\*,example.org,\*.example.com”

  See PATTERNS in [ssh\_config(5)](/ssh_config/5.md) for a description of pattern-list syntax.

- **-P** *allowed\_providers*

  Specify a pattern-list of acceptable paths for PKCS#11 provider and FIDO authenticator middleware shared libraries that may be used with the **-S** or **-s** options to [ssh-add(1)](/ssh-add/1.md). Libraries that do not match the pattern list will be refused. The default list is “/usr/lib/\*,/usr/local/lib/\*”.

  See PATTERNS in [ssh\_config(5)](/ssh_config/5.md) for a description of pattern-list syntax.

- **-s**

  Generate Bourne shell commands on standard output. This is the default if SHELL does not look like it's a csh style of shell.

- **-T**

  Bind the agent socket in a randomised subdirectory of the form *$TMPDIR/ssh-XXXXXXXXXX/agent.ppid*, instead of the default behaviour of using a randomised name matching *$HOME/.ssh/agent/s.\**.

- **-t** *life*

  Set a default value for the maximum lifetime of identities added to the agent. The lifetime may be specified in seconds or in a time format specified in [sshd\_config(5)](/sshd_config/5.md). A lifetime specified for an identity with [ssh-add(1)](/ssh-add/1.md) overrides this value. Without this option the default maximum lifetime is forever.

- **-U**

  Instructs **ssh-agent** not to clean up stale agent sockets under *$HOME/.ssh/agent/*.

- **-u**

  Instructs **ssh-agent** to only clean up stale agent sockets under *$HOME/.ssh/agent/* and then exit immediately. If this option is given twice, **ssh-agent** will delete stale agent sockets regardless of the host name that created them.

- *command* \[*arg* *...*\]

  If a command (and optional arguments) is given, this is executed as a subprocess of the agent. The agent exits automatically when the command given on the command line terminates.

- **-V**

  Display the version number and exit.

There are two main ways to get an agent set up. The first is at the start of an X session, where all other windows or programs are started as children of the **ssh-agent** program. The agent starts a command under which its environment variables are exported, for example **ssh-agent** **xterm** **&**. When the command terminates, so does the agent.

The second method is used for a login session. When **ssh-agent** is started, it prints the shell commands required to set its environment variables, which in turn can be evaluated in the calling shell, for example **eval** **\`ssh-agent** **-s\`**.

In both cases, [ssh(1)](/ssh/1.md) looks at these environment variables and uses them to establish a connection to the agent.

The agent initially does not have any private keys. Keys are added using [ssh-add(1)](/ssh-add/1.md) or by [ssh(1)](/ssh/1.md) when **AddKeysToAgent** is set in [ssh\_config(5)](/ssh_config/5.md). Multiple identities may be stored in **ssh-agent** concurrently and [ssh(1)](/ssh/1.md) will automatically use them if present. [ssh-add(1)](/ssh-add/1.md) is also used to remove keys from **ssh-agent** and to query the keys that are held in one.

Connections to **ssh-agent** may be forwarded from further remote hosts using the **-A** option to [ssh(1)](/ssh/1.md) (but see the caveats documented therein), avoiding the need for authentication data to be stored on other machines. Authentication passphrases and private keys never go over the network: the connection to the agent is forwarded over SSH remote connections and the result is returned to the requester, allowing the user access to their identities anywhere in the network in a secure fashion.

**ssh-agent** will delete all keys it has loaded upon receiving SIGUSR1.

## ENVIRONMENT

- SSH\_AGENT\_PID

  When **ssh-agent** starts, it stores the name of the agent's process ID (PID) in this variable.

- SSH\_AUTH\_SOCK

  When **ssh-agent** starts, it creates a UNIX-domain socket and stores its pathname in this variable. It is accessible only to the current user, but is easily abused by root or another instance of the same user.

## FILES

- *$HOME/.ssh/agent/s.\**

  UNIX-domain sockets used to contain the connection to the authentication agent. These sockets should only be readable by the owner. The sockets should get automatically removed when the agent exits.

## SEE ALSO

[ssh(1)](/ssh/1.md), [ssh-add(1)](/ssh-add/1.md), [ssh-keygen(1)](/ssh-keygen/1.md), [ssh\_config(5)](/ssh_config/5.md), [sshd(8)](/sshd/8.md)

## AUTHORS

OpenSSH is a derivative of the original and free ssh 1.2.12 release by Tatu Ylonen. Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo de Raadt and Dug Song removed many bugs, re-added newer features and created OpenSSH. Markus Friedl contributed the support for SSH protocol versions 1.5 and 2.0.
