xref: /freebsd/crypto/openssh/PROTOCOL.certkeys (revision 19261079b74319502c6ffa1249920079f0f69a72)
1b15c8340SDag-Erling SmørgravThis document describes a simple public-key certificate authentication
2b15c8340SDag-Erling Smørgravsystem for use by SSH.
3b15c8340SDag-Erling Smørgrav
4b15c8340SDag-Erling SmørgravBackground
5b15c8340SDag-Erling Smørgrav----------
6b15c8340SDag-Erling Smørgrav
7b15c8340SDag-Erling SmørgravThe SSH protocol currently supports a simple public key authentication
84a421b63SDag-Erling Smørgravmechanism. Unlike other public key implementations, SSH eschews the use
94a421b63SDag-Erling Smørgravof X.509 certificates and uses raw keys. This approach has some benefits
104a421b63SDag-Erling Smørgravrelating to simplicity of configuration and minimisation of attack
114a421b63SDag-Erling Smørgravsurface, but it does not support the important use-cases of centrally
124a421b63SDag-Erling Smørgravmanaged, passwordless authentication and centrally certified host keys.
13b15c8340SDag-Erling Smørgrav
14b15c8340SDag-Erling SmørgravThese protocol extensions build on the simple public key authentication
154a421b63SDag-Erling Smørgravsystem already in SSH to allow certificate-based authentication. The
164a421b63SDag-Erling Smørgravcertificates used are not traditional X.509 certificates, with numerous
174a421b63SDag-Erling Smørgravoptions and complex encoding rules, but something rather more minimal: a
184a421b63SDag-Erling Smørgravkey, some identity information and usage options that have been signed
194a421b63SDag-Erling Smørgravwith some other trusted key.
20b15c8340SDag-Erling Smørgrav
21b15c8340SDag-Erling SmørgravA sshd server may be configured to allow authentication via certified
224a421b63SDag-Erling Smørgravkeys, by extending the existing ~/.ssh/authorized_keys mechanism to
234a421b63SDag-Erling Smørgravallow specification of certification authority keys in addition to
244a421b63SDag-Erling Smørgravraw user keys. The ssh client will support automatic verification of
254a421b63SDag-Erling Smørgravacceptance of certified host keys, by adding a similar ability to
264a421b63SDag-Erling Smørgravspecify CA keys in ~/.ssh/known_hosts.
27b15c8340SDag-Erling Smørgrav
28190cef3dSDag-Erling SmørgravAll certificate types include certification information along with the
29190cef3dSDag-Erling Smørgravpublic key that is used to sign challenges. In OpenSSH, ssh-keygen
30190cef3dSDag-Erling Smørgravperforms the CA signing operation.
31190cef3dSDag-Erling Smørgrav
324a421b63SDag-Erling SmørgravCertified keys are represented using new key types:
334a421b63SDag-Erling Smørgrav
344a421b63SDag-Erling Smørgrav    ssh-rsa-cert-v01@openssh.com
354a421b63SDag-Erling Smørgrav    ssh-dss-cert-v01@openssh.com
364a421b63SDag-Erling Smørgrav    ecdsa-sha2-nistp256-cert-v01@openssh.com
374a421b63SDag-Erling Smørgrav    ecdsa-sha2-nistp384-cert-v01@openssh.com
384a421b63SDag-Erling Smørgrav    ecdsa-sha2-nistp521-cert-v01@openssh.com
39*19261079SEd Maste    ssh-ed25519-cert-v01@openssh.com
404a421b63SDag-Erling Smørgrav
41190cef3dSDag-Erling SmørgravTwo additional types exist for RSA certificates to force use of
42190cef3dSDag-Erling SmørgravSHA-2 signatures (SHA-256 and SHA-512 respectively):
43190cef3dSDag-Erling Smørgrav
44190cef3dSDag-Erling Smørgrav    rsa-sha2-256-cert-v01@openssh.com
45190cef3dSDag-Erling Smørgrav    rsa-sha2-512-cert-v01@openssh.com
46190cef3dSDag-Erling Smørgrav
47190cef3dSDag-Erling SmørgravThese RSA/SHA-2 types should not appear in keys at rest or transmitted
48*19261079SEd Masteon the wire, but do appear in a SSH_MSG_KEXINIT's host-key algorithms
49190cef3dSDag-Erling Smørgravfield or in the "public key algorithm name" field of a "publickey"
50190cef3dSDag-Erling SmørgravSSH_USERAUTH_REQUEST to indicate that the signature will use the
51190cef3dSDag-Erling Smørgravspecified algorithm.
52b15c8340SDag-Erling Smørgrav
53b15c8340SDag-Erling SmørgravProtocol extensions
54b15c8340SDag-Erling Smørgrav-------------------
55b15c8340SDag-Erling Smørgrav
56b15c8340SDag-Erling SmørgravThe SSH wire protocol includes several extensibility mechanisms.
57b15c8340SDag-Erling SmørgravThese modifications shall take advantage of namespaced public key
58b15c8340SDag-Erling Smørgravalgorithm names to add support for certificate authentication without
59b15c8340SDag-Erling Smørgravbreaking the protocol - implementations that do not support the
60b15c8340SDag-Erling Smørgravextensions will simply ignore them.
61b15c8340SDag-Erling Smørgrav
62b15c8340SDag-Erling SmørgravAuthentication using the new key formats described below proceeds
63b15c8340SDag-Erling Smørgravusing the existing SSH "publickey" authentication method described
64b15c8340SDag-Erling Smørgravin RFC4252 section 7.
65b15c8340SDag-Erling Smørgrav
66b15c8340SDag-Erling SmørgravNew public key formats
67b15c8340SDag-Erling Smørgrav----------------------
68b15c8340SDag-Erling Smørgrav
694a421b63SDag-Erling SmørgravThe certificate key types take a similar high-level format (note: data
704a421b63SDag-Erling Smørgravtypes and encoding are as per RFC4251 section 5). The serialised wire
714a421b63SDag-Erling Smørgravencoding of these certificates is also used for storing them on disk.
72b15c8340SDag-Erling Smørgrav
73b15c8340SDag-Erling Smørgrav#define SSH_CERT_TYPE_USER    1
74b15c8340SDag-Erling Smørgrav#define SSH_CERT_TYPE_HOST    2
75b15c8340SDag-Erling Smørgrav
76b15c8340SDag-Erling SmørgravRSA certificate
77b15c8340SDag-Erling Smørgrav
78e2f6069cSDag-Erling Smørgrav    string    "ssh-rsa-cert-v01@openssh.com"
79e2f6069cSDag-Erling Smørgrav    string    nonce
80b15c8340SDag-Erling Smørgrav    mpint     e
81b15c8340SDag-Erling Smørgrav    mpint     n
82e2f6069cSDag-Erling Smørgrav    uint64    serial
83b15c8340SDag-Erling Smørgrav    uint32    type
84b15c8340SDag-Erling Smørgrav    string    key id
85b15c8340SDag-Erling Smørgrav    string    valid principals
86b15c8340SDag-Erling Smørgrav    uint64    valid after
87b15c8340SDag-Erling Smørgrav    uint64    valid before
88e2f6069cSDag-Erling Smørgrav    string    critical options
89e2f6069cSDag-Erling Smørgrav    string    extensions
90b15c8340SDag-Erling Smørgrav    string    reserved
91b15c8340SDag-Erling Smørgrav    string    signature key
92b15c8340SDag-Erling Smørgrav    string    signature
93b15c8340SDag-Erling Smørgrav
94b15c8340SDag-Erling SmørgravDSA certificate
95b15c8340SDag-Erling Smørgrav
96e2f6069cSDag-Erling Smørgrav    string    "ssh-dss-cert-v01@openssh.com"
97e2f6069cSDag-Erling Smørgrav    string    nonce
98b15c8340SDag-Erling Smørgrav    mpint     p
99b15c8340SDag-Erling Smørgrav    mpint     q
100b15c8340SDag-Erling Smørgrav    mpint     g
101b15c8340SDag-Erling Smørgrav    mpint     y
102e2f6069cSDag-Erling Smørgrav    uint64    serial
103b15c8340SDag-Erling Smørgrav    uint32    type
104b15c8340SDag-Erling Smørgrav    string    key id
105b15c8340SDag-Erling Smørgrav    string    valid principals
106b15c8340SDag-Erling Smørgrav    uint64    valid after
107b15c8340SDag-Erling Smørgrav    uint64    valid before
108e2f6069cSDag-Erling Smørgrav    string    critical options
109e2f6069cSDag-Erling Smørgrav    string    extensions
110b15c8340SDag-Erling Smørgrav    string    reserved
111b15c8340SDag-Erling Smørgrav    string    signature key
112b15c8340SDag-Erling Smørgrav    string    signature
113b15c8340SDag-Erling Smørgrav
1144a421b63SDag-Erling SmørgravECDSA certificate
1154a421b63SDag-Erling Smørgrav
11647dd1d1bSDag-Erling Smørgrav    string    "ecdsa-sha2-nistp256-cert-v01@openssh.com" |
11747dd1d1bSDag-Erling Smørgrav              "ecdsa-sha2-nistp384-cert-v01@openssh.com" |
11847dd1d1bSDag-Erling Smørgrav              "ecdsa-sha2-nistp521-cert-v01@openssh.com"
1194a421b63SDag-Erling Smørgrav    string    nonce
1204a421b63SDag-Erling Smørgrav    string    curve
1214a421b63SDag-Erling Smørgrav    string    public_key
1224a421b63SDag-Erling Smørgrav    uint64    serial
1234a421b63SDag-Erling Smørgrav    uint32    type
1244a421b63SDag-Erling Smørgrav    string    key id
1254a421b63SDag-Erling Smørgrav    string    valid principals
1264a421b63SDag-Erling Smørgrav    uint64    valid after
1274a421b63SDag-Erling Smørgrav    uint64    valid before
1284a421b63SDag-Erling Smørgrav    string    critical options
1294a421b63SDag-Erling Smørgrav    string    extensions
1304a421b63SDag-Erling Smørgrav    string    reserved
1314a421b63SDag-Erling Smørgrav    string    signature key
1324a421b63SDag-Erling Smørgrav    string    signature
1334a421b63SDag-Erling Smørgrav
134076ad2f8SDag-Erling SmørgravED25519 certificate
135076ad2f8SDag-Erling Smørgrav
136076ad2f8SDag-Erling Smørgrav    string    "ssh-ed25519-cert-v01@openssh.com"
137076ad2f8SDag-Erling Smørgrav    string    nonce
138076ad2f8SDag-Erling Smørgrav    string    pk
139076ad2f8SDag-Erling Smørgrav    uint64    serial
140076ad2f8SDag-Erling Smørgrav    uint32    type
141076ad2f8SDag-Erling Smørgrav    string    key id
142076ad2f8SDag-Erling Smørgrav    string    valid principals
143076ad2f8SDag-Erling Smørgrav    uint64    valid after
144076ad2f8SDag-Erling Smørgrav    uint64    valid before
145076ad2f8SDag-Erling Smørgrav    string    critical options
146076ad2f8SDag-Erling Smørgrav    string    extensions
147076ad2f8SDag-Erling Smørgrav    string    reserved
148076ad2f8SDag-Erling Smørgrav    string    signature key
149076ad2f8SDag-Erling Smørgrav    string    signature
150076ad2f8SDag-Erling Smørgrav
151e2f6069cSDag-Erling SmørgravThe nonce field is a CA-provided random bitstring of arbitrary length
152e2f6069cSDag-Erling Smørgrav(but typically 16 or 32 bytes) included to make attacks that depend on
153e2f6069cSDag-Erling Smørgravinducing collisions in the signature hash infeasible.
154e2f6069cSDag-Erling Smørgrav
155b15c8340SDag-Erling Smørgrave and n are the RSA exponent and public modulus respectively.
156b15c8340SDag-Erling Smørgrav
157b15c8340SDag-Erling Smørgravp, q, g, y are the DSA parameters as described in FIPS-186-2.
158b15c8340SDag-Erling Smørgrav
1594a421b63SDag-Erling Smørgravcurve and public key are respectively the ECDSA "[identifier]" and "Q"
1604a421b63SDag-Erling Smørgravdefined in section 3.1 of RFC5656.
1614a421b63SDag-Erling Smørgrav
162*19261079SEd Mastepk is the encoded Ed25519 public key as defined by RFC8032.
163076ad2f8SDag-Erling Smørgrav
164e2f6069cSDag-Erling Smørgravserial is an optional certificate serial number set by the CA to
165e2f6069cSDag-Erling Smørgravprovide an abbreviated way to refer to certificates from that CA.
166*19261079SEd MasteIf a CA does not wish to number its certificates, it must set this
167e2f6069cSDag-Erling Smørgravfield to zero.
168e2f6069cSDag-Erling Smørgrav
169b15c8340SDag-Erling Smørgravtype specifies whether this certificate is for identification of a user
170b15c8340SDag-Erling Smørgravor a host using a SSH_CERT_TYPE_... value.
171b15c8340SDag-Erling Smørgrav
172b15c8340SDag-Erling Smørgravkey id is a free-form text field that is filled in by the CA at the time
173b15c8340SDag-Erling Smørgravof signing; the intention is that the contents of this field are used to
174b15c8340SDag-Erling Smørgravidentify the identity principal in log messages.
175b15c8340SDag-Erling Smørgrav
176b15c8340SDag-Erling Smørgrav"valid principals" is a string containing zero or more principals as
177b15c8340SDag-Erling Smørgravstrings packed inside it. These principals list the names for which this
178b15c8340SDag-Erling Smørgravcertificate is valid; hostnames for SSH_CERT_TYPE_HOST certificates and
179b15c8340SDag-Erling Smørgravusernames for SSH_CERT_TYPE_USER certificates. As a special case, a
180b15c8340SDag-Erling Smørgravzero-length "valid principals" field means the certificate is valid for
181076ad2f8SDag-Erling Smørgravany principal of the specified type.
182b15c8340SDag-Erling Smørgrav
183b15c8340SDag-Erling Smørgrav"valid after" and "valid before" specify a validity period for the
184b15c8340SDag-Erling Smørgravcertificate. Each represents a time in seconds since 1970-01-01
185b15c8340SDag-Erling Smørgrav00:00:00. A certificate is considered valid if:
1864a421b63SDag-Erling Smørgrav
187b15c8340SDag-Erling Smørgrav    valid after <= current time < valid before
188b15c8340SDag-Erling Smørgrav
189190cef3dSDag-Erling Smørgravcritical options is a set of zero or more key options encoded as
190e2f6069cSDag-Erling Smørgravbelow. All such options are "critical" in the sense that an implementation
191e2f6069cSDag-Erling Smørgravmust refuse to authorise a key that has an unrecognised option.
192b15c8340SDag-Erling Smørgrav
193e2f6069cSDag-Erling Smørgravextensions is a set of zero or more optional extensions. These extensions
194e2f6069cSDag-Erling Smørgravare not critical, and an implementation that encounters one that it does
195e2f6069cSDag-Erling Smørgravnot recognise may safely ignore it.
196b15c8340SDag-Erling Smørgrav
197462c32cbSDag-Erling SmørgravGenerally, critical options are used to control features that restrict
198462c32cbSDag-Erling Smørgravaccess where extensions are used to enable features that grant access.
199462c32cbSDag-Erling SmørgravThis ensures that certificates containing unknown restrictions do not
200462c32cbSDag-Erling Smørgravinadvertently grant access while allowing new protocol features to be
201462c32cbSDag-Erling Smørgravenabled via extensions without breaking certificates' backwards
202462c32cbSDag-Erling Smørgravcompatibility.
203462c32cbSDag-Erling Smørgrav
204e2f6069cSDag-Erling SmørgravThe reserved field is currently unused and is ignored in this version of
205b15c8340SDag-Erling Smørgravthe protocol.
206b15c8340SDag-Erling Smørgrav
2074f52dfbbSDag-Erling SmørgravThe signature key field contains the CA key used to sign the
2084f52dfbbSDag-Erling Smørgravcertificate. The valid key types for CA keys are ssh-rsa,
2094f52dfbbSDag-Erling Smørgravssh-dss, ssh-ed25519 and the ECDSA types ecdsa-sha2-nistp256,
2104f52dfbbSDag-Erling Smørgravecdsa-sha2-nistp384, ecdsa-sha2-nistp521. "Chained" certificates, where
2114f52dfbbSDag-Erling Smørgravthe signature key type is a certificate type itself are NOT supported.
2124f52dfbbSDag-Erling SmørgravNote that it is possible for a RSA certificate key to be signed by a
2134f52dfbbSDag-Erling SmørgravEd25519 or ECDSA CA key and vice-versa.
214b15c8340SDag-Erling Smørgrav
215b15c8340SDag-Erling Smørgravsignature is computed over all preceding fields from the initial string
216b15c8340SDag-Erling Smørgravup to, and including the signature key. Signatures are computed and
217b15c8340SDag-Erling Smørgravencoded according to the rules defined for the CA's public key algorithm
2184a421b63SDag-Erling Smørgrav(RFC4253 section 6.6 for ssh-rsa and ssh-dss, RFC5656 for the ECDSA
219*19261079SEd Mastetypes, and RFC8032 for Ed25519).
220b15c8340SDag-Erling Smørgrav
221e2f6069cSDag-Erling SmørgravCritical options
222e2f6069cSDag-Erling Smørgrav----------------
223b15c8340SDag-Erling Smørgrav
224e2f6069cSDag-Erling SmørgravThe critical options section of the certificate specifies zero or more
225*19261079SEd Masteoptions on the certificate's validity. The format of this field
226b15c8340SDag-Erling Smørgravis a sequence of zero or more tuples:
227b15c8340SDag-Erling Smørgrav
228b15c8340SDag-Erling Smørgrav    string       name
229b15c8340SDag-Erling Smørgrav    string       data
230b15c8340SDag-Erling Smørgrav
231e2f6069cSDag-Erling SmørgravOptions must be lexically ordered by "name" if they appear in the
232462c32cbSDag-Erling Smørgravsequence. Each named option may only appear once in a certificate.
233e2f6069cSDag-Erling Smørgrav
234e2f6069cSDag-Erling SmørgravThe name field identifies the option and the data field encodes
235e2f6069cSDag-Erling Smørgravoption-specific information (see below). All options are
236*19261079SEd Maste"critical"; if an implementation does not recognise a option,
237b15c8340SDag-Erling Smørgravthen the validating party should refuse to accept the certificate.
238b15c8340SDag-Erling Smørgrav
2394f52dfbbSDag-Erling SmørgravCustom options should append the originating author or organisation's
2404f52dfbbSDag-Erling Smørgravdomain name to the option name, e.g. "my-option@example.com".
2414f52dfbbSDag-Erling Smørgrav
242076ad2f8SDag-Erling SmørgravNo critical options are defined for host certificates at present. The
243076ad2f8SDag-Erling Smørgravsupported user certificate options and the contents and structure of
244076ad2f8SDag-Erling Smørgravtheir data fields are:
245b15c8340SDag-Erling Smørgrav
246b15c8340SDag-Erling SmørgravName                    Format        Description
247b15c8340SDag-Erling Smørgrav-----------------------------------------------------------------------------
248b15c8340SDag-Erling Smørgravforce-command           string        Specifies a command that is executed
249b15c8340SDag-Erling Smørgrav                                      (replacing any the user specified on the
250b15c8340SDag-Erling Smørgrav                                      ssh command-line) whenever this key is
251b15c8340SDag-Erling Smørgrav                                      used for authentication.
252b15c8340SDag-Erling Smørgrav
253b15c8340SDag-Erling Smørgravsource-address          string        Comma-separated list of source addresses
254b15c8340SDag-Erling Smørgrav                                      from which this certificate is accepted
255b15c8340SDag-Erling Smørgrav                                      for authentication. Addresses are
256b15c8340SDag-Erling Smørgrav                                      specified in CIDR format (nn.nn.nn.nn/nn
257b15c8340SDag-Erling Smørgrav                                      or hhhh::hhhh/nn).
258*19261079SEd Maste                                      If this option is not present, then
259b15c8340SDag-Erling Smørgrav                                      certificates may be presented from any
260b15c8340SDag-Erling Smørgrav                                      source address.
261b15c8340SDag-Erling Smørgrav
262*19261079SEd Masteverify-required         empty         Flag indicating that signatures made
263*19261079SEd Maste                                      with this certificate must assert FIDO
264*19261079SEd Maste                                      user verification (e.g. PIN or
265*19261079SEd Maste                                      biometric). This option only makes sense
266*19261079SEd Maste                                      for the U2F/FIDO security key types that
267*19261079SEd Maste                                      support this feature in their signature
268*19261079SEd Maste                                      formats.
269*19261079SEd Maste
270e2f6069cSDag-Erling SmørgravExtensions
271e2f6069cSDag-Erling Smørgrav----------
272e2f6069cSDag-Erling Smørgrav
273e2f6069cSDag-Erling SmørgravThe extensions section of the certificate specifies zero or more
274e2f6069cSDag-Erling Smørgravnon-critical certificate extensions. The encoding and ordering of
275462c32cbSDag-Erling Smørgravextensions in this field is identical to that of the critical options,
276462c32cbSDag-Erling Smørgravas is the requirement that each name appear only once.
277462c32cbSDag-Erling Smørgrav
278e2f6069cSDag-Erling SmørgravIf an implementation does not recognise an extension, then it should
279e2f6069cSDag-Erling Smørgravignore it.
280e2f6069cSDag-Erling Smørgrav
2814f52dfbbSDag-Erling SmørgravCustom options should append the originating author or organisation's
2824f52dfbbSDag-Erling Smørgravdomain name to the option name, e.g. "my-option@example.com".
2834f52dfbbSDag-Erling Smørgrav
284076ad2f8SDag-Erling SmørgravNo extensions are defined for host certificates at present. The
285076ad2f8SDag-Erling Smørgravsupported user certificate extensions and the contents and structure of
286076ad2f8SDag-Erling Smørgravtheir data fields are:
287e2f6069cSDag-Erling Smørgrav
288e2f6069cSDag-Erling SmørgravName                    Format        Description
289e2f6069cSDag-Erling Smørgrav-----------------------------------------------------------------------------
290*19261079SEd Masteno-touch-required       empty         Flag indicating that signatures made
291*19261079SEd Maste                                      with this certificate need not assert
292*19261079SEd Maste                                      FIDO user presence. This option only
293*19261079SEd Maste                                      makes sense for the U2F/FIDO security
294*19261079SEd Maste                                      key types that support this feature in
295*19261079SEd Maste                                      their signature formats.
296*19261079SEd Maste
297e2f6069cSDag-Erling Smørgravpermit-X11-forwarding   empty         Flag indicating that X11 forwarding
298e2f6069cSDag-Erling Smørgrav                                      should be permitted. X11 forwarding will
299e2f6069cSDag-Erling Smørgrav                                      be refused if this option is absent.
300e2f6069cSDag-Erling Smørgrav
301e2f6069cSDag-Erling Smørgravpermit-agent-forwarding empty         Flag indicating that agent forwarding
302e2f6069cSDag-Erling Smørgrav                                      should be allowed. Agent forwarding
303e2f6069cSDag-Erling Smørgrav                                      must not be permitted unless this
304e2f6069cSDag-Erling Smørgrav                                      option is present.
305e2f6069cSDag-Erling Smørgrav
306e2f6069cSDag-Erling Smørgravpermit-port-forwarding  empty         Flag indicating that port-forwarding
307e2f6069cSDag-Erling Smørgrav                                      should be allowed. If this option is
308*19261079SEd Maste                                      not present, then no port forwarding will
309e2f6069cSDag-Erling Smørgrav                                      be allowed.
310e2f6069cSDag-Erling Smørgrav
311e2f6069cSDag-Erling Smørgravpermit-pty              empty         Flag indicating that PTY allocation
312e2f6069cSDag-Erling Smørgrav                                      should be permitted. In the absence of
313e2f6069cSDag-Erling Smørgrav                                      this option PTY allocation will be
314e2f6069cSDag-Erling Smørgrav                                      disabled.
315e2f6069cSDag-Erling Smørgrav
316e2f6069cSDag-Erling Smørgravpermit-user-rc          empty         Flag indicating that execution of
317e2f6069cSDag-Erling Smørgrav                                      ~/.ssh/rc should be permitted. Execution
318e2f6069cSDag-Erling Smørgrav                                      of this script will not be permitted if
319e2f6069cSDag-Erling Smørgrav                                      this option is not present.
320e2f6069cSDag-Erling Smørgrav
321*19261079SEd Maste$OpenBSD: PROTOCOL.certkeys,v 1.19 2021/06/05 13:47:00 naddy Exp $
322