xref: /netbsd-src/crypto/external/bsd/openssh/dist/ssh-add.1 (revision 1c7715dda22cf2bd169e2f84953c050393e8fe9c)
1*1c7715ddSchristos.\"	$NetBSD: ssh-add.1,v 1.20 2024/07/08 22:33:44 christos Exp $
2*1c7715ddSchristos.\"	$OpenBSD: ssh-add.1,v 1.87 2024/06/17 08:30:29 djm Exp $
3ca32bd8dSchristos.\"
4ca32bd8dSchristos.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
5ca32bd8dSchristos.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
6ca32bd8dSchristos.\"                    All rights reserved
7ca32bd8dSchristos.\"
8ca32bd8dSchristos.\" As far as I am concerned, the code I have written for this software
9ca32bd8dSchristos.\" can be used freely for any purpose.  Any derived versions of this
10ca32bd8dSchristos.\" software must be clearly marked as such, and if the derived work is
11ca32bd8dSchristos.\" incompatible with the protocol description in the RFC file, it must be
12ca32bd8dSchristos.\" called by a name other than "ssh" or "Secure Shell".
13ca32bd8dSchristos.\"
14ca32bd8dSchristos.\"
15ca32bd8dSchristos.\" Copyright (c) 1999,2000 Markus Friedl.  All rights reserved.
16ca32bd8dSchristos.\" Copyright (c) 1999 Aaron Campbell.  All rights reserved.
17ca32bd8dSchristos.\" Copyright (c) 1999 Theo de Raadt.  All rights reserved.
18ca32bd8dSchristos.\"
19ca32bd8dSchristos.\" Redistribution and use in source and binary forms, with or without
20ca32bd8dSchristos.\" modification, are permitted provided that the following conditions
21ca32bd8dSchristos.\" are met:
22ca32bd8dSchristos.\" 1. Redistributions of source code must retain the above copyright
23ca32bd8dSchristos.\"    notice, this list of conditions and the following disclaimer.
24ca32bd8dSchristos.\" 2. Redistributions in binary form must reproduce the above copyright
25ca32bd8dSchristos.\"    notice, this list of conditions and the following disclaimer in the
26ca32bd8dSchristos.\"    documentation and/or other materials provided with the distribution.
27ca32bd8dSchristos.\"
28ca32bd8dSchristos.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
29ca32bd8dSchristos.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
30ca32bd8dSchristos.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
31ca32bd8dSchristos.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
32ca32bd8dSchristos.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
33ca32bd8dSchristos.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
34ca32bd8dSchristos.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
35ca32bd8dSchristos.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
36ca32bd8dSchristos.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
37ca32bd8dSchristos.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38ca32bd8dSchristos.\"
39*1c7715ddSchristos.Dd June 17 2024
40ca32bd8dSchristos.Dt SSH-ADD 1
41ca32bd8dSchristos.Os
42ca32bd8dSchristos.Sh NAME
43ca32bd8dSchristos.Nm ssh-add
44ed75d7a8Schristos.Nd adds private key identities to the OpenSSH authentication agent
45ca32bd8dSchristos.Sh SYNOPSIS
46ca32bd8dSchristos.Nm ssh-add
47c5555919Schristos.Op Fl CcDdKkLlqvXx
48e4d43b82Schristos.Op Fl E Ar fingerprint_hash
49a03ec00cSchristos.Op Fl H Ar hostkey_file
50a03ec00cSchristos.Op Fl h Ar destination_constraint
51ed75d7a8Schristos.Op Fl S Ar provider
52ca32bd8dSchristos.Op Fl t Ar life
53ca32bd8dSchristos.Op Ar
54ca32bd8dSchristos.Nm ssh-add
5534b27b53Sadam.Fl s Ar pkcs11
56c5555919Schristos.Op Fl Cv
57514b5d45Schristos.Op Ar certificate ...
58ca32bd8dSchristos.Nm ssh-add
5934b27b53Sadam.Fl e Ar pkcs11
60aa36fcacSchristos.Nm ssh-add
61aa36fcacSchristos.Fl T
62aa36fcacSchristos.Ar pubkey ...
63ca32bd8dSchristos.Sh DESCRIPTION
64ca32bd8dSchristos.Nm
65185c8f97Schristosadds private key identities to the authentication agent,
66ca32bd8dSchristos.Xr ssh-agent 1 .
67ca32bd8dSchristosWhen run without arguments, it adds the files
68ca32bd8dSchristos.Pa ~/.ssh/id_rsa ,
698a4530f9Schristos.Pa ~/.ssh/id_ecdsa ,
70ed75d7a8Schristos.Pa ~/.ssh/id_ecdsa_sk ,
71*1c7715ddSchristos.Pa ~/.ssh/id_ed25519
72ca32bd8dSchristosand
73*1c7715ddSchristos.Pa ~/.ssh/id_ed25519_sk .
7434b27b53SadamAfter loading a private key,
7534b27b53Sadam.Nm
7634b27b53Sadamwill try to load corresponding certificate information from the
7734b27b53Sadamfilename obtained by appending
7834b27b53Sadam.Pa -cert.pub
7934b27b53Sadamto the name of the private key file.
80ca32bd8dSchristosAlternative file names can be given on the command line.
8134b27b53Sadam.Pp
82ca32bd8dSchristosIf any file requires a passphrase,
83ca32bd8dSchristos.Nm
84ca32bd8dSchristosasks for the passphrase from the user.
85ca32bd8dSchristosThe passphrase is read from the user's tty.
86ca32bd8dSchristos.Nm
87ca32bd8dSchristosretries the last passphrase if multiple identity files are given.
88ca32bd8dSchristos.Pp
89ca32bd8dSchristosThe authentication agent must be running and the
90ca32bd8dSchristos.Ev SSH_AUTH_SOCK
91ca32bd8dSchristosenvironment variable must contain the name of its socket for
92ca32bd8dSchristos.Nm
93ca32bd8dSchristosto work.
94ca32bd8dSchristos.Pp
95ca32bd8dSchristosThe options are as follows:
96ca32bd8dSchristos.Bl -tag -width Ds
97c5555919Schristos.It Fl C
98c5555919SchristosWhen loading keys into or deleting keys from the agent, process
99c5555919Schristoscertificates only and skip plain keys.
100ca32bd8dSchristos.It Fl c
101ca32bd8dSchristosIndicates that added identities should be subject to confirmation before
102ca32bd8dSchristosbeing used for authentication.
1034054ffb0SchristosConfirmation is performed by
1044054ffb0Schristos.Xr ssh-askpass 1 .
1054054ffb0SchristosSuccessful confirmation is signaled by a zero exit status from
1064054ffb0Schristos.Xr ssh-askpass 1 ,
1074054ffb0Schristosrather than text entered into the requester.
108ca32bd8dSchristos.It Fl D
109ca32bd8dSchristosDeletes all identities from the agent.
110ca32bd8dSchristos.It Fl d
111ca32bd8dSchristosInstead of adding identities, removes identities from the agent.
112ca32bd8dSchristosIf
113ca32bd8dSchristos.Nm
114ce11a51fSchristoshas been run without arguments, the keys for the default identities and
115ce11a51fSchristostheir corresponding certificates will be removed.
116ca32bd8dSchristosOtherwise, the argument list will be interpreted as a list of paths to
117ce11a51fSchristospublic key files to specify keys and certificates to be removed from the agent.
118ca32bd8dSchristosIf no public key is found at a given path,
119ca32bd8dSchristos.Nm
120ca32bd8dSchristoswill append
121ca32bd8dSchristos.Pa .pub
122ca32bd8dSchristosand retry.
1232d3b0f52SchristosIf the argument list consists of
1242d3b0f52Schristos.Dq -
1252d3b0f52Schristosthen
1262d3b0f52Schristos.Nm
1272d3b0f52Schristoswill read public keys to be removed from standard input.
128e4d43b82Schristos.It Fl E Ar fingerprint_hash
129e4d43b82SchristosSpecifies the hash algorithm used when displaying key fingerprints.
130e4d43b82SchristosValid options are:
131e4d43b82Schristos.Dq md5
132e4d43b82Schristosand
133e4d43b82Schristos.Dq sha256 .
134e4d43b82SchristosThe default is
135e4d43b82Schristos.Dq sha256 .
13634b27b53Sadam.It Fl e Ar pkcs11
13734b27b53SadamRemove keys provided by the PKCS#11 shared library
13834b27b53Sadam.Ar pkcs11 .
139a03ec00cSchristos.It Fl H Ar hostkey_file
140a03ec00cSchristosSpecifies a known hosts file to look up hostkeys when using
141a03ec00cSchristosdestination-constrained keys via the
142a03ec00cSchristos.Fl h
143a03ec00cSchristosflag.
144a03ec00cSchristosThis option may be specified multiple times to allow multiple files to be
145a03ec00cSchristossearched.
146a03ec00cSchristosIf no files are specified,
147a03ec00cSchristos.Nm
148a03ec00cSchristoswill use the default
149a03ec00cSchristos.Xr ssh_config 5
150a03ec00cSchristosknown hosts files:
151a03ec00cSchristos.Pa ~/.ssh/known_hosts ,
152a03ec00cSchristos.Pa ~/.ssh/known_hosts2 ,
153a03ec00cSchristos.Pa /etc/ssh/ssh_known_hosts ,
154a03ec00cSchristosand
155a03ec00cSchristos.Pa /etc/ssh/ssh_known_hosts2 .
156a03ec00cSchristos.It Fl h Ar destination_constraint
157a03ec00cSchristosWhen adding keys, constrain them to be usable only through specific hosts or to
158a03ec00cSchristosspecific destinations.
159a03ec00cSchristos.Pp
160a03ec00cSchristosDestination constraints of the form
161a03ec00cSchristos.Sq [user@]dest-hostname
162a03ec00cSchristospermit use of the key only from the origin host (the one running
163a03ec00cSchristos.Xr ssh-agent 1 )
164a03ec00cSchristosto the listed destination host, with optional user name.
165a03ec00cSchristos.Pp
166a03ec00cSchristosConstraints of the form
167a03ec00cSchristos.Sq src-hostname>[user@]dst-hostname
168a03ec00cSchristosallow a key available on a forwarded
169a03ec00cSchristos.Xr ssh-agent 1
170a03ec00cSchristosto be used through a particular host (as specified by
171a03ec00cSchristos.Sq src-hostname )
172a03ec00cSchristosto authenticate to a further host,
173a03ec00cSchristosspecified by
174a03ec00cSchristos.Sq dst-hostname .
175a03ec00cSchristos.Pp
176a03ec00cSchristosMultiple destination constraints may be added when loading keys.
177a03ec00cSchristosWhen attempting authentication with a key that has destination constraints,
178a03ec00cSchristosthe whole connection path, including
179a03ec00cSchristos.Xr ssh-agent 1
180a03ec00cSchristosforwarding, is tested against those constraints and each
181a03ec00cSchristoshop must be permitted for the attempt to succeed.
182a03ec00cSchristosFor example, if key is forwarded to a remote host,
183a03ec00cSchristos.Sq host-b ,
184a03ec00cSchristosand is attempting authentication to another host,
185a03ec00cSchristos.Sq host-c ,
186a03ec00cSchristosthen the operation will be successful only if
187a03ec00cSchristos.Sq host-b
188a03ec00cSchristoswas permitted from the origin host and the subsequent
189a03ec00cSchristos.Sq host-b>host-c
190a03ec00cSchristoshop is also permitted by destination constraints.
191a03ec00cSchristos.Pp
192a03ec00cSchristosHosts are identified by their host keys, and are looked up from known hosts
193a03ec00cSchristosfiles by
194a03ec00cSchristos.Nm .
195a03ec00cSchristosWildcards patterns may be used for hostnames and certificate host
196a03ec00cSchristoskeys are supported.
197a03ec00cSchristosBy default, keys added by
198a03ec00cSchristos.Nm
199a03ec00cSchristosare not destination constrained.
200a03ec00cSchristos.Pp
201a03ec00cSchristosDestination constraints were added in OpenSSH release 8.9.
202a03ec00cSchristosSupport in both the remote SSH client and server is required when using
203a03ec00cSchristosdestination-constrained keys over a forwarded
204a03ec00cSchristos.Xr ssh-agent 1
205a03ec00cSchristoschannel.
206a03ec00cSchristos.Pp
207a03ec00cSchristosIt is also important to note that destination constraints can only be
208a03ec00cSchristosenforced by
209a03ec00cSchristos.Xr ssh-agent 1
210a03ec00cSchristoswhen a key is used, or when it is forwarded by a
211a03ec00cSchristos.Sy cooperating
212a03ec00cSchristos.Xr ssh 1 .
213a03ec00cSchristosSpecifically, it does not prevent an attacker with access to a remote
214a03ec00cSchristos.Ev SSH_AUTH_SOCK
215a03ec00cSchristosfrom forwarding it again and using it on a different host (but only to
216a03ec00cSchristosa permitted destination).
217ed75d7a8Schristos.It Fl K
218ed75d7a8SchristosLoad resident keys from a FIDO authenticator.
219091c4109Schristos.It Fl k
220ce11a51fSchristosWhen loading keys into or deleting keys from the agent, process plain private
221ce11a51fSchristoskeys only and skip certificates.
222ca32bd8dSchristos.It Fl L
223ca32bd8dSchristosLists public key parameters of all identities currently represented
224ca32bd8dSchristosby the agent.
225ca32bd8dSchristos.It Fl l
226ca32bd8dSchristosLists fingerprints of all identities currently represented by the agent.
2277a183406Schristos.It Fl q
2287a183406SchristosBe quiet after a successful operation.
229ed75d7a8Schristos.It Fl S Ar provider
230ed75d7a8SchristosSpecifies a path to a library that will be used when adding
231ed75d7a8SchristosFIDO authenticator-hosted keys, overriding the default of using the
232ed75d7a8Schristosinternal USB HID support.
23334b27b53Sadam.It Fl s Ar pkcs11
23434b27b53SadamAdd keys provided by the PKCS#11 shared library
23534b27b53Sadam.Ar pkcs11 .
236514b5d45SchristosCertificate files may optionally be listed as command-line arguments.
237514b5d45SchristosIf these are present, then they will be loaded into the agent using any
238514b5d45Schristoscorresponding private keys loaded from the PKCS#11 token.
239aa36fcacSchristos.It Fl T Ar pubkey ...
240aa36fcacSchristosTests whether the private keys that correspond to the specified
241aa36fcacSchristos.Ar pubkey
242aa36fcacSchristosfiles are usable by performing sign and verify operations on each.
243ca32bd8dSchristos.It Fl t Ar life
244ca32bd8dSchristosSet a maximum lifetime when adding identities to an agent.
245ca32bd8dSchristosThe lifetime may be specified in seconds or in a time format
246ca32bd8dSchristosspecified in
247ca32bd8dSchristos.Xr sshd_config 5 .
248aa36fcacSchristos.It Fl v
249aa36fcacSchristosVerbose mode.
250aa36fcacSchristosCauses
251aa36fcacSchristos.Nm
252aa36fcacSchristosto print debugging messages about its progress.
253aa36fcacSchristosThis is helpful in debugging problems.
254aa36fcacSchristosMultiple
255aa36fcacSchristos.Fl v
256aa36fcacSchristosoptions increase the verbosity.
257aa36fcacSchristosThe maximum is 3.
258ca32bd8dSchristos.It Fl X
259ca32bd8dSchristosUnlock the agent.
260ca32bd8dSchristos.It Fl x
261ca32bd8dSchristosLock the agent with a password.
262ca32bd8dSchristos.El
263ca32bd8dSchristos.Sh ENVIRONMENT
264ca32bd8dSchristos.Bl -tag -width Ds
2652d3b0f52Schristos.It Ev "DISPLAY", "SSH_ASKPASS" and "SSH_ASKPASS_REQUIRE"
266ca32bd8dSchristosIf
267ca32bd8dSchristos.Nm
268ca32bd8dSchristosneeds a passphrase, it will read the passphrase from the current
269ca32bd8dSchristosterminal if it was run from a terminal.
270ca32bd8dSchristosIf
271ca32bd8dSchristos.Nm
272ca32bd8dSchristosdoes not have a terminal associated with it but
273ca32bd8dSchristos.Ev DISPLAY
274ca32bd8dSchristosand
275ca32bd8dSchristos.Ev SSH_ASKPASS
276ca32bd8dSchristosare set, it will execute the program specified by
277ca32bd8dSchristos.Ev SSH_ASKPASS
2784054ffb0Schristos(by default
2794054ffb0Schristos.Dq ssh-askpass )
280ca32bd8dSchristosand open an X11 window to read the passphrase.
281ca32bd8dSchristosThis is particularly useful when calling
282ca32bd8dSchristos.Nm
283ca32bd8dSchristosfrom a
284ca32bd8dSchristos.Pa .xsession
285ca32bd8dSchristosor related script.
2862d3b0f52Schristos.Pp
2872d3b0f52Schristos.Ev SSH_ASKPASS_REQUIRE
2882d3b0f52Schristosallows further control over the use of an askpass program.
2892d3b0f52SchristosIf this variable is set to
2902d3b0f52Schristos.Dq never
2912d3b0f52Schristosthen
2922d3b0f52Schristos.Nm
2932d3b0f52Schristoswill never attempt to use one.
2942d3b0f52SchristosIf it is set to
2952d3b0f52Schristos.Dq prefer ,
2962d3b0f52Schristosthen
2972d3b0f52Schristos.Nm
2982d3b0f52Schristoswill prefer to use the askpass program instead of the TTY when requesting
2992d3b0f52Schristospasswords.
3002d3b0f52SchristosFinally, if the variable is set to
3012d3b0f52Schristos.Dq force ,
3022d3b0f52Schristosthen the askpass program will be used for all passphrase input regardless
3032d3b0f52Schristosof whether
3042d3b0f52Schristos.Ev DISPLAY
3052d3b0f52Schristosis set.
306ca32bd8dSchristos.It Ev SSH_AUTH_SOCK
30734b27b53SadamIdentifies the path of a
30834b27b53Sadam.Ux Ns -domain
30934b27b53Sadamsocket used to communicate with the agent.
310ed75d7a8Schristos.It Ev SSH_SK_PROVIDER
311ed75d7a8SchristosSpecifies a path to a library that will be used when loading any
312ed75d7a8SchristosFIDO authenticator-hosted keys, overriding the default of using
313ed75d7a8Schristosthe built-in USB HID support.
314ca32bd8dSchristos.El
315ca32bd8dSchristos.Sh FILES
316ed75d7a8Schristos.Bl -tag -width Ds -compact
317185c8f97Schristos.It Pa ~/.ssh/id_ecdsa
318ed75d7a8Schristos.It Pa ~/.ssh/id_ecdsa_sk
3198a4530f9Schristos.It Pa ~/.ssh/id_ed25519
320ed75d7a8Schristos.It Pa ~/.ssh/id_ed25519_sk
321ca32bd8dSchristos.It Pa ~/.ssh/id_rsa
322*1c7715ddSchristosContains the ECDSA, authenticator-hosted ECDSA, Ed25519,
323ed75d7a8Schristosauthenticator-hosted Ed25519 or RSA authentication identity of the user.
324ca32bd8dSchristos.El
325ca32bd8dSchristos.Pp
326ca32bd8dSchristosIdentity files should not be readable by anyone but the user.
327ca32bd8dSchristosNote that
328ca32bd8dSchristos.Nm
329ca32bd8dSchristosignores identity files if they are accessible by others.
330185c8f97Schristos.Sh EXIT STATUS
331ca32bd8dSchristosExit status is 0 on success, 1 if the specified command fails,
332ca32bd8dSchristosand 2 if
333ca32bd8dSchristos.Nm
334ca32bd8dSchristosis unable to contact the authentication agent.
335ca32bd8dSchristos.Sh SEE ALSO
336ca32bd8dSchristos.Xr ssh 1 ,
337ca32bd8dSchristos.Xr ssh-agent 1 ,
3384054ffb0Schristos.Xr ssh-askpass 1 ,
339ca32bd8dSchristos.Xr ssh-keygen 1 ,
340ca32bd8dSchristos.Xr sshd 8
341ca32bd8dSchristos.Sh AUTHORS
342ca32bd8dSchristosOpenSSH is a derivative of the original and free
343ca32bd8dSchristosssh 1.2.12 release by Tatu Ylonen.
344ca32bd8dSchristosAaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
345ca32bd8dSchristosTheo de Raadt and Dug Song
346ca32bd8dSchristosremoved many bugs, re-added newer features and
347ca32bd8dSchristoscreated OpenSSH.
348ca32bd8dSchristosMarkus Friedl contributed the support for SSH
349ca32bd8dSchristosprotocol versions 1.5 and 2.0.
350