xref: /freebsd/crypto/openssh/PROTOCOL.certkeys (revision 8e28d84935f2f0ee081d44f9803f3052b960e50b)
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
3919261079SEd 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
4819261079SEd 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
16219261079SEd 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.
16619261079SEd 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
21919261079SEd 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
22519261079SEd 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
234*8e28d849SEd MasteThe name field identifies the option. The data field contains
235*8e28d849SEd Masteoption-specific information encoded as zero or more values inside
236*8e28d849SEd Mastethe string. I.e. an empty data field would be encoded as a zero-
237*8e28d849SEd Mastelength string (00 00 00 00), and data field that holds a single
238*8e28d849SEd Mastestring value "a" would be encoded as (00 00 00 05 00 00 00 01 65).
239*8e28d849SEd Maste
240*8e28d849SEd MasteAll options are "critical"; if an implementation does not recognise
241*8e28d849SEd Mastea option, then the validating party should refuse to accept the
242*8e28d849SEd Mastecertificate.
243b15c8340SDag-Erling Smørgrav
2444f52dfbbSDag-Erling SmørgravCustom options should append the originating author or organisation's
2454f52dfbbSDag-Erling Smørgravdomain name to the option name, e.g. "my-option@example.com".
2464f52dfbbSDag-Erling Smørgrav
247076ad2f8SDag-Erling SmørgravNo critical options are defined for host certificates at present. The
248076ad2f8SDag-Erling Smørgravsupported user certificate options and the contents and structure of
249076ad2f8SDag-Erling Smørgravtheir data fields are:
250b15c8340SDag-Erling Smørgrav
251b15c8340SDag-Erling SmørgravName                    Format        Description
252b15c8340SDag-Erling Smørgrav-----------------------------------------------------------------------------
253b15c8340SDag-Erling Smørgravforce-command           string        Specifies a command that is executed
254b15c8340SDag-Erling Smørgrav                                      (replacing any the user specified on the
255b15c8340SDag-Erling Smørgrav                                      ssh command-line) whenever this key is
256b15c8340SDag-Erling Smørgrav                                      used for authentication.
257b15c8340SDag-Erling Smørgrav
258b15c8340SDag-Erling Smørgravsource-address          string        Comma-separated list of source addresses
259b15c8340SDag-Erling Smørgrav                                      from which this certificate is accepted
260b15c8340SDag-Erling Smørgrav                                      for authentication. Addresses are
261b15c8340SDag-Erling Smørgrav                                      specified in CIDR format (nn.nn.nn.nn/nn
262b15c8340SDag-Erling Smørgrav                                      or hhhh::hhhh/nn).
26319261079SEd Maste                                      If this option is not present, then
264b15c8340SDag-Erling Smørgrav                                      certificates may be presented from any
265b15c8340SDag-Erling Smørgrav                                      source address.
266b15c8340SDag-Erling Smørgrav
26719261079SEd Masteverify-required         empty         Flag indicating that signatures made
26819261079SEd Maste                                      with this certificate must assert FIDO
26919261079SEd Maste                                      user verification (e.g. PIN or
27019261079SEd Maste                                      biometric). This option only makes sense
27119261079SEd Maste                                      for the U2F/FIDO security key types that
27219261079SEd Maste                                      support this feature in their signature
27319261079SEd Maste                                      formats.
27419261079SEd Maste
275e2f6069cSDag-Erling SmørgravExtensions
276e2f6069cSDag-Erling Smørgrav----------
277e2f6069cSDag-Erling Smørgrav
278e2f6069cSDag-Erling SmørgravThe extensions section of the certificate specifies zero or more
279e2f6069cSDag-Erling Smørgravnon-critical certificate extensions. The encoding and ordering of
280462c32cbSDag-Erling Smørgravextensions in this field is identical to that of the critical options,
281462c32cbSDag-Erling Smørgravas is the requirement that each name appear only once.
282462c32cbSDag-Erling Smørgrav
283e2f6069cSDag-Erling SmørgravIf an implementation does not recognise an extension, then it should
284e2f6069cSDag-Erling Smørgravignore it.
285e2f6069cSDag-Erling Smørgrav
2864f52dfbbSDag-Erling SmørgravCustom options should append the originating author or organisation's
2874f52dfbbSDag-Erling Smørgravdomain name to the option name, e.g. "my-option@example.com".
2884f52dfbbSDag-Erling Smørgrav
289076ad2f8SDag-Erling SmørgravNo extensions are defined for host certificates at present. The
290076ad2f8SDag-Erling Smørgravsupported user certificate extensions and the contents and structure of
291076ad2f8SDag-Erling Smørgravtheir data fields are:
292e2f6069cSDag-Erling Smørgrav
293e2f6069cSDag-Erling SmørgravName                    Format        Description
294e2f6069cSDag-Erling Smørgrav-----------------------------------------------------------------------------
29519261079SEd Masteno-touch-required       empty         Flag indicating that signatures made
29619261079SEd Maste                                      with this certificate need not assert
29719261079SEd Maste                                      FIDO user presence. This option only
29819261079SEd Maste                                      makes sense for the U2F/FIDO security
29919261079SEd Maste                                      key types that support this feature in
30019261079SEd Maste                                      their signature formats.
30119261079SEd Maste
302e2f6069cSDag-Erling Smørgravpermit-X11-forwarding   empty         Flag indicating that X11 forwarding
303e2f6069cSDag-Erling Smørgrav                                      should be permitted. X11 forwarding will
304e2f6069cSDag-Erling Smørgrav                                      be refused if this option is absent.
305e2f6069cSDag-Erling Smørgrav
306e2f6069cSDag-Erling Smørgravpermit-agent-forwarding empty         Flag indicating that agent forwarding
307e2f6069cSDag-Erling Smørgrav                                      should be allowed. Agent forwarding
308e2f6069cSDag-Erling Smørgrav                                      must not be permitted unless this
309e2f6069cSDag-Erling Smørgrav                                      option is present.
310e2f6069cSDag-Erling Smørgrav
311e2f6069cSDag-Erling Smørgravpermit-port-forwarding  empty         Flag indicating that port-forwarding
312e2f6069cSDag-Erling Smørgrav                                      should be allowed. If this option is
31319261079SEd Maste                                      not present, then no port forwarding will
314e2f6069cSDag-Erling Smørgrav                                      be allowed.
315e2f6069cSDag-Erling Smørgrav
316e2f6069cSDag-Erling Smørgravpermit-pty              empty         Flag indicating that PTY allocation
317e2f6069cSDag-Erling Smørgrav                                      should be permitted. In the absence of
318e2f6069cSDag-Erling Smørgrav                                      this option PTY allocation will be
319e2f6069cSDag-Erling Smørgrav                                      disabled.
320e2f6069cSDag-Erling Smørgrav
321e2f6069cSDag-Erling Smørgravpermit-user-rc          empty         Flag indicating that execution of
322e2f6069cSDag-Erling Smørgrav                                      ~/.ssh/rc should be permitted. Execution
323e2f6069cSDag-Erling Smørgrav                                      of this script will not be permitted if
324e2f6069cSDag-Erling Smørgrav                                      this option is not present.
325e2f6069cSDag-Erling Smørgrav
326*8e28d849SEd Maste$OpenBSD: PROTOCOL.certkeys,v 1.20 2024/12/06 16:02:12 djm Exp $
327