Home

SSHAGENTPID

SSH_AGENT_PID is the environment variable used by OpenSSH to store the process ID of the ssh-agent running for the current user session. The canonical name is SSH_AGENT_PID (with an underscore); some sources or typings may refer to it informally as SSHAGENTPID, but the variable in practice is SSH_AGENT_PID. It is set when ssh-agent is started and its value is exported to the shell so that SSH clients can locate and communicate with the agent.

When a user starts ssh-agent, typically via commands like eval "$(ssh-agent -s)" or by using a session

The SSH_AGENT_PID value is primarily used to manage the agent process. Programs can read the PID to

Security considerations include protecting the agent’s socket path (SSH_AUTH_SOCK) and ensuring environment variables are not exposed

See also: SSH_AUTH_SOCK, ssh-agent, ssh-add, key management tools.

manager,
the
agent
outputs
a
line
that
assigns
SSH_AGENT_PID
to
the
agent’s
process
ID
and
SSH_AUTH_SOCK
to
the
path
of
the
agent’s
Unix
domain
socket.
Exporting
these
variables
allows
subsequent
SSH
tools
to
find
the
agent
without
knowing
its
specific
PID
or
socket
name.
send
signals
to
the
agent,
for
example
to
terminate
it
with
a
controlled
shutdown
using
kill
"$SSH_AGENT_PID".
It
also
serves
as
a
sanity
check:
if
the
PID
no
longer
corresponds
to
a
running
ssh-agent,
scripts
may
need
to
restart
the
agent
or
refresh
environment
variables.
to
untrusted
processes.
If
the
agent
dies
or
is
restarted,
SSH_AGENT_PID
changes
and
users
should
reinitialize
their
environment
accordingly.