Bug 1699 - [patch] Enhance SSH to automatically add keys to ssh-agent
Summary: [patch] Enhance SSH to automatically add keys to ssh-agent
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: ssh (show other bugs)
Version: 5.3p1
Hardware: amd64 OpenBSD
: P2 enhancement
Assignee: Assigned to nobody
URL: http://article.gmane.org/gmane.networ...
Keywords: needs-release-note, patch
Depends on:
Blocks:
 
Reported: 2010-01-19 11:25 AEDT by Joachim Schipper
Modified: 2016-08-02 10:41 AEST (History)
3 users (show)

See Also:


Attachments
[patch] Automatically add keys to ssh-agent(1) (22.03 KB, patch)
2010-01-19 11:25 AEDT, Joachim Schipper
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Joachim Schipper 2010-01-19 11:25:43 AEDT
Created attachment 1780 [details]
[patch] Automatically add keys to ssh-agent(1)

[Continuing a mailing list thread; see http://article.gmane.org/gmane.network.openssh.devel/16422.]

My keys are secured with a passphrase. That's good for security, but having to type the passphrase either at every login or at every invocation of ssh(1) is annoying.

It's possible to hack around this annoyance, but such hacks are inevitably brittle. OpenSSH should just do quietly do the right thing, as it does in other cases.

Please find included a patch (against OpenBSD's OpenSSH) to fix this. By way of specification, I'll quote ssh_config(5):

     AddKeysToAgent
             Specifies whether keys should be automatically added to ssh-agent(5) (if running).  If this option is set to ``yes'' and a key is loaded from a file, this key and all keys with either the same or an empty passphrase are added to the agent (with the default lifetime), as if by ssh-add(1).  If this option is set to ``ask'', ssh will require confirmation using the SSH_ASKPASS pro- gram before adding a key (see ssh-add(1) for details).  If this option is set to ``confirm'', each use of the key must be confirmed, exactly as if the -c option was specified to ssh-add(1).  If this option is set to ``no'', no keys are added to the agent.  The argument must be ``yes'', ``confirm'', ``ask'', or ``no''.  The default is ``no''.

This is my first patch, so please review thoroughly! I'll happily make any changes requested.

		Joachim

P.S. This patch has been completely rewritten (relative to the patch posted to the mailing list, above) to support adding all keys with the same passphrase at once.
Comment 1 joshua stein 2015-11-16 09:33:53 AEDT
A more basic version of this concept (only adding the key used, not all that match the same passphrase) was just committed to the OpenBSD tree, so I think this can be considered resolved.
Comment 2 Damien Miller 2016-08-02 10:41:15 AEST
Close all resolved bugs after 7.3p1 release