ssh-agent
Quick Reference
Command Name:
ssh-agent
Category:
networking
Platform:
Linux/Unix/Windows
Basic Usage:
Common Use Cases
- 1
SSH key management
Manage SSH keys in the SSH agent for password-less authentication
- 2
Security
Ensure secure communication between systems
- 3
Scripting
Use in shell scripts to automate SSH key management
- 4
Remote administration
Administer remote systems securely
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).