LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

ssh-agent

TLDR

Start ssh-agent and set environment variables
$ eval $(ssh-agent)
copy
Start agent in background for current shell
$ ssh-agent -s
copy
Start with C-shell compatible output
$ ssh-agent -c
copy
Kill the running agent
$ ssh-agent -k
copy
Run a command with agent environment
$ ssh-agent [command]
copy
Set key lifetime (default is forever)
$ ssh-agent -t [1h]
copy

SYNOPSIS

ssh-agent [-c | -s] [-Dd] [-a SOCKET] [-t LIFE] [COMMAND [ARGS...]]ssh-agent [-c | -s] -k

DESCRIPTION

ssh-agent is a program that holds private keys used for SSH public key authentication. The agent runs in the background and provides keys to SSH clients without requiring passphrase re-entry.Keys are added to the agent using ssh-add. Once added, the agent responds to authentication requests from SSH connections, including forwarded agent connections from remote hosts.The agent outputs shell commands to set environment variables (SSHAUTHSOCK and SSHAGENTPID). These must be evaluated in the shell using eval $(ssh-agent) to enable communication between SSH clients and the agent.

PARAMETERS

-s

Generate Bourne shell commands on stdout.
-c
Generate C-shell commands on stdout.
-k
Kill the current agent (using SSHAGENTPID).
-d
Debug mode (don't fork).
-D
Foreground mode without debug output.
-a SOCKET
Bind to specified Unix socket instead of random.
-t LIFE
Default maximum lifetime for added keys (e.g., 1h, 30m).

INSTALL

sudo apt install openssh-client
copy
sudo apk add openssh-client-common
copy

CAVEATS

The agent keeps decrypted private keys in memory. If compromised, all loaded keys are exposed. Use -t to limit key lifetime. Agent forwarding (-A in ssh) should be used carefully as remote hosts can use your agent. Kill the agent when done with sensitive sessions.

HISTORY

ssh-agent was developed as part of OpenSSH, originally created by Tatu Ylönen and later maintained by the OpenBSD project. The agent model allows secure key storage while enabling passwordless SSH connections, and has become the standard approach for managing SSH keys across all major platforms.

SEE ALSO

ssh-add(1), ssh(1), ssh-keygen(1), sshd(8)

RESOURCES

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid