blob: 11363fdc370ecb6f3f392e8cafcd4b44729b8e3c [file] [log] [blame]
Damien Miller0a80ca12010-02-27 07:55:05 +11001This document describes a simple public-key certificate authentication
2system for use by SSH.
3
4Background
5----------
6
7The SSH protocol currently supports a simple public key authentication
Damien Millereb8b60e2010-08-31 22:41:14 +10008mechanism. Unlike other public key implementations, SSH eschews the use
9of X.509 certificates and uses raw keys. This approach has some benefits
10relating to simplicity of configuration and minimisation of attack
11surface, but it does not support the important use-cases of centrally
12managed, passwordless authentication and centrally certified host keys.
Damien Miller0a80ca12010-02-27 07:55:05 +110013
14These protocol extensions build on the simple public key authentication
Damien Millereb8b60e2010-08-31 22:41:14 +100015system already in SSH to allow certificate-based authentication. The
16certificates used are not traditional X.509 certificates, with numerous
17options and complex encoding rules, but something rather more minimal: a
18key, some identity information and usage options that have been signed
19with some other trusted key.
Damien Miller0a80ca12010-02-27 07:55:05 +110020
21A sshd server may be configured to allow authentication via certified
Damien Millereb8b60e2010-08-31 22:41:14 +100022keys, by extending the existing ~/.ssh/authorized_keys mechanism to
23allow specification of certification authority keys in addition to
24raw user keys. The ssh client will support automatic verification of
25acceptance of certified host keys, by adding a similar ability to
26specify CA keys in ~/.ssh/known_hosts.
Damien Miller0a80ca12010-02-27 07:55:05 +110027
djm@openbsd.org4ba0d542018-07-03 11:39:54 +000028All certificate types include certification information along with the
29public key that is used to sign challenges. In OpenSSH, ssh-keygen
30performs the CA signing operation.
31
Damien Millereb8b60e2010-08-31 22:41:14 +100032Certified keys are represented using new key types:
33
34 ssh-rsa-cert-v01@openssh.com
35 ssh-dss-cert-v01@openssh.com
36 ecdsa-sha2-nistp256-cert-v01@openssh.com
37 ecdsa-sha2-nistp384-cert-v01@openssh.com
38 ecdsa-sha2-nistp521-cert-v01@openssh.com
39
djm@openbsd.org4ba0d542018-07-03 11:39:54 +000040Two additional types exist for RSA certificates to force use of
41SHA-2 signatures (SHA-256 and SHA-512 respectively):
42
43 rsa-sha2-256-cert-v01@openssh.com
44 rsa-sha2-512-cert-v01@openssh.com
45
46These RSA/SHA-2 types should not appear in keys at rest or transmitted
47on their wire, but do appear in a SSH_MSG_KEXINIT's host-key algorithms
48field or in the "public key algorithm name" field of a "publickey"
49SSH_USERAUTH_REQUEST to indicate that the signature will use the
50specified algorithm.
Damien Miller0a80ca12010-02-27 07:55:05 +110051
52Protocol extensions
53-------------------
54
55The SSH wire protocol includes several extensibility mechanisms.
56These modifications shall take advantage of namespaced public key
57algorithm names to add support for certificate authentication without
58breaking the protocol - implementations that do not support the
59extensions will simply ignore them.
60
61Authentication using the new key formats described below proceeds
62using the existing SSH "publickey" authentication method described
63in RFC4252 section 7.
64
65New public key formats
66----------------------
67
Damien Millereb8b60e2010-08-31 22:41:14 +100068The certificate key types take a similar high-level format (note: data
69types and encoding are as per RFC4251 section 5). The serialised wire
70encoding of these certificates is also used for storing them on disk.
Damien Miller0a80ca12010-02-27 07:55:05 +110071
72#define SSH_CERT_TYPE_USER 1
73#define SSH_CERT_TYPE_HOST 2
74
75RSA certificate
76
Damien Miller4e270b02010-04-16 15:56:21 +100077 string "ssh-rsa-cert-v01@openssh.com"
78 string nonce
Damien Miller0a80ca12010-02-27 07:55:05 +110079 mpint e
80 mpint n
Damien Miller4e270b02010-04-16 15:56:21 +100081 uint64 serial
Damien Miller0a80ca12010-02-27 07:55:05 +110082 uint32 type
83 string key id
84 string valid principals
85 uint64 valid after
86 uint64 valid before
Damien Miller4e270b02010-04-16 15:56:21 +100087 string critical options
88 string extensions
Damien Miller0a80ca12010-02-27 07:55:05 +110089 string reserved
90 string signature key
91 string signature
92
93DSA certificate
94
Damien Miller4e270b02010-04-16 15:56:21 +100095 string "ssh-dss-cert-v01@openssh.com"
96 string nonce
Damien Miller0a80ca12010-02-27 07:55:05 +110097 mpint p
98 mpint q
99 mpint g
100 mpint y
Damien Miller4e270b02010-04-16 15:56:21 +1000101 uint64 serial
Damien Miller0a80ca12010-02-27 07:55:05 +1100102 uint32 type
103 string key id
104 string valid principals
105 uint64 valid after
106 uint64 valid before
Damien Miller4e270b02010-04-16 15:56:21 +1000107 string critical options
108 string extensions
Damien Miller0a80ca12010-02-27 07:55:05 +1100109 string reserved
110 string signature key
111 string signature
112
Damien Millereb8b60e2010-08-31 22:41:14 +1000113ECDSA certificate
114
djm@openbsd.org@openbsd.orgc357eed2017-11-03 02:32:19 +0000115 string "ecdsa-sha2-nistp256-cert-v01@openssh.com" |
116 "ecdsa-sha2-nistp384-cert-v01@openssh.com" |
117 "ecdsa-sha2-nistp521-cert-v01@openssh.com"
Damien Millereb8b60e2010-08-31 22:41:14 +1000118 string nonce
119 string curve
120 string public_key
121 uint64 serial
122 uint32 type
123 string key id
124 string valid principals
125 uint64 valid after
126 uint64 valid before
127 string critical options
128 string extensions
129 string reserved
130 string signature key
131 string signature
132
djm@openbsd.orgfa582082016-05-03 10:27:59 +0000133ED25519 certificate
134
135 string "ssh-ed25519-cert-v01@openssh.com"
136 string nonce
137 string pk
138 uint64 serial
139 uint32 type
140 string key id
141 string valid principals
142 uint64 valid after
143 uint64 valid before
144 string critical options
145 string extensions
146 string reserved
147 string signature key
148 string signature
149
Damien Miller4e270b02010-04-16 15:56:21 +1000150The nonce field is a CA-provided random bitstring of arbitrary length
151(but typically 16 or 32 bytes) included to make attacks that depend on
152inducing collisions in the signature hash infeasible.
153
Damien Miller0a80ca12010-02-27 07:55:05 +1100154e and n are the RSA exponent and public modulus respectively.
155
156p, q, g, y are the DSA parameters as described in FIPS-186-2.
157
Damien Millereb8b60e2010-08-31 22:41:14 +1000158curve and public key are respectively the ECDSA "[identifier]" and "Q"
159defined in section 3.1 of RFC5656.
160
djm@openbsd.orgfa582082016-05-03 10:27:59 +0000161pk is the encoded Ed25519 public key as defined by
162draft-josefsson-eddsa-ed25519-03.
163
Damien Miller4e270b02010-04-16 15:56:21 +1000164serial is an optional certificate serial number set by the CA to
165provide an abbreviated way to refer to certificates from that CA.
Damien Miller2725c212010-05-10 11:56:14 +1000166If a CA does not wish to number its certificates it must set this
Damien Miller4e270b02010-04-16 15:56:21 +1000167field to zero.
168
Damien Miller0a80ca12010-02-27 07:55:05 +1100169type specifies whether this certificate is for identification of a user
170or a host using a SSH_CERT_TYPE_... value.
171
172key id is a free-form text field that is filled in by the CA at the time
173of signing; the intention is that the contents of this field are used to
174identify the identity principal in log messages.
175
176"valid principals" is a string containing zero or more principals as
177strings packed inside it. These principals list the names for which this
178certificate is valid; hostnames for SSH_CERT_TYPE_HOST certificates and
179usernames for SSH_CERT_TYPE_USER certificates. As a special case, a
180zero-length "valid principals" field means the certificate is valid for
djm@openbsd.orgfa582082016-05-03 10:27:59 +0000181any principal of the specified type.
Damien Miller0a80ca12010-02-27 07:55:05 +1100182
183"valid after" and "valid before" specify a validity period for the
184certificate. Each represents a time in seconds since 1970-01-01
18500:00:00. A certificate is considered valid if:
Damien Millereb8b60e2010-08-31 22:41:14 +1000186
187 valid after <= current time < valid before
Damien Miller0a80ca12010-02-27 07:55:05 +1100188
djm@openbsd.org001aa552018-04-10 00:10:49 +0000189critical options is a set of zero or more key options encoded as
Damien Miller4e270b02010-04-16 15:56:21 +1000190below. All such options are "critical" in the sense that an implementation
191must refuse to authorise a key that has an unrecognised option.
Damien Miller0a80ca12010-02-27 07:55:05 +1100192
Damien Miller4e270b02010-04-16 15:56:21 +1000193extensions is a set of zero or more optional extensions. These extensions
194are not critical, and an implementation that encounters one that it does
Damien Millerd0e4a8e2010-05-21 14:58:32 +1000195not recognise may safely ignore it.
Damien Miller0a80ca12010-02-27 07:55:05 +1100196
Damien Miller48348fc2012-04-22 11:08:30 +1000197Generally, critical options are used to control features that restrict
198access where extensions are used to enable features that grant access.
199This ensures that certificates containing unknown restrictions do not
200inadvertently grant access while allowing new protocol features to be
201enabled via extensions without breaking certificates' backwards
202compatibility.
203
Damien Miller4e270b02010-04-16 15:56:21 +1000204The reserved field is currently unused and is ignored in this version of
Damien Miller0a80ca12010-02-27 07:55:05 +1100205the protocol.
206
djm@openbsd.orgadb47ce2017-05-16 16:54:05 +0000207The signature key field contains the CA key used to sign the
208certificate. The valid key types for CA keys are ssh-rsa,
209ssh-dss, ssh-ed25519 and the ECDSA types ecdsa-sha2-nistp256,
210ecdsa-sha2-nistp384, ecdsa-sha2-nistp521. "Chained" certificates, where
211the signature key type is a certificate type itself are NOT supported.
212Note that it is possible for a RSA certificate key to be signed by a
213Ed25519 or ECDSA CA key and vice-versa.
Damien Miller0a80ca12010-02-27 07:55:05 +1100214
215signature is computed over all preceding fields from the initial string
216up to, and including the signature key. Signatures are computed and
217encoded according to the rules defined for the CA's public key algorithm
Damien Millereb8b60e2010-08-31 22:41:14 +1000218(RFC4253 section 6.6 for ssh-rsa and ssh-dss, RFC5656 for the ECDSA
djm@openbsd.orgfa582082016-05-03 10:27:59 +0000219types), and draft-josefsson-eddsa-ed25519-03 for Ed25519.
Damien Miller0a80ca12010-02-27 07:55:05 +1100220
Damien Miller4e270b02010-04-16 15:56:21 +1000221Critical options
222----------------
Damien Miller0a80ca12010-02-27 07:55:05 +1100223
Damien Miller4e270b02010-04-16 15:56:21 +1000224The critical options section of the certificate specifies zero or more
225options on the certificates validity. The format of this field
Damien Miller0a80ca12010-02-27 07:55:05 +1100226is a sequence of zero or more tuples:
227
228 string name
229 string data
230
Damien Miller1da63882010-08-05 13:03:51 +1000231Options must be lexically ordered by "name" if they appear in the
Damien Miller48348fc2012-04-22 11:08:30 +1000232sequence. Each named option may only appear once in a certificate.
Damien Miller1da63882010-08-05 13:03:51 +1000233
Damien Miller4e270b02010-04-16 15:56:21 +1000234The name field identifies the option and the data field encodes
235option-specific information (see below). All options are
236"critical", if an implementation does not recognise a option
Damien Miller0a80ca12010-02-27 07:55:05 +1100237then the validating party should refuse to accept the certificate.
238
djm@openbsd.orgd40dbdc2017-05-31 04:29:44 +0000239Custom options should append the originating author or organisation's
240domain name to the option name, e.g. "my-option@example.com".
241
djm@openbsd.orgfa582082016-05-03 10:27:59 +0000242No critical options are defined for host certificates at present. The
243supported user certificate options and the contents and structure of
244their data fields are:
Damien Miller0a80ca12010-02-27 07:55:05 +1100245
246Name Format Description
247-----------------------------------------------------------------------------
248force-command string Specifies a command that is executed
249 (replacing any the user specified on the
250 ssh command-line) whenever this key is
251 used for authentication.
252
Damien Millerd0e4a8e2010-05-21 14:58:32 +1000253source-address string Comma-separated list of source addresses
254 from which this certificate is accepted
255 for authentication. Addresses are
256 specified in CIDR format (nn.nn.nn.nn/nn
257 or hhhh::hhhh/nn).
258 If this option is not present then
259 certificates may be presented from any
260 source address.
261
262Extensions
263----------
264
265The extensions section of the certificate specifies zero or more
Damien Miller1da63882010-08-05 13:03:51 +1000266non-critical certificate extensions. The encoding and ordering of
Damien Miller48348fc2012-04-22 11:08:30 +1000267extensions in this field is identical to that of the critical options,
268as is the requirement that each name appear only once.
269
Damien Miller1da63882010-08-05 13:03:51 +1000270If an implementation does not recognise an extension, then it should
271ignore it.
Damien Millerd0e4a8e2010-05-21 14:58:32 +1000272
djm@openbsd.orgd40dbdc2017-05-31 04:29:44 +0000273Custom options should append the originating author or organisation's
274domain name to the option name, e.g. "my-option@example.com".
275
djm@openbsd.orgfa582082016-05-03 10:27:59 +0000276No extensions are defined for host certificates at present. The
277supported user certificate extensions and the contents and structure of
278their data fields are:
Damien Millerd0e4a8e2010-05-21 14:58:32 +1000279
280Name Format Description
281-----------------------------------------------------------------------------
Damien Miller0a80ca12010-02-27 07:55:05 +1100282permit-X11-forwarding empty Flag indicating that X11 forwarding
283 should be permitted. X11 forwarding will
Damien Miller4e270b02010-04-16 15:56:21 +1000284 be refused if this option is absent.
Damien Miller0a80ca12010-02-27 07:55:05 +1100285
286permit-agent-forwarding empty Flag indicating that agent forwarding
287 should be allowed. Agent forwarding
288 must not be permitted unless this
Damien Miller4e270b02010-04-16 15:56:21 +1000289 option is present.
Damien Miller0a80ca12010-02-27 07:55:05 +1100290
291permit-port-forwarding empty Flag indicating that port-forwarding
Damien Miller4e270b02010-04-16 15:56:21 +1000292 should be allowed. If this option is
Damien Miller0a80ca12010-02-27 07:55:05 +1100293 not present then no port forwarding will
294 be allowed.
295
296permit-pty empty Flag indicating that PTY allocation
297 should be permitted. In the absence of
Damien Miller4e270b02010-04-16 15:56:21 +1000298 this option PTY allocation will be
Damien Miller0a80ca12010-02-27 07:55:05 +1100299 disabled.
300
301permit-user-rc empty Flag indicating that execution of
302 ~/.ssh/rc should be permitted. Execution
303 of this script will not be permitted if
Damien Miller4e270b02010-04-16 15:56:21 +1000304 this option is not present.
Damien Miller0a80ca12010-02-27 07:55:05 +1100305
djm@openbsd.org4ba0d542018-07-03 11:39:54 +0000306$OpenBSD: PROTOCOL.certkeys,v 1.15 2018/07/03 11:39:54 djm Exp $