PROTOCOL.certkeys 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. This document describes a simple public-key certificate authentication
  2. system for use by SSH.
  3. Background
  4. ----------
  5. The SSH protocol currently supports a simple public key authentication
  6. mechanism. Unlike other public key implementations, SSH eschews the use
  7. of X.509 certificates and uses raw keys. This approach has some benefits
  8. relating to simplicity of configuration and minimisation of attack
  9. surface, but it does not support the important use-cases of centrally
  10. managed, passwordless authentication and centrally certified host keys.
  11. These protocol extensions build on the simple public key authentication
  12. system already in SSH to allow certificate-based authentication. The
  13. certificates used are not traditional X.509 certificates, with numerous
  14. options and complex encoding rules, but something rather more minimal: a
  15. key, some identity information and usage options that have been signed
  16. with some other trusted key.
  17. A sshd server may be configured to allow authentication via certified
  18. keys, by extending the existing ~/.ssh/authorized_keys mechanism to
  19. allow specification of certification authority keys in addition to
  20. raw user keys. The ssh client will support automatic verification of
  21. acceptance of certified host keys, by adding a similar ability to
  22. specify CA keys in ~/.ssh/known_hosts.
  23. All certificate types include certification information along with the
  24. public key that is used to sign challenges. In OpenSSH, ssh-keygen
  25. performs the CA signing operation.
  26. Certified keys are represented using new key types:
  27. ssh-rsa-cert-v01@openssh.com
  28. ssh-dss-cert-v01@openssh.com
  29. ecdsa-sha2-nistp256-cert-v01@openssh.com
  30. ecdsa-sha2-nistp384-cert-v01@openssh.com
  31. ecdsa-sha2-nistp521-cert-v01@openssh.com
  32. ssh-ed25519-cert-v01@openssh.com
  33. Two additional types exist for RSA certificates to force use of
  34. SHA-2 signatures (SHA-256 and SHA-512 respectively):
  35. rsa-sha2-256-cert-v01@openssh.com
  36. rsa-sha2-512-cert-v01@openssh.com
  37. These RSA/SHA-2 types should not appear in keys at rest or transmitted
  38. on their wire, but do appear in a SSH_MSG_KEXINIT's host-key algorithms
  39. field or in the "public key algorithm name" field of a "publickey"
  40. SSH_USERAUTH_REQUEST to indicate that the signature will use the
  41. specified algorithm.
  42. Protocol extensions
  43. -------------------
  44. The SSH wire protocol includes several extensibility mechanisms.
  45. These modifications shall take advantage of namespaced public key
  46. algorithm names to add support for certificate authentication without
  47. breaking the protocol - implementations that do not support the
  48. extensions will simply ignore them.
  49. Authentication using the new key formats described below proceeds
  50. using the existing SSH "publickey" authentication method described
  51. in RFC4252 section 7.
  52. New public key formats
  53. ----------------------
  54. The certificate key types take a similar high-level format (note: data
  55. types and encoding are as per RFC4251 section 5). The serialised wire
  56. encoding of these certificates is also used for storing them on disk.
  57. #define SSH_CERT_TYPE_USER 1
  58. #define SSH_CERT_TYPE_HOST 2
  59. RSA certificate
  60. string "ssh-rsa-cert-v01@openssh.com"
  61. string nonce
  62. mpint e
  63. mpint n
  64. uint64 serial
  65. uint32 type
  66. string key id
  67. string valid principals
  68. uint64 valid after
  69. uint64 valid before
  70. string critical options
  71. string extensions
  72. string reserved
  73. string signature key
  74. string signature
  75. DSA certificate
  76. string "ssh-dss-cert-v01@openssh.com"
  77. string nonce
  78. mpint p
  79. mpint q
  80. mpint g
  81. mpint y
  82. uint64 serial
  83. uint32 type
  84. string key id
  85. string valid principals
  86. uint64 valid after
  87. uint64 valid before
  88. string critical options
  89. string extensions
  90. string reserved
  91. string signature key
  92. string signature
  93. ECDSA certificate
  94. string "ecdsa-sha2-nistp256-cert-v01@openssh.com" |
  95. "ecdsa-sha2-nistp384-cert-v01@openssh.com" |
  96. "ecdsa-sha2-nistp521-cert-v01@openssh.com"
  97. string nonce
  98. string curve
  99. string public_key
  100. uint64 serial
  101. uint32 type
  102. string key id
  103. string valid principals
  104. uint64 valid after
  105. uint64 valid before
  106. string critical options
  107. string extensions
  108. string reserved
  109. string signature key
  110. string signature
  111. ED25519 certificate
  112. string "ssh-ed25519-cert-v01@openssh.com"
  113. string nonce
  114. string pk
  115. uint64 serial
  116. uint32 type
  117. string key id
  118. string valid principals
  119. uint64 valid after
  120. uint64 valid before
  121. string critical options
  122. string extensions
  123. string reserved
  124. string signature key
  125. string signature
  126. The nonce field is a CA-provided random bitstring of arbitrary length
  127. (but typically 16 or 32 bytes) included to make attacks that depend on
  128. inducing collisions in the signature hash infeasible.
  129. e and n are the RSA exponent and public modulus respectively.
  130. p, q, g, y are the DSA parameters as described in FIPS-186-2.
  131. curve and public key are respectively the ECDSA "[identifier]" and "Q"
  132. defined in section 3.1 of RFC5656.
  133. pk is the encoded Ed25519 public key as defined by
  134. draft-josefsson-eddsa-ed25519-03.
  135. serial is an optional certificate serial number set by the CA to
  136. provide an abbreviated way to refer to certificates from that CA.
  137. If a CA does not wish to number its certificates it must set this
  138. field to zero.
  139. type specifies whether this certificate is for identification of a user
  140. or a host using a SSH_CERT_TYPE_... value.
  141. key id is a free-form text field that is filled in by the CA at the time
  142. of signing; the intention is that the contents of this field are used to
  143. identify the identity principal in log messages.
  144. "valid principals" is a string containing zero or more principals as
  145. strings packed inside it. These principals list the names for which this
  146. certificate is valid; hostnames for SSH_CERT_TYPE_HOST certificates and
  147. usernames for SSH_CERT_TYPE_USER certificates. As a special case, a
  148. zero-length "valid principals" field means the certificate is valid for
  149. any principal of the specified type.
  150. "valid after" and "valid before" specify a validity period for the
  151. certificate. Each represents a time in seconds since 1970-01-01
  152. 00:00:00. A certificate is considered valid if:
  153. valid after <= current time < valid before
  154. critical options is a set of zero or more key options encoded as
  155. below. All such options are "critical" in the sense that an implementation
  156. must refuse to authorise a key that has an unrecognised option.
  157. extensions is a set of zero or more optional extensions. These extensions
  158. are not critical, and an implementation that encounters one that it does
  159. not recognise may safely ignore it.
  160. Generally, critical options are used to control features that restrict
  161. access where extensions are used to enable features that grant access.
  162. This ensures that certificates containing unknown restrictions do not
  163. inadvertently grant access while allowing new protocol features to be
  164. enabled via extensions without breaking certificates' backwards
  165. compatibility.
  166. The reserved field is currently unused and is ignored in this version of
  167. the protocol.
  168. The signature key field contains the CA key used to sign the
  169. certificate. The valid key types for CA keys are ssh-rsa,
  170. ssh-dss, ssh-ed25519 and the ECDSA types ecdsa-sha2-nistp256,
  171. ecdsa-sha2-nistp384, ecdsa-sha2-nistp521. "Chained" certificates, where
  172. the signature key type is a certificate type itself are NOT supported.
  173. Note that it is possible for a RSA certificate key to be signed by a
  174. Ed25519 or ECDSA CA key and vice-versa.
  175. signature is computed over all preceding fields from the initial string
  176. up to, and including the signature key. Signatures are computed and
  177. encoded according to the rules defined for the CA's public key algorithm
  178. (RFC4253 section 6.6 for ssh-rsa and ssh-dss, RFC5656 for the ECDSA
  179. types), and draft-josefsson-eddsa-ed25519-03 for Ed25519.
  180. Critical options
  181. ----------------
  182. The critical options section of the certificate specifies zero or more
  183. options on the certificates validity. The format of this field
  184. is a sequence of zero or more tuples:
  185. string name
  186. string data
  187. Options must be lexically ordered by "name" if they appear in the
  188. sequence. Each named option may only appear once in a certificate.
  189. The name field identifies the option and the data field encodes
  190. option-specific information (see below). All options are
  191. "critical", if an implementation does not recognise a option
  192. then the validating party should refuse to accept the certificate.
  193. Custom options should append the originating author or organisation's
  194. domain name to the option name, e.g. "my-option@example.com".
  195. No critical options are defined for host certificates at present. The
  196. supported user certificate options and the contents and structure of
  197. their data fields are:
  198. Name Format Description
  199. -----------------------------------------------------------------------------
  200. force-command string Specifies a command that is executed
  201. (replacing any the user specified on the
  202. ssh command-line) whenever this key is
  203. used for authentication.
  204. source-address string Comma-separated list of source addresses
  205. from which this certificate is accepted
  206. for authentication. Addresses are
  207. specified in CIDR format (nn.nn.nn.nn/nn
  208. or hhhh::hhhh/nn).
  209. If this option is not present then
  210. certificates may be presented from any
  211. source address.
  212. Extensions
  213. ----------
  214. The extensions section of the certificate specifies zero or more
  215. non-critical certificate extensions. The encoding and ordering of
  216. extensions in this field is identical to that of the critical options,
  217. as is the requirement that each name appear only once.
  218. If an implementation does not recognise an extension, then it should
  219. ignore it.
  220. Custom options should append the originating author or organisation's
  221. domain name to the option name, e.g. "my-option@example.com".
  222. No extensions are defined for host certificates at present. The
  223. supported user certificate extensions and the contents and structure of
  224. their data fields are:
  225. Name Format Description
  226. -----------------------------------------------------------------------------
  227. no-touch-required empty Flag indicating that signatures made
  228. with this certificate need not assert
  229. user presence. This option only make
  230. sense for the U2F/FIDO security key
  231. types that support this feature in
  232. their signature formats. Note that the
  233. CA must also have been marked with the
  234. no-touch-required option for this to
  235. be respected.
  236. permit-X11-forwarding empty Flag indicating that X11 forwarding
  237. should be permitted. X11 forwarding will
  238. be refused if this option is absent.
  239. permit-agent-forwarding empty Flag indicating that agent forwarding
  240. should be allowed. Agent forwarding
  241. must not be permitted unless this
  242. option is present.
  243. permit-port-forwarding empty Flag indicating that port-forwarding
  244. should be allowed. If this option is
  245. not present then no port forwarding will
  246. be allowed.
  247. permit-pty empty Flag indicating that PTY allocation
  248. should be permitted. In the absence of
  249. this option PTY allocation will be
  250. disabled.
  251. permit-user-rc empty Flag indicating that execution of
  252. ~/.ssh/rc should be permitted. Execution
  253. of this script will not be permitted if
  254. this option is not present.
  255. $OpenBSD: PROTOCOL.certkeys,v 1.17 2019/11/25 00:57:51 djm Exp $