SSH-ADD(1)
๐ SSH-ADD(1) โ General Commands Manual ๐
okay so bestie, welcome to ssh-add(1), from the General Commands Manual โ yes that one, the OpenSSH one, the icon herself. she's about to make your keys make sense โจ
๐ธ NAME ๐ธ
ssh-add โ adds private key identities to the OpenSSH authentication agent. that's it, that's the whole job, and she does it flawlessly ๐
โจ SYNOPSIS โจ
ssh-add [-CcDdKkLlNqvXx] [-E fingerprint_hash] [-H hostkey_file]
[-h destination_constraint] [-S provider] [-t life] [file ...]
ssh-add -s pkcs11 [-Cv] [certificate ...]
ssh-add -e pkcs11
ssh-add -T pubkey ...
like, four whole modes, pick your fighter ๐ซถ
๐ DESCRIPTION ๐
so ssh-add adds private key identities to the authentication agent, ssh-agent(1). no cap.
when you run it with no arguments at all, she goes and adds these files for you, unprompted, main character energy:
~/.ssh/id_rsa~/.ssh/id_ecdsa~/.ssh/id_ecdsa_sk~/.ssh/id_ed25519~/.ssh/id_ed25519_sk
and after loading a private key, ssh-add will also try to load corresponding certificate information from the filename you get by appending -cert.pub to the name of the private key file. love a girl who checks for the bonus content ๐ alternative file names can be given on the command line, obviously.
if any file requires a passphrase, ssh-add asks you for it. the passphrase is read from the user's tty. and here's the cute part โ ssh-add retries the last passphrase if multiple identity files are given. she remembers. she's thoughtful like that ๐
the authentication agent must be running and the SSH_AUTH_SOCK environment variable must contain the name of its socket for ssh-add to work. non-negotiable, that's the whole vibe check.
the options are as follows:
๐ฆ OPTIONS ๐ฆ
-Cโ when loading keys into or deleting keys from the agent, process certificates only and skip plain keys.-cโ indicates that added identities should be subject to confirmation before being used for authentication. confirmation is performed byssh-askpass(1). and listen โ successful confirmation is signaled by a zero exit status fromssh-askpass(1), not by text entered into the requester. that's the detail everyone gets wrong, iykyk.-Dโ deletes all identities from the agent. nuclear option bestie ๐-dโ instead of adding identities, removes identities from the agent. ifssh-addhas been run with no arguments, the keys for the default identities and their corresponding certificates will be removed. otherwise, the argument list will be interpreted as a list of paths to public key files to specify keys and certificates to be removed from the agent. if no public key is found at a given path,ssh-addwill append.puband retry. and if the argument list consists of-thenssh-addwill read public keys to be removed from standard input. icon behaviour fr.-Efingerprint_hashโ specifies the hash algorithm used when displaying key fingerprints. valid options are:md5andsha256. the default issha256. as it should be ๐-epkcs11โ remove keys provided by the PKCS#11 shared librarypkcs11.-Hhostkey_fileโ specifies a known hosts file to look up hostkeys when using destination-constrained keys via the-hflag. this option may be specified multiple times to allow multiple files to be searched. if no files are specified,ssh-addwill use the defaultssh_config(5)known hosts files:~/.ssh/known_hosts,~/.ssh/known_hosts2,/etc/ssh/ssh_known_hosts, and/etc/ssh/ssh_known_hosts2.-hdestination_constraintโ when adding keys, constrain them to be usable only through specific hosts or to specific destinations. this one's a whole saga so buckle up ๐:
destination constraints of the form [user@]dest-hostname permit use of the key only from the origin host (the one running ssh-agent(1)) to the listed destination host, with optional user name.
constraints of the form src-hostname>[user@]dst-hostname allow a key available on a forwarded ssh-agent(1) to be used through a particular host (as specified by src-hostname) to authenticate to a further host, specified by dst-hostname.
multiple destination constraints may be added when loading keys. when attempting authentication with a key that has destination constraints, the whole connection path โ including ssh-agent(1) forwarding โ is tested against those constraints and each hop must be permitted for the attempt to succeed. for example, if a key is forwarded to a remote host, host-b, and is attempting authentication to another host, host-c, then the operation will be successful only if host-b was permitted from the origin host and the subsequent host-b>host-c hop is also permitted by destination constraints. literally the whole chain gets checked, no skipping steps.
hosts are identified by their host keys, and are looked up from known hosts files by ssh-add. wildcards patterns may be used for hostnames and certificate host keys are supported. by default, keys added by ssh-add are not destination constrained.
destination constraints were added in OpenSSH release 8.9. support in both the remote SSH client and server is required when using destination-constrained keys over a forwarded ssh-agent(1) channel.
it is also important to note that destination constraints can only be enforced byssh-agent(1)when a key is used, or when it is forwarded by a cooperatingssh(1). specifically, it does not prevent an attacker with access to a remoteSSH_AUTH_SOCKfrom forwarding it again and using it on a different host (but only to a permitted destination). read that twice, bestie ๐ญ
-Kโ load resident keys from a FIDO authenticator.-kโ when loading keys into or deleting keys from the agent, process plain private keys only and skip certificates.-Lโ lists public key parameters of all identities currently represented by the agent.-lโ lists fingerprints of all identities currently represented by the agent.-Nโ when adding certificates, by defaultssh-addwill request that the agent automatically delete the certificate shortly after the certificate's expiry date. this flag suppresses this behaviour and does not specify a lifetime for certificates added to an agent.-qโ be quiet after a successful operation. she's humble sometimes ๐-Sproviderโ specifies a path to a library that will be used when adding FIDO authenticator-hosted keys, overriding the default of using the internal USB HID support.-spkcs11โ add keys provided by the PKCS#11 shared librarypkcs11. certificate files may optionally be listed as command-line arguments. if these are present, then they will be loaded into the agent using any corresponding private keys loaded from the PKCS#11 token.-Tpubkey ...โ tests whether the private keys that correspond to the specifiedpubkeyfiles are usable by performing sign and verify operations on each. a little vibe check, for your keys ๐ฅ-tlifeโ set a maximum lifetime when adding identities to an agent. the lifetime may be specified in seconds or in a time format specified insshd_config(5).-vโ verbose mode. causesssh-addto print debugging messages about its progress. this is helpful in debugging problems. multiple-voptions increase the verbosity. the maximum is 3. three is the limit, don't push her ๐-Xโ unlock the agent.-xโ lock the agent with a password.
๐ ENVIRONMENT ๐
DISPLAY, SSH_ASKPASS and SSH_ASKPASS_REQUIRE
if ssh-add needs a passphrase, it will read the passphrase from the current terminal if it was run from a terminal. but if ssh-add does not have a terminal associated with it but DISPLAY and SSH_ASKPASS are set, it will execute the program specified by SSH_ASKPASS (by default ssh-askpass) and open an X11 window to read the passphrase. this is particularly useful when calling ssh-add from a .xsession or related script. so extra, so helpful ๐ง
SSH_ASKPASS_REQUIRE allows further control over the use of an askpass program:
- if this variable is set to
neverthenssh-addwill never attempt to use one. - if it is set to
prefer, thenssh-addwill prefer to use the askpass program instead of the TTY when requesting passwords. - finally, if the variable is set to
force, then the askpass program will be used for all passphrase input regardless of whetherDISPLAYis set. no escape hatch, she's committed.
SSH_AUTH_SOCK
identifies the path of a Unix-domain socket used to communicate with the agent.
SSH_SK_PROVIDER
specifies a path to a library that will be used when loading any FIDO authenticator-hosted keys, overriding the default of using the built-in USB HID support.
๐ FILES ๐
~/.ssh/id_ecdsa~/.ssh/id_ecdsa_sk~/.ssh/id_ed25519~/.ssh/id_ed25519_sk~/.ssh/id_rsa
contains the ECDSA, authenticator-hosted ECDSA, Ed25519, authenticator-hosted Ed25519 or RSA authentication identity of the user โจ
identity files should not be readable by anyone but the user. note that ssh-add ignores identity files if they are accessible by others. your keys, your business, nobody else's, periodt ๐
โญ EXIT STATUS โญ
- exit status is
0on success ๐ 1if the specified command fails ๐ญ2ifssh-addis unable to contact the authentication agent ๐
๐ SEE ALSO ๐
ssh(1), ssh-agent(1), ssh-askpass(1), ssh-keygen(1), sshd(8)
the whole friend group, honestly ๐ซถ
๐ AUTHORS ๐
OpenSSH is a derivative of the original and free ssh 1.2.12 release by Tatu Ylonen. Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos, Theo de Raadt and Dug Song removed many bugs, re-added newer features and created OpenSSH. Markus Friedl contributed the support for SSH protocol versions 1.5 and 2.0. legends, every single one ๐ฅ
and that's the page, bestie ๐ this was the Debian build of the General Commands Manual, dated September 11, 2025 โ go forth and ssh-add responsibly, mwah ๐โจ
๐ฆ where this page comes from
- alpine 3.23: openssh-doc 10.2_p1-r0 ยท SSH-OpenSSH
- fedora 44: openssh-clients 10.2p1-14.fc44
- fedora 44: openssh-clients 10.2p1-16.fc44 ยท BSD-3-Clause AND BSD-2-Clause AND ISC AND SSH-OpenSSH AND ssh-keyscan AND snprintf AND LicenseRef-Fedora-Public-Domain AND X11-distribute-modifications-variant
- fedora 44: openssh-clients 10.2p1-7.fc44 ยท BSD-3-Clause AND BSD-2-Clause AND ISC AND SSH-OpenSSH AND ssh-keyscan AND snprintf AND LicenseRef-Fedora-Public-Domain AND X11-distribute-modifications-variant
- ubuntu resolute: openssh-client 1:10.2p1-2ubuntu3 ยท OpenSSH
- ubuntu resolute: openssh-client 1:10.2p1-2ubuntu3.6
- ubuntu resolute: openssh-client 1:10.2p1-2ubuntu3.7
- ubuntu resolute: openssh-client 1:10.2p1-2ubuntu3.8 ยท OpenSSH
- Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
- Copyright (c) 1999,2000 Markus Friedl. All rights reserved
- Copyright (c) 1999 Aaron Campbell. All rights reserved
- Copyright (c) 1999 Theo de Raadt. All rights reserved
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms