What is OpenSSH ssh-agent?

Host Key Not Cached Putty

About

ssh-agent is the authentication agent of Openssh.

It works on Linux and windows

It stores un/desencrypted private keys in memory, and communicates with SSH clients via Unix_domain_socket

Installation

Windows

Docker Limitations

With the windows agent:

2) By default the ssh-agent service is disabled.

  • Configure it to start automatically with a shell running as an Administrator.
Get-Service ssh-agent | Set-Service -StartupType Automatic
# start
Start-Service ssh-agent
# status
Get-Service ssh-agent
Status   Name               DisplayName
------   ----               -----------
Running  ssh-agent          OpenSSH Authentication Agent

(get-command ssh-agent.exe).path
C:\Windows\System32\OpenSSH\ssh-agent.exe

Linux

On Linux, the ssh-agent binary should already be available, if not use your package manager to install it

Example:

apt-get install openssh

Shell Configuration

Git bash

On Git bash, if you want to work with:

  • the windows ssh-agent, you need to configure it at installation.

Git Open Ssh

  • with the openssh of Git, see below the Posix Shell configuration

Posix Shell

In a posix shell, you start the ssh-agent and set the configuration variables with the following command:

ssh-agent -s
# where:
# ssh-agent starts the ssh-agent 
# -s generate commands on stdout
SSH_AUTH_SOCK=/tmp/ssh-asX1VgTTeGM3/agent.1848; export SSH_AUTH_SOCK;
SSH_AGENT_PID=1849; export SSH_AGENT_PID;
echo Agent pid 1849;

You can configure it to start automatically with the following command in .bashrc

eval `ssh-agent -s`

Key Operations

If your private key is not stored in one of the default locations (like ~/.ssh/id_rsa), you'll need to add them.

Add a key

Add a SSH private key to the ssh-agent created with keygen with the ssh-add

  • Posix Shell
ssh-add ~/.ssh/id_rsa
  • Powershell
ssh-add $env:USERPROFILE\.ssh\id_ed25519

Add all keys from a directory

ssh-add <directory to private SSH key>

List the keys

ssh-add -l

Return empty if there is no key

The agent has no identities.

Remove a key

ssh-add -d ~/.ssh/key-to-remove

Set an expiration

ssh-add -t <seconds>

Documentation / Reference





Discover More
Card Puncher Data Processing
Ansible - Connection

Connection parameters to hosts are given through variable. You can define the running user with the help of this two variable: ansible_user ( in a inventory file) remote_user in a Playbook ansible_userremote_userbecomeansible/ansible/issues/2004520045...
Host Key Not Cached Putty
How to add an encrypted private key with ssh-add via a script?

ssh-add is an openssh command that adds a key to the ssh-agent. By default, it will ask the passphrase for an encrypted private key, the script below shows you how to use SSH_ASKPASS...
Host Key Not Cached Putty
How to create a keypair with OpenSSH KeyGen?

Keygen is a OpenSSH tool that generates a new ssh keypair suitable for public key authentication Install OpenSsh Run ssh-keygen to create a keypair where: -t is the algorithm (implementation)...
Host Key Not Cached Putty
SSH - How to made an Ssh connection in a shell (for instance from Cygwin, CygwinX) ?

How to made an SSH connection to a Linux Operating system with a shell from a term, xterm of Cygwin, CygwinX ? Install the ssh component of Cygwin start the console and use this syntax: open-ssh...
Host Key Not Cached Putty
What is a SSH Authentication Agent?

An authentication agent is a ssh authentication component that serves private keys. It is a background process that stores your private keys in memory, already decoded. (an encrypted key will be first...
Host Key Not Cached Putty
What is the SSH command line tool? (OpenSsh)

The ssh cli is the ssh client of openssh See OpenSSH installation Identify file for public key authentication can be set in the config file. In the config file, by default, you have this configuration...



Share this page:
Follow us:
Task Runner