mpint g, generator for subgroup in GF(p)
This is followed by the message exchange described above in
Section 2.1, except that the exchange hash H is computed as the HASH
hash of the concatenation of the following:
string V_C, the client’s version string (CR, NL excluded)
string V_S, the server’s version string (CR, NL excluded)
string I_C, the payload of the client’s SSH_MSG_KEXINIT
string I_S, the payload of the server’s SSH_MSG_KEXINIT
string K_S, the host key
uint32 min, minimal size in bits of an acceptable group
uint32 n, preferred size in bits of the group the server
should send
uint32 max, maximal size in bits of an acceptable group
mpint p, safe prime
mpint g, generator for subgroup in GF(p)
mpint e, exchange value sent by the client
mpint f, exchange value sent by the server
mpint K, the shared secret
2.3. gss-group1-sha1-*
Each of these methods specifies GSS-API-authenticated Diffie-Hellman
key exchange as described in Section 2.1 with SHA-1 as HASH, and the
group defined in Section 8.1 of [SSH-TRANSPORT]. The method name for
each method is the concatenation of the string "gss-group1-sha1-"
with the Base64 encoding of the MD5 hash [MD5] of the ASN.1
Distinguished Encoding Rules (DER) encoding [ASN1] of the underlying
GSS-API mechanism’s Object Identifier (OID). Base64 encoding is
described in Section 6.8 of [MIME].
Each and every such key exchange method is implicitly registered by
this specification. The IESG is considered to be the owner of all
such key exchange methods; this does NOT imply that the IESG is
considered to be the owner of the underlying GSS-API mechanism.
2.4. gss-group14-sha1-*
Each of these methods specifies GSS-API authenticated Diffie-Hellman
key exchange as described in Section 2.1 with SHA-1 as HASH, and the
group defined in Section 8.2 of [SSH-TRANSPORT]. The method name for
each method is the concatenation of the string "gss-group14-sha1-"
with the Base64 encoding of the MD5 hash [MD5] of the ASN.1 DER
encoding [ASN1] of the underlying GSS-API mechanism’s OID. Base64
encoding is described in Section 6.8 of [MIME].
Each and every such key exchange method is implicitly registered by
this specification. The IESG is considered to be the owner of all
such key exchange methods; this does NOT imply that the IESG is
considered to be the owner of the underlying GSS-API mechanism.
2.5. gss-gex-sha1-*
Each of these methods specifies GSS-API-authenticated Diffie-Hellman
key exchange as described in Section 2.2 with SHA-1 as HASH. The
method name for each method is the concatenation of the string "gss-
gex-sha1-" with the Base64 encoding of the MD5 hash [MD5] of the
ASN.1 DER encoding [ASN1] of the underlying GSS-API mechanism’s OID.
Base64 encoding is described in Section 6.8 of [MIME].
Each and every such key exchange method is implicitly registered by
this specification. The IESG is considered to be the owner of all
such key exchange methods; this does NOT imply that the IESG is
considered to be the owner of the underlying GSS-API mechanism.
2.6. Other GSS-API Key Exchange Methods
Key exchange method names starting with "gss-" are reserved for key
exchange methods that conform to this document; in particular, for
those methods that use the GSS-API-authenticated Diffie-Hellman key
exchange algorithm described in Section 2.1, including any future
methods that use different groups and/or hash functions. The intent
is that the names for any such future methods be defined in a similar
manner to that used in Section 2.3.
3. GSS-API User Authentication
This section describes a general-purpose user authentication method
based on [GSSAPI]. It is intended to be run over the SSH user
authentication protocol [SSH-USERAUTH].
The authentication method name for this protocol is "gssapi-with-
mic".
3.1. GSS-API Authentication Overview
GSS-API authentication must maintain a context. Authentication
begins when the client sends an SSH_MSG_USERAUTH_REQUEST, which
specifies the mechanism OIDs the client supports.
If the server supports any of the requested mechanism OIDs, the
server sends an SSH_MSG_USERAUTH_GSSAPI_RESPONSE message containing
the mechanism OID.
After the client receives SSH_MSG_USERAUTH_GSSAPI_RESPONSE, the
client and server exchange SSH_MSG_USERAUTH_GSSAPI_TOKEN packets
until the authentication mechanism either succeeds or fails.
If at any time during the exchange the client sends a new
SSH_MSG_USERAUTH_REQUEST packet, the GSS-API context is completely
discarded and destroyed, and any further GSS-API authentication MUST
restart from the beginning.
If the authentication succeeds and a non-empty user name is presented
by the client, the SSH server implementation verifies that the user
name is authorized based on the credentials exchanged in the GSS-API
exchange. If the user name is not authorized, then the
authentication MUST fail.
3.2. Initiating GSS-API Authentication
The GSS-API authentication method is initiated when the client sends
an SSH_MSG_USERAUTH_REQUEST:
byte SSH_MSG_USERAUTH_REQUEST
string user name (in ISO-10646 UTF-8 encoding)
string service name (in US-ASCII)
string "gssapi-with-mic" (US-ASCII method name)
uint32 n, the number of mechanism OIDs client supports
string[n] mechanism OIDs
Mechanism OIDs are encoded according to the ASN.1 Distinguished
Encoding Rules (DER), as described in [ASN1] and in Section 3.1 of
[GSSAPI]. The mechanism OIDs MUST be listed in order of preference,
and the server must choose the first mechanism OID on the list that
it supports.
The client SHOULD send GSS-API mechanism OIDs only for mechanisms
that are of the same priority, compared to non-GSS-API authentication
methods. Otherwise, authentication methods may be executed out of
order. Thus, the client could first send an SSH_MSG_USERAUTH_REQUEST
for one GSS-API mechanism, then try public key authentication, and
then try another GSS-API mechanism.
If the server does not support any of the specified OIDs, the server
MUST fail the request by sending an SSH_MSG_USERAUTH_FAILURE packet.
The user name may be an empty string if it can be deduced from the
results of the GSS-API authentication. If the user name is not
empty, and the requested user does not exist, the server MAY
disconnect or MAY send a bogus list of acceptable authentications but
never accept any. This makes it possible for the server to avoid
disclosing information about which accounts exist. In any case, if
the user does not exist, the authentication request MUST NOT be
accepted.
Note that the ’user name’ value is encoded in ISO-10646 UTF-8. It is
up to the server how it interprets the user name and determines
whether the client is authorized based on his GSS-API credentials.
In particular, the encoding used by the system for user names is a
matter for the ssh server implementation. However, if the client
reads the user name in some other encoding (e.g., ISO 8859-1 - ISO
Latin1), it MUST convert the user name to ISO-10646 UTF-8 before
transmitting, and the server MUST convert the user name to the
encoding used on that system for user names.
Any normalization or other preparation of names is done by the ssh
server based on the requirements of the system, and is outside the
scope of SSH. SSH implementations which maintain private user
databases SHOULD prepare user names as described by [SASLPREP].
The client MAY at any time continue with a new
SSH_MSG_USERAUTH_REQUEST message, in which case the server MUST
abandon the previous authentication attempt and continue with the new
one.
3.3. Initial Server Response
The server responds to the SSH_MSG_USERAUTH_REQUEST with either an
SSH_MSG_USERAUTH_FAILURE if none of the mechanisms are supported or
with an SSH_MSG_USERAUTH_GSSAPI_RESPONSE as follows:
byte SSH_MSG_USERAUTH_GSSAPI_RESPONSE
string selected mechanism OID
The mechanism OID must be one of the OIDs sent by the client in the
SSH_MSG_USERAUTH_REQUEST packet.
3.4. GSS-API Session
Once the mechanism OID has been selected, the client will then
initiate an exchange of one or more pairs of
SSH_MSG_USERAUTH_GSSAPI_TOKEN packets. These packets contain the
tokens produced from the ’GSS_Init_sec_context()’ and
’GSS_Accept_sec_context()’ calls. The actual number of packets
exchanged is determined by the underlying GSS-API mechanism.
byte SSH_MSG_USERAUTH_GSSAPI_TOKEN
string data returned from either GSS_Init_sec_context()
or GSS_Accept_sec_context()
If an error occurs during this exchange on server side, the server
can terminate the method by sending an SSH_MSG_USERAUTH_FAILURE
packet. If an error occurs on client side, the client can terminate
the method by sending a new SSH_MSG_USERAUTH_REQUEST packet.
When calling GSS_Init_sec_context(), the client MUST set
integ_req_flag to "true" to request that per-message integrity
protection be supported for this context. In addition,
deleg_req_flag MAY be set to "true" to request access delegation, if
requested by the user.
Since the user authentication process by its nature authenticates
only the client, the setting of mutual_req_flag is not needed for
this process. This flag SHOULD be set to "false".
Since the user authentication process will involve the exchange of
only a single token once the context has been established, it is not
necessary that the context support detection of replayed or out-of-
sequence tokens. Thus, the setting of replay_det_req_flag and
sequence_req_flag are not needed for this process. These flags
SHOULD be set to "false".
Additional SSH_MSG_USERAUTH_GSSAPI_TOKEN messages are sent if and
only if the calls to the GSS-API routines produce send tokens of non-
zero length.
Any major status code other than GSS_S_COMPLETE or
GSS_S_CONTINUE_NEEDED SHOULD be a failure.
3.5. Binding Encryption Keys
In some cases, it is possible to obtain improved security by allowing
access only if the client sends a valid message integrity code (MIC)
binding the GSS-API context to the keys used for encryption and
integrity protection of the SSH session. With this extra level of
protection, a "man-in-the-middle" attacker who has convinced a client
of his authenticity cannot then relay user authentication messages
between the real client and server, thus gaining access to the real
server. This additional protection is available when the negotiated
GSS-API context supports per-message integrity protection, as
indicated by the setting of the integ_avail flag on successful return
from GSS_Init_sec_context() or GSS_Accept_sec_context().
When the client’s call to GSS_Init_sec_context() returns
GSS_S_COMPLETE with the integ_avail flag set, the client MUST
conclude the user authentication exchange by sending the following
message:
byte SSH_MSG_USERAUTH_GSSAPI_MIC
string MIC
This message MUST be sent only if GSS_Init_sec_context() returned
GSS_S_COMPLETE. If a token is also returned, then the
SSH_MSG_USERAUTH_GSSAPI_TOKEN message MUST be sent before this one.
The contents of the MIC field are obtained by calling GSS_GetMIC()
over the following, using the GSS-API context that was just
established:
string session identifier
byte SSH_MSG_USERAUTH_REQUEST
string user name
string service
string "gssapi-with-mic"
If this message is received by the server before the GSS-API context
is fully established, the server MUST fail the authentication.
If this message is received by the server when the negotiated GSS-API
context does not support per-message integrity protection, the server
MUST fail the authentication.
3.6. Client Acknowledgement
Some servers may wish to permit user authentication to proceed even
when the negotiated GSS-API context does not support per-message
integrity protection. In such cases, it is possible for the server
to successfully complete the GSS-API method, while the client’s last
call to GSS_Init_sec_context() fails. If the server simply assumed
success on the part of the client and completed the authentication
service, it is possible that the client would fail to complete the
authentication method, but not be able to retry other methods because
the server had already moved on. To protect against this, a final
message is sent by the client to indicate it has completed
authentication.
When the client’s call to GSS_Init_sec_context() returns
GSS_S_COMPLETE with the integ_avail flag not set, the client MUST
conclude the user authentication exchange by sending the following
message:
byte SSH_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE
This message MUST be sent only if GSS_Init_sec_context() returned
GSS_S_COMPLETE. If a token is also returned, then the
SSH_MSG_USERAUTH_GSSAPI_TOKEN message MUST be sent before this one.
If this message is received by the server before the GSS-API context
is fully established, the server MUST fail the authentication.
If this message is received by the server when the negotiated GSS-API
context supports per-message integrity protection, the server MUST
fail the authentication.
It is a site policy decision for the server whether or not to permit
authentication using GSS-API mechanisms and/or contexts that do not
support per-message integrity protection. The server MAY fail the
otherwise valid gssapi-with-mic authentication if per-message
integrity protection is not supported.
3.7. Completion
As with all SSH authentication methods, successful completion is
indicated by an SSH_MSG_USERAUTH_SUCCESS if no other authentication
is required, or an SSH_MSG_USERAUTH_FAILURE with the partial success
flag set if the server requires further authentication. This packet
SHOULD be sent immediately following receipt of the
SSH_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE packet.
3.8. Error Status
In the event that a GSS-API error occurs on the server during context
establishment, the server MAY send the following message to inform
the client of the details of the error before sending an
SSH_MSG_USERAUTH_FAILURE message:
byte SSH_MSG_USERAUTH_GSSAPI_ERROR
uint32 major_status
uint32 minor_status
string message
string language tag
The message text MUST be encoded in the UTF-8 encoding described in
[UTF8]. Language tags are those described in [LANGTAG]. Note that
the message text may contain multiple lines separated by carriage
return-line feed (CRLF) sequences. Application developers should
take this into account when displaying these messages.
Clients receiving this message MAY log the error details and/or
report them to the user. Any server sending this message MUST ignore
any SSH_MSG_UNIMPLEMENTED sent by the client in response.
3.9. Error Token
In the event that, during context establishment, a client’s call to
GSS_Init_sec_context() or a server’s call to GSS_Accept_sec_context()
returns a token along with an error status, the resulting "error
token" SHOULD be sent to the peer using the following message:
byte SSH_MSG_USERAUTH_GSSAPI_ERRTOK
string error token
This message implies that the authentication is about to fail, and is
defined to allow the error token to be communicated without losing
synchronization.
When a server sends this message, it MUST be followed by an
SSH_MSG_USERAUTH_FAILURE message, which is to be interpreted as
applying to the same authentication request. A client receiving this
message SHOULD wait for the following SSH_MSG_USERAUTH_FAILURE
message before beginning another authentication attempt.
When a client sends this message, it MUST be followed by a new
authentication request or by terminating the connection. A server
receiving this message MUST NOT send an SSH_MSG_USERAUTH_FAILURE in
reply, since such a message might otherwise be interpreted by a
client as a response to the following authentication sequence.
Any server sending this message MUST ignore any SSH_MSG_UNIMPLEMENTED
sent by the client in response. If a server sends both this message
and an SSH_MSG_USERAUTH_GSSAPI_ERROR message, the
SSH_MSG_USERAUTH_GSSAPI_ERROR message MUST be sent first, to allow
the client to store and/or display the error status before processing
the error token.
4. Authentication Using GSS-API Key Exchange
This section describes a user authentication method building on the
framework described in [SSH-USERAUTH]. This method performs user
authentication by making use of an existing GSS-API context
established during key exchange.
The authentication method name for this protocol is "gssapi-keyex".
This method may be used only if the initial key exchange was
performed using a GSS-API-based key exchange method defined in
accordance with Section 2. The GSS-API context used with this method
is always that established during an initial GSS-API-based key
exchange. Any context established during key exchange for the
purpose of rekeying MUST NOT be used with this method.
The server SHOULD include this user authentication method in the list
of methods that can continue (in an SSH_MSG_USERAUTH_FAILURE) if the
initial key exchange was performed using a GSS-API-based key exchange
method and provides information about the user’s identity that is
useful to the server. It MUST NOT include this method if the initial
key exchange was not performed using a GSS-API-based key exchange
method defined in accordance with Section 2.
The client SHOULD attempt to use this method if it is advertised by
the server, initial key exchange was performed using a GSS-API-based
key exchange method, and this method has not already been tried. The
client SHOULD NOT try this method more than once per session. It
MUST NOT try this method if initial key exchange was not performed
using a GSS-API-based key exchange method defined in accordance with
Section 2.
If a server receives a request for this method when initial key
exchange was not performed using a GSS-API-based key exchange method
defined in accordance with Section 2, it MUST return
SSH_MSG_USERAUTH_FAILURE.
This method is defined as a single message:
byte SSH_MSG_USERAUTH_REQUEST
string user name
string service
string "gssapi-keyex"
string MIC
The contents of the MIC field are obtained by calling GSS_GetMIC over
the following, using the GSS-API context that was established during
initial key exchange:
string session identifier
byte SSH_MSG_USERAUTH_REQUEST
string user name
string service
string "gssapi-keyex"
Upon receiving this message when initial key exchange was performed
using a GSS-API-based key exchange method, the server uses
GSS_VerifyMIC() to verify that the MIC received is valid. If the MIC
is not valid, the user authentication fails, and the server MUST
return SSH_MSG_USERAUTH_FAILURE.
If the MIC is valid and the server is satisfied as to the user’s
credentials, it MAY return either SSH_MSG_USERAUTH_SUCCESS or
SSH_MSG_USERAUTH_FAILURE with the partial success flag set, depending
on whether additional authentications are needed.
5. Null Host Key Algorithm
The "null" host key algorithm has no associated host key material and
provides neither signature nor encryption algorithms. Thus, it can
be used only with key exchange methods that do not require any
public-key operations and do not require the use of host public key
material. The key exchange methods described in Section 2 are
examples of such methods.
This algorithm is used when, as a matter of configuration, the host
does not have or does not wish to use a public key. For example, it
can be used when the administrator has decided as a matter of policy
to require that all key exchanges be authenticated using Kerberos
[KRB5], and thus the only permitted key exchange method is the
GSS-API-authenticated Diffie-Hellman exchange described above, with
Kerberos V5 as the underlying GSS-API mechanism. In such a
configuration, the server implementation supports the "ssh-dss" key
algorithm (as required by [SSH-TRANSPORT]), but could be prohibited
by configuration from using it. In this situation, the server needs
some key exchange algorithm to advertise; the "null" algorithm fills
this purpose.
Note that the use of the "null" algorithm in this way means that the
server will not be able to interoperate with clients that do not
support this algorithm. This is not a significant problem, since in
the configuration described, it will also be unable to interoperate
with implementations that do not support the GSS-API-authenticated
key exchange and Kerberos.
Any implementation supporting at least one key exchange method that
conforms to Section 2 MUST also support the "null" host key
algorithm. Servers MUST NOT advertise the "null" host key algorithm
unless it is the only algorithm advertised.
6. Summary of Message Numbers
The following message numbers have been defined for use with GSS-
API-based key exchange methods:
#define SSH_MSG_KEXGSS_INIT 30
#define SSH_MSG_KEXGSS_CONTINUE 31
#define SSH_MSG_KEXGSS_COMPLETE 32
#define SSH_MSG_KEXGSS_HOSTKEY 33
#define SSH_MSG_KEXGSS_ERROR 34
#define SSH_MSG_KEXGSS_GROUPREQ 40
#define SSH_MSG_KEXGSS_GROUP 41
The numbers 30-49 are specific to key exchange and may be redefined
by other kex methods.
The following message numbers have been defined for use with the
’gssapi-with-mic’ user authentication method:
#define SSH_MSG_USERAUTH_GSSAPI_RESPONSE 60
#define SSH_MSG_USERAUTH_GSSAPI_TOKEN 61
#define SSH_MSG_USERAUTH_GSSAPI_EXCHANGE_COMPLETE 63
#define SSH_MSG_USERAUTH_GSSAPI_ERROR 64
#define SSH_MSG_USERAUTH_GSSAPI_ERRTOK 65
#define SSH_MSG_USERAUTH_GSSAPI_MIC 66
The numbers 60-79 are specific to user authentication and may be
redefined by other user auth methods. Note that in the method
described in this document, message number 62 is unused.
7. GSS-API Considerations
7.1. Naming Conventions
In order to establish a GSS-API security context, the SSH client
needs to determine the appropriate targ_name to use in identifying
the server when calling GSS_Init_sec_context(). For this purpose,
the GSS-API mechanism-independent name form for host-based services
is used, as described in Section 4.1 of [GSSAPI].
In particular, the targ_name to pass to GSS_Init_sec_context() is
obtained by calling GSS_Import_name() with an input_name_type of
GSS_C_NT_HOSTBASED_SERVICE, and an input_name_string consisting of
the string "host@" concatenated with the hostname of the SSH server.