ssh-agent
Quick Reference
Command Name:
ssh-agent
Category:
networking
Platform:
Linux/Unix/Windows
Basic Usage:
Common Use Cases
- 1
Key management
Start an authentication agent to securely store private keys in memory
- 2
Passwordless login
Enable SSH connections without having to enter your passphrase each time
- 3
Session-based security
Keep keys available for the duration of a login session but encrypted on disk
- 4
Shell integration
Integrate with different shell environments using the appropriate output format
Syntax
ssh-agent [options] [command [args ...]]
Options
Option | Description |
---|---|
-a socket | Bind the agent to a specific UNIX-domain socket |
-c | Generate C-shell commands on stdout |
-d | Debug mode |
-k | Kill the current agent (given by the SSH_AGENT_PID environment variable) |
-s | Generate Bourne shell commands on stdout (default) |
-t seconds | Set a default maximum lifetime for identities added to the agent |
Examples
How to Use These Examples
The examples below show common ways to use the ssh-agent
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
Basic Usage:
ssh-agent
Start the SSH agent and output shell commands for setting the required environment variables.
eval $(ssh-agent)
Start the SSH agent and set the environment variables in the current shell.
ssh-agent bash
Start the SSH agent and spawn a new bash shell with the correct environment variables.
eval $(ssh-agent) && ssh-add
Start the SSH agent, set environment variables, and load the default SSH keys.
Managing the Agent:
ssh-agent -k
Kill the running SSH agent process.
ssh-agent -t 3600
Start an agent that will automatically expire after 1 hour (3600 seconds).