<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc toc="yes"?>
<?rfc symrefs="yes"?>
<?rfc sortrefs="yes" ?>
<?rfc compact="yes"?>
<?rfc subcompact="no"?>
<?rfc linkmailto="no" ?>
<?rfc editing="no" ?>
<?rfc comments="yes" ?>
<?rfc inline="yes"?>
<?rfc rfcedstyle="yes"?>
<?rfc-ext allow-markup-in-artwork="yes" ?>
<?rfc-ext include-index="no" ?>
<!--<?rfc strict="no"?> -->
<rfc category="std" docName="draft-ietf-netconf-ssh-client-server-09"
     ipr="trust200902">
  <front>
    <title abbrev="Groupings for SSH Clients and Servers">YANG Groupings for
    SSH Clients and SSH Servers</title>

    <author fullname="Kent Watsen" initials="K." surname="Watsen">
      <organization>Watsen Networks</organization>

      <address>
        <email>kent+ietf@watsen.net</email>
      </address>
    </author>

    <author fullname="Gary Wu" initials="G." surname="Wu">
      <organization>Cisco Systems</organization>

      <address>
        <email>garywu@cisco.com</email>
      </address>
    </author>

    <author fullname="Liang Xia" initials="L." surname="Xia">
      <organization>Huawei</organization>

      <address>
        <email>frank.xialiang@huawei.com</email>
      </address>
    </author>

    <date/>

    <area>Operations</area>

    <workgroup>NETCONF Working Group</workgroup>

    <abstract>
      <t>This document defines three YANG modules: the first defines groupings
      for a generic SSH client, the second defines groupings for a generic SSH
      server, and the third defines common identities and groupings used by
      both the client and the server. It is intended that these groupings will
      be used by applications using the SSH protocol.</t>
    </abstract>

    <note title="Editorial Note (To be removed by RFC Editor)">
      <t>This draft contains many placeholder values that need to be replaced
      with finalized values at the time of publication. This note summarizes
      all of the substitutions that are needed. No other RFC Editor
      instructions are specified elsewhere in this document.</t>

      <t>This document contains references to other drafts in progress, both
      in the Normative References section, as well as in body text throughout.
      Please update the following references to reflect their final RFC
      assignments: <list style="symbols">
          <t>I-D.ietf-netconf-trust-anchors</t>

          <t>I-D.ietf-netconf-keystore</t>
        </list></t>

      <t>Artwork in this document contains shorthand references to drafts in
      progress. Please apply the following replacements: <list style="symbols">
          <t><spanx style="verb">XXXX</spanx> --&gt; the assigned RFC value
          for this draft</t>

          <t><spanx style="verb">YYYY</spanx> --&gt; the assigned RFC value
          for I-D.ietf-netconf-trust-anchors</t>

          <t><spanx style="verb">ZZZZ</spanx> --&gt; the assigned RFC value
          for I-D.ietf-netconf-keystore</t>
        </list></t>

      <t>Artwork in this document contains placeholder values for the date of
      publication of this draft. Please apply the following replacement: <list
          style="symbols">
          <t><spanx style="verb">2019-03-09</spanx> --&gt; the publication
          date of this draft</t>
        </list></t>

      <t>The following Appendix section is to be removed prior to publication:
      <list style="symbols">
          <t>Appendix A. Change Log</t>
        </list></t>
    </note>
  </front>

  <middle>
    <section title="Introduction">
      <t>This document defines three YANG 1.1 <xref target="RFC7950"/>
      modules: the first defines a grouping for a generic SSH client, the
      second defines a grouping for a generic SSH server, and the third
      defines identities and groupings common to both the client and the
      server. It is intended that these groupings will be used by applications
      using the SSH protocol <xref target="RFC4252"/>, <xref
      target="RFC4253"/>, and <xref target="RFC4254"/>. For instance, these
      groupings could be used to help define the data model for an OpenSSH
      <xref target="OPENSSH"/> server or a NETCONF over SSH <xref
      target="RFC6242"/> based server.</t>

      <t>The client and server YANG modules in this document each define one
      grouping, which is focused on just SSH-specific configuration, and
      specifically avoids any transport-level configuration, such as what
      ports to listen on or connect to. This affords applications the
      opportunity to define their own strategy for how the underlying TCP
      connection is established. For instance, applications supporting NETCONF
      Call Home <xref target="RFC8071"/> could use the "ssh-server-grouping"
      grouping for the SSH parts it provides, while adding data nodes for the
      TCP-level call-home configuration.</t>

      <t>The modules defined in this document use groupings defined in <xref
      target="I-D.ietf-netconf-keystore"/> <!-- and
        <xref target="I-D.kwatsen-netconf-trust-anchors"/> --> enabling keys
      <!-- and trust anchors, respectively,--> to be either locally defined or
      a reference to globally configured values.</t>

      <t>The modules defined in this document optionally support <xref
      target="RFC6187"/> enabling X.509v3 certificate based host keys and
      public keys.</t>
    </section>

    <section title="Terminology">
      <t>The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
      "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
      "OPTIONAL" in this document are to be interpreted as described in BCP 14
      <xref target="RFC2119"/> <xref target="RFC8174"/> when, and only when,
      they appear in all capitals, as shown here.</t>
    </section>

    <section anchor="ssh-client-model" title="The SSH Client Model">
      <section title="Tree Diagram">
        <t>This section provides a tree diagram <xref target="RFC8340"/> for
        the "ietf-ssh-client" module that does not have groupings
        expanded.</t>

        <t><figure>
            <artwork><![CDATA[
module: ietf-ssh-client

  grouping ssh-client-grouping
    +---u client-identity-grouping
    +---u server-auth-grouping
    +---u transport-params-grouping
    +---u keepalives-grouping
  grouping client-identity-grouping
    +-- ssh-client-identity
       +-- username?            string
       +-- (auth-type)
          +--:(password)
          |  +-- password?      string
          +--:(public-key)
          |  +-- public-key
          |     +---u client-identity-grouping
          +--:(certificate)
             +-- certificate {sshcmn:ssh-x509-certs}?
                +---u client-identity-grouping
  grouping server-auth-grouping
    +-- ssh-server-auth
       +-- pinned-ssh-host-keys?   ta:pinned-host-keys-ref
       |       {ta:ssh-host-keys}?
       +-- pinned-ca-certs?        ta:pinned-certificates-ref
       |       {sshcmn:ssh-x509-certs,ta:x509-certificates}?
       +-- pinned-server-certs?    ta:pinned-certificates-ref
               {sshcmn:ssh-x509-certs,ta:x509-certificates}?
  grouping transport-params-grouping
    +-- ssh-transport-params {ssh-client-transport-params-config}?
       +---u transport-params-grouping
  grouping keepalives-grouping
    +-- ssh-keepalives {ssh-client-keepalives}?
       +-- max-wait?       uint16
       +-- max-attempts?   uint8
]]></artwork>
          </figure></t>
      </section>

      <section title="Example Usage">
        <t>This section presents two examples showing the ssh-client-grouping
        populated with some data. These examples are effectively the same
        except the first configures the client identity using a local key
        while the second uses a key configured in a keystore. Both examples
        are consistent with the examples presented in Section 3 of <xref
        target="I-D.ietf-netconf-trust-anchors"/> and Section 3.2 of <xref
        target="I-D.ietf-netconf-keystore"/>.</t>

        <t>The following example configures the client identity using a local
        key: <figure>
            <artwork><![CDATA[
========== NOTE: '\\' line wrapping per BCP XX (RFC XXXX) ===========

<ssh-client
   xmlns="urn:ietf:params:xml:ns:yang:ietf-ssh-client"
   xmlns:algs="urn:ietf:params:xml:ns:yang:ietf-ssh-common">

  <!-- how this client will authenticate itself to the server -->
  <ssh-client-identity>
    <username>foobar</username>
    <public-key>
      <local-definition>
        <algorithm xmlns:ct="urn:ietf:params:xml:ns:yang:ietf-crypto\
\-types">ct:rsa2048</algorithm>
        <private-key>base64encodedvalue==</private-key>
        <public-key>base64encodedvalue==</public-key>
      </local-definition>
    </public-key>
  </ssh-client-identity>

  <!-- which host-keys will this client trust -->
  <ssh-server-auth>
    <pinned-ssh-host-keys>explicitly-trusted-ssh-host-keys</pinned-s\
\sh-host-keys>
  </ssh-server-auth>

  <ssh-transport-params>
    <host-key>
      <host-key-alg>algs:ssh-rsa</host-key-alg>
    </host-key>
    <key-exchange>
      <key-exchange-alg>
        algs:diffie-hellman-group-exchange-sha256
      </key-exchange-alg>
    </key-exchange>
    <encryption>
      <encryption-alg>algs:aes256-ctr</encryption-alg>
      <encryption-alg>algs:aes192-ctr</encryption-alg>
      <encryption-alg>algs:aes128-ctr</encryption-alg>
      <encryption-alg>algs:aes256-cbc</encryption-alg>
      <encryption-alg>algs:aes192-cbc</encryption-alg>
      <encryption-alg>algs:aes128-cbc</encryption-alg>
    </encryption>
    <mac>
      <mac-alg>algs:hmac-sha2-256</mac-alg>
      <mac-alg>algs:hmac-sha2-512</mac-alg>
    </mac>
  </ssh-transport-params>
  
  <ssh-keepalives>
    <max-wait>30</max-wait>
    <max-attempts>3</max-attempts>
  </ssh-keepalives>
  
</ssh-client>
]]></artwork>
          </figure></t>

        <t>The following example configures the client identity using a key
        from the keystore: <figure>
            <artwork><![CDATA[
========== NOTE: '\\' line wrapping per BCP XX (RFC XXXX) ===========

<ssh-client
   xmlns="urn:ietf:params:xml:ns:yang:ietf-ssh-client"
   xmlns:algs="urn:ietf:params:xml:ns:yang:ietf-ssh-common">

  <!-- how this client will authenticate itself to the server -->
  <ssh-client-identity>
    <username>foobar</username>
    <public-key>
      <keystore-reference>ex-rsa-key</keystore-reference>
    </public-key>
  </ssh-client-identity>

  <!-- which host-keys will this client trust -->
  <ssh-server-auth>
    <pinned-ssh-host-keys>explicitly-trusted-ssh-host-keys</pinned-s\
\sh-host-keys>
  </ssh-server-auth>

  <ssh-transport-params>
    <host-key>
      <host-key-alg>algs:ssh-rsa</host-key-alg>
    </host-key>
    <key-exchange>
      <key-exchange-alg>
        algs:diffie-hellman-group-exchange-sha256
      </key-exchange-alg>
    </key-exchange>
    <encryption>
      <encryption-alg>algs:aes256-ctr</encryption-alg>
      <encryption-alg>algs:aes192-ctr</encryption-alg>
      <encryption-alg>algs:aes128-ctr</encryption-alg>
      <encryption-alg>algs:aes256-cbc</encryption-alg>
      <encryption-alg>algs:aes192-cbc</encryption-alg>
      <encryption-alg>algs:aes128-cbc</encryption-alg>
    </encryption>
    <mac>
      <mac-alg>algs:hmac-sha2-256</mac-alg>
      <mac-alg>algs:hmac-sha2-512</mac-alg>
    </mac>
  </ssh-transport-params>

  <ssh-keepalives>
    <max-wait>30</max-wait>
    <max-attempts>3</max-attempts>
  </ssh-keepalives>
  
</ssh-client>
]]></artwork>
          </figure></t>
      </section>

      <section anchor="ssh-client-yang-module" title="YANG Module">
        <t>This YANG module has normative references to <xref
        target="I-D.ietf-netconf-trust-anchors"/>, and <xref
        target="I-D.ietf-netconf-keystore"/>.</t>

        <t><figure>
            <artwork><![CDATA[
<CODE BEGINS> file "ietf-ssh-client@2019-03-09.yang"
module ietf-ssh-client {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:ietf-ssh-client";
  prefix "sshc";

  import ietf-ssh-common {
    prefix sshcmn;
    revision-date 2019-03-09; // stable grouping definitions
    reference
      "RFC XXXX: YANG Groupings for SSH Clients and SSH Servers";
  }

  import ietf-trust-anchors {
    prefix ta;
    reference
      "RFC YYYY: YANG Data Model for Global Trust Anchors";
  }

  import ietf-keystore {
    prefix ks;
    reference
      "RFC ZZZZ:
         YANG Data Model for a Centralized Keystore Mechanism";
  }

  organization
   "IETF NETCONF (Network Configuration) Working Group";

  contact
   "WG Web:   <http://datatracker.ietf.org/wg/netconf/>
    WG List:  <mailto:netconf@ietf.org>
    Author:   Kent Watsen <mailto:kent+ietf@watsen.net>
    Author:   Gary Wu <mailto:garywu@cisco.com>";

  description
   "This module defines reusable groupings for SSH clients that
    can be used as a basis for specific SSH client instances.

    The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL',
    'SHALL NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED',
    'NOT RECOMMENDED', 'MAY', and 'OPTIONAL' in this document
    are to be interpreted as described in BCP 14 [RFC2119]
    [RFC8174] when, and only when, they appear in all
    capitals, as shown here.

    Copyright (c) 2019 IETF Trust and the persons identified as
    authors of the code. All rights reserved.

    Redistribution and use in source and binary forms, with or
    without modification, is permitted pursuant to, and subject
    to the license terms contained in, the Simplified BSD
    License set forth in Section 4.c of the IETF Trust's
    Legal Provisions Relating to IETF Documents
    (http://trustee.ietf.org/license-info).

    This version of this YANG module is part of RFC XXXX; see
    the RFC itself for full legal notices.";

  revision "2019-03-09" {
    description
     "Initial version";
    reference
     "RFC XXXX: YANG Groupings for SSH Clients and SSH Servers";
  }

  // Features

  feature ssh-client-transport-params-config {
    description
      "SSH transport layer parameters are configurable on an SSH
       client.";
  }

  feature ssh-client-keepalives {
    description
      "Per socket SSH keepalive parameters are configurable for
       SSH clients on the server implementing this feature.";
  }

  // Groupings

  grouping ssh-client-grouping {
    description
      "A reusable grouping for configuring a SSH client without
       any consideration for how an underlying TCP session is
       established.";
    uses client-identity-grouping;
    uses server-auth-grouping;
    uses transport-params-grouping;
    uses keepalives-grouping;
  }

  grouping client-identity-grouping {
    description
      "A reusable grouping for configuring a SSH client identity.";
    container ssh-client-identity {
      description
        "The credentials used by the client to authenticate to
         the SSH server.";
      leaf username {
        type string;
        description
          "The username of this user.  This will be the username
           used, for instance, to log into an SSH server.";
      }
      choice auth-type {
        mandatory true;
        description
          "The authentication type.";
        leaf password {
          type string;
          description
            "A password to be used for client authentication.";
        }
        container public-key {
          uses ks:local-or-keystore-asymmetric-key-grouping;
          description
            "A locally-defined or referenced asymmetric key pair
             to be used for client authentication.";
          reference
            "RFC ZZZZ:
              YANG Data Model for a Centralized Keystore Mechanism";
        }
        container certificate {
          if-feature sshcmn:ssh-x509-certs;
          uses ks:local-or-keystore-end-entity-cert-with-key-grouping;
          description
            "A locally-defined or referenced certificate
             to be used for client authentication.";
          reference
            "RFC ZZZZ
              YANG Data Model for a Centralized Keystore Mechanism";
        }
      } // auth-type
    } // client-identity
  } // client-identity-grouping

  grouping server-auth-grouping {
    description
      "A reusable grouping for configuring SSH server
       authentication.";
    container ssh-server-auth {
      must 'pinned-ssh-host-keys or pinned-ca-certs or ' 
           + 'pinned-server-certs';
      description
        "Trusted server identities.";
      leaf pinned-ssh-host-keys {
        if-feature "ta:ssh-host-keys";
        type ta:pinned-host-keys-ref;
        description
          "A reference to a list of SSH host keys used by the
           SSH client to authenticate SSH server host keys.
           A server host key is authenticated if it is an exact
           match to a configured SSH host key.";
        reference
          "RFC YYYY: YANG Data Model for Global Trust Anchors";
      }
      leaf pinned-ca-certs {
        if-feature sshcmn:ssh-x509-certs;
        if-feature "ta:x509-certificates";
        type ta:pinned-certificates-ref;
        description
          "A reference to a list of certificate authority (CA)
           certificates used by the SSH client to authenticate
           SSH server certificates.  A server certificate is
           authenticated if it has a valid chain of trust to
           a configured CA certificate.";
        reference
          "RFC YYYY: YANG Data Model for Global Trust Anchors";
      }

      leaf pinned-server-certs {
        if-feature sshcmn:ssh-x509-certs;
        if-feature "ta:x509-certificates";
        type ta:pinned-certificates-ref;
        description
          "A reference to a list of server certificates used by
           the SSH client to authenticate SSH server certificates.
           A server certificate is authenticated if it is an
           exact match to a configured server certificate.";
        reference
          "RFC YYYY: YANG Data Model for Global Trust Anchors";
      }
    } // server-auth
  } // server-auth-grouping

  grouping transport-params-grouping {
    description
      "A reusable grouping for configuring a SSH transport
       parameters.";
    container ssh-transport-params {
      if-feature ssh-client-transport-params-config;
      description
        "Configurable parameters of the SSH transport layer.";
      uses sshcmn:transport-params-grouping;
    }
  } // transport-params-grouping

  grouping keepalives-grouping {
    description
      "A reusable grouping for configuring SSH client keepalive
       parameters.";
    container ssh-keepalives {
      if-feature "ssh-client-keepalives";
      description
        "Configures the keep-alive policy, to proactively test the
         aliveness of the SSH server.  An unresponsive TLS server is
         dropped after approximately max-wait * max-attempts seconds.";
      leaf max-wait {
        type uint16 {
          range "1..max";
        }
        units seconds;
        default 30;
        description
         "Sets the amount of time in seconds after which if no data
          has been received from the SSH server, a TLS-level message
          will be sent to test the aliveness of the SSH server.";
      }
      leaf max-attempts {
        type uint8;
        default 3;
        description
         "Sets the maximum number of sequential keep-alive messages
         that can fail to obtain a response from the SSH server
         before assuming the SSH server is no longer alive.";
      }
    }
  } // keepalives-grouping

}
<CODE ENDS>
]]></artwork>
          </figure></t>
      </section>
    </section>

    <section anchor="ssh-server-model" title="The SSH Server Model">
      <section title="Tree Diagram">
        <t>This section provides a tree diagram <xref target="RFC8340"/> for
        the "ietf-ssh-server" module that does not have groupings
        expanded.</t>

        <t><figure>
            <artwork><![CDATA[
module: ietf-ssh-server

  grouping ssh-server-grouping
    +---u server-identity-grouping
    +---u client-auth-grouping
    +---u transport-params-grouping
    +---u keepalives-grouping
  grouping server-identity-grouping
    +-- ssh-server-identity
       +-- host-key* [name]
          +-- name?                string
          +-- (host-key-type)
             +--:(public-key)
             |  +-- public-key
             |     +---u server-identity-grouping
             +--:(certificate)
                +-- certificate {sshcmn:ssh-x509-certs}?
                   +---u server-identity-grouping
  grouping client-auth-grouping
    +-- ssh-client-cert-auth {sshcmn:ssh-x509-certs}?
       +-- pinned-ca-certs?       ta:pinned-certificates-ref
       |       {ta:x509-certificates}?
       +-- pinned-client-certs?   ta:pinned-certificates-ref
               {ta:x509-certificates}?
  grouping transport-params-grouping
    +-- ssh-transport-params {ssh-server-transport-params-config}?
       +---u transport-params-grouping
  grouping keepalives-grouping
    +-- ssh-keepalives {ssh-server-keepalives}?
       +-- max-wait?       uint16
       +-- max-attempts?   uint8
]]></artwork>
          </figure></t>
      </section>

      <section title="Example Usage">
        <t>This section presents two examples showing the ssh-server-grouping
        populated with some data. These examples are effectively the same
        except the first configures the server identity using a local key
        while the second uses a key configured in a keystore. Both examples
        are consistent with the examples presented in Section 3 of <xref
        target="I-D.ietf-netconf-trust-anchors"/> and Section 3.2 of <xref
        target="I-D.ietf-netconf-keystore"/>.</t>

        <t>The following example configures the server identity using a local
        key: <figure>
            <artwork><![CDATA[
========== NOTE: '\\' line wrapping per BCP XX (RFC XXXX) ===========

<ssh-server xmlns="urn:ietf:params:xml:ns:yang:ietf-ssh-server"
            xmlns:algs="urn:ietf:params:xml:ns:yang:ietf-ssh-common">

  <!-- which host-keys will this SSH server present -->
  <ssh-server-identity>
    <host-key>
      <name>deployment-specific-certificate</name>
      <public-key>
        <local-definition>
          <algorithm xmlns:ct="urn:ietf:params:xml:ns:yang:ietf-cryp\
\to-types">ct:rsa2048</algorithm>
          <private-key>base64encodedvalue==</private-key>
          <public-key>base64encodedvalue==</public-key>
        </local-definition>
      </public-key>
    </host-key>
  </ssh-server-identity>

  <!-- which client-certs will this SSH server trust -->
  <ssh-client-cert-auth>
    <pinned-ca-certs>explicitly-trusted-client-ca-certs</pinned-ca-c\
\erts>
    <pinned-client-certs>explicitly-trusted-client-certs</pinned-cli\
\ent-certs>
  </ssh-client-cert-auth>

  <ssh-transport-params>
    <host-key>
      <host-key-alg>algs:ssh-rsa</host-key-alg>
    </host-key>
    <key-exchange>
      <key-exchange-alg>
        algs:diffie-hellman-group-exchange-sha256
      </key-exchange-alg>
    </key-exchange>
    <encryption>
      <encryption-alg>algs:aes256-ctr</encryption-alg>
      <encryption-alg>algs:aes192-ctr</encryption-alg>
      <encryption-alg>algs:aes128-ctr</encryption-alg>
      <encryption-alg>algs:aes256-cbc</encryption-alg>
      <encryption-alg>algs:aes192-cbc</encryption-alg>
      <encryption-alg>algs:aes128-cbc</encryption-alg>
    </encryption>
    <mac>
      <mac-alg>algs:hmac-sha2-256</mac-alg>
      <mac-alg>algs:hmac-sha2-512</mac-alg>
    </mac>
  </ssh-transport-params>

</ssh-server>
]]></artwork>
          </figure></t>

        <t>The following example configures the server identity using a key
        from the keystore: <figure>
            <artwork><![CDATA[
========== NOTE: '\\' line wrapping per BCP XX (RFC XXXX) ===========

<ssh-server xmlns="urn:ietf:params:xml:ns:yang:ietf-ssh-server"
            xmlns:algs="urn:ietf:params:xml:ns:yang:ietf-ssh-common">

  <!-- which host-keys will this SSH server present -->
  <ssh-server-identity>
    <host-key>
      <name>deployment-specific-certificate</name>
      <public-key>
        <keystore-reference>ex-rsa-key</keystore-reference>
      </public-key>
    </host-key>
  </ssh-server-identity>

  <!-- which client-certs will this SSH server trust -->
  <ssh-client-cert-auth>
    <pinned-ca-certs>explicitly-trusted-client-ca-certs</pinned-ca-c\
\erts>
    <pinned-client-certs>explicitly-trusted-client-certs</pinned-cli\
\ent-certs>
  </ssh-client-cert-auth>

  <ssh-transport-params>
    <host-key>
      <host-key-alg>algs:ssh-rsa</host-key-alg>
    </host-key>
    <key-exchange>
      <key-exchange-alg>
        algs:diffie-hellman-group-exchange-sha256
      </key-exchange-alg>
    </key-exchange>
    <encryption>
      <encryption-alg>algs:aes256-ctr</encryption-alg>
      <encryption-alg>algs:aes192-ctr</encryption-alg>
      <encryption-alg>algs:aes128-ctr</encryption-alg>
      <encryption-alg>algs:aes256-cbc</encryption-alg>
      <encryption-alg>algs:aes192-cbc</encryption-alg>
      <encryption-alg>algs:aes128-cbc</encryption-alg>
    </encryption>
    <mac>
      <mac-alg>algs:hmac-sha2-256</mac-alg>
      <mac-alg>algs:hmac-sha2-512</mac-alg>
    </mac>
  </ssh-transport-params>

</ssh-server>
]]></artwork>
          </figure></t>
      </section>

      <section anchor="ssh-server-yang-module" title="YANG Module">
        <t>This YANG module has normative references to <xref
        target="I-D.ietf-netconf-trust-anchors"/> and <xref
        target="I-D.ietf-netconf-keystore"/> and informative references to
        <xref target="RFC4253"/> and <xref target="RFC7317"/>.</t>

        <t><figure>
            <artwork><![CDATA[
<CODE BEGINS> file "ietf-ssh-server@2019-03-09.yang"
========== NOTE: '\\' line wrapping per BCP XX (RFC XXXX) ===========

module ietf-ssh-server {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:ietf-ssh-server";
  prefix "sshs";

  import ietf-ssh-common {
    prefix sshcmn;
    revision-date 2019-03-09; // stable grouping definitions
    reference
      "RFC XXXX: YANG Groupings for SSH Clients and SSH Servers";
  }

  import ietf-trust-anchors {
    prefix ta;
    reference
      "RFC YYYY: YANG Data Model for Global Trust Anchors";
  }

  import ietf-keystore {
    prefix ks;
    reference
      "RFC ZZZZ:
         YANG Data Model for a Centralized Keystore Mechanism";
  }

  organization
   "IETF NETCONF (Network Configuration) Working Group";

  contact
   "WG Web:   <http://datatracker.ietf.org/wg/netconf/>
    WG List:  <mailto:netconf@ietf.org>
    Author:   Kent Watsen <mailto:kent+ietf@watsen.net>
    Author:   Gary Wu <mailto:garywu@cisco.com>";

  description
   "This module defines reusable groupings for SSH servers that
    can be used as a basis for specific SSH server instances.

    The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL',
    'SHALL NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED',
    'NOT RECOMMENDED', 'MAY', and 'OPTIONAL' in this document
    are to be interpreted as described in BCP 14 [RFC2119]
    [RFC8174] when, and only when, they appear in all
    capitals, as shown here.

    Copyright (c) 2019 IETF Trust and the persons identified as
    authors of the code. All rights reserved.

    Redistribution and use in source and binary forms, with or
    without modification, is permitted pursuant to, and subject
    to the license terms contained in, the Simplified BSD
    License set forth in Section 4.c of the IETF Trust's
    Legal Provisions Relating to IETF Documents
    (http://trustee.ietf.org/license-info).

    This version of this YANG module is part of RFC XXXX; see
    the RFC itself for full legal notices.";

  revision "2019-03-09" {
    description
     "Initial version";
    reference
     "RFC XXXX: YANG Groupings for SSH Clients and SSH Servers";
  }

  // Features

  feature ssh-server-transport-params-config {
    description
      "SSH transport layer parameters are configurable on an SSH
       server.";
  }

  feature ssh-server-keepalives {
    description
      "Per socket SSH keepalive parameters are configurable for 
       SSH servers on the server implementing this feature.";
  }


  // Groupings

  grouping ssh-server-grouping {
    description
      "A reusable grouping for configuring a SSH server without
       any consideration for how underlying TCP sessions are 
       established.";
    uses server-identity-grouping;
    uses client-auth-grouping;
    uses transport-params-grouping;
    uses keepalives-grouping;
  }

  grouping server-identity-grouping {
    description
      "A reusable grouping for configuring an SSH server identity.";
    container ssh-server-identity {
      description
        "The list of host-keys the SSH server will present when
         establishing a SSH connection.";
      list host-key {
        key name;
        min-elements 1;
        ordered-by user;
        description
          "An ordered list of host keys the SSH server will use to
           construct its ordered list of algorithms, when sending
           its SSH_MSG_KEXINIT message, as defined in Section 7.1
           of RFC 4253.";
        reference
          "RFC 4253: The Secure Shell (SSH) Transport Layer
                     Protocol";
        leaf name {
          type string;
          description
            "An arbitrary name for this host-key";
        }
        choice host-key-type {
          mandatory true;
          description
            "The type of host key being specified";
          container public-key {
            uses ks:local-or-keystore-asymmetric-key-grouping;
            description
              "A locally-defined or referenced asymmetric key pair
               to be used for the SSH server's host key.";
            reference
              "RFC ZZZZ: YANG Data Model for a Centralized
                         Keystore Mechanism";
          }
          container certificate {
            if-feature sshcmn:ssh-x509-certs;
            uses
              ks:local-or-keystore-end-entity-cert-with-key-grouping;
            description
              "A locally-defined or referenced end-entity
               certificate to be used for the SSH server's
               host key.";
            reference
              "RFC ZZZZ: YANG Data Model for a Centralized
                         Keystore Mechanism";
          }
        }
      }
    } // server-identity
  } // server-identity-grouping


  grouping client-auth-grouping {
    description
      "A reusable grouping for configuring a SSH client
       authentication.";
    container ssh-client-cert-auth {
      if-feature sshcmn:ssh-x509-certs;
      description
        "A reference to a list of pinned certificate authority (CA)
         certificates and a reference to a list of pinned client
         certificates.

         Note: password and public-key based client authentication
               are not configured in this YANG module as they are
               expected to be configured by the ietf-system module
               defined in RFC 7317.";
      reference
        "RFC 7317: A YANG Data Model for System Management";
      leaf pinned-ca-certs {
        if-feature "ta:x509-certificates";
        type ta:pinned-certificates-ref;
        description
          "A reference to a list of certificate authority (CA) 
           certificates used by the SSH server to authenticate
           SSH client certificates.  A client certificate is
           authenticated if it has a valid chain of trust to
           a configured pinned CA certificate.";
        reference
          "RFC YYYY: YANG Data Model for Global Trust Anchors";
      }
      leaf pinned-client-certs {
        if-feature "ta:x509-certificates";
        type ta:pinned-certificates-ref;
        description
          "A reference to a list of client certificates used by 
           the SSH server to authenticate SSH client certificates.
           A clients certificate is authenticated if it is an
           exact match to a configured pinned client certificate.";
        reference
          "RFC YYYY: YANG Data Model for Global Trust Anchors";
      }
    }
  } // client-auth-grouping


  grouping transport-params-grouping {
    description
      "A reusable grouping for configuring a SSH transport
       parameters.";
    container ssh-transport-params {
      if-feature ssh-server-transport-params-config;
      description
        "Configurable parameters of the SSH transport layer.";
      uses sshcmn:transport-params-grouping;
    }
  } // transport-params-grouping


  grouping keepalives-grouping {
    description
      "A reusable grouping for configuring SSH server keepalive
       parameters.";
    container ssh-keepalives {
      if-feature "ssh-server-keepalives";
      description
        "Configures the keep-alive policy, to proactively test the
         aliveness of the SSL client.  An unresponsive SSL client is
         dropped after approximately max-wait * max-attempts seconds\
\.";
      leaf max-wait {
        type uint16 {
          range "1..max";
        }
        units seconds;
        default 30;
        description
         "Sets the amount of time in seconds after which if no data
          has been received from the SSL client, a SSL-level message
          will be sent to test the aliveness of the SSL client.";
      }
      leaf max-attempts {
        type uint8;
        default 3;
        description
         "Sets the maximum number of sequential keep-alive messages
         that can fail to obtain a response from the SSL client
         before assuming the SSL client is no longer alive.";
      }
    }
  } // keepalives-grouping

}
<CODE ENDS>
]]></artwork>
          </figure></t>
      </section>
    </section>

    <section anchor="ssh-common-model" title="The SSH Common Model">
      <t>The SSH common model presented in this section contains identities
      and groupings common to both SSH clients and SSH servers. The
      transport-params-grouping can be used to configure the list of SSH
      transport algorithms permitted by the SSH client or SSH server. The
      lists of algorithms are ordered such that, if multiple algorithms are
      permitted by the client, the algorithm that appears first in its list
      that is also permitted by the server is used for the SSH transport layer
      connection. The ability to restrict the algorithms allowed is
      provided in this grouping for SSH clients and SSH servers that are
      capable of doing so and may serve to make SSH clients and SSH servers
      compliant with security policies.</t>

      <t><xref target="I-D.ietf-netconf-crypto-types"/> defines six categories
      of cryptographic algorithms (hash-algorithm,
      symmetric-key-encryption-algorithm, mac-algorithm,
      asymmetric-key-encryption-algorithm, signature-algorithm,
      key-negotiation-algorithm) and lists several widely accepted algorithms
      for each of them. The SSH client and server models use one or more of
      these algorithms. The SSH common model includes four parameters for
      configuring its permitted SSH algorithms, which are: host-key-alg,
      key-exchange-alg, encryption-alg and mac-alg. The following tables are
      provided, in part, to define the subset of algorithms defined in the
      crypto-types model used by SSH and, in part, to ensure compatibility of
      configured SSH cryptographic parameters for configuring its permitted
      SSH algorithms ("sshcmn" representing SSH common model, and "ct"
      representing crypto-types model which the SSH client/server model is
      based on):<figure
          title="Table 1   The SSH Host-key-alg Compatibility Matrix">
          <artwork align="center">+-------------------------------+-------------------------------+
|     sshcmn:host-key-alg       |      ct:signature-algorithm   |
+-------------------------------+-------------------------------+
| dsa-sha1                      | dsa-sha1                      |
| rsa-pkcs1-sha1                | rsa-pkcs1-sha1                |
| rsa-pkcs1-sha256              | rsa-pkcs1-sha256              |
| rsa-pkcs1-sha512              | rsa-pkcs1-sha512              |
| ecdsa-secp256r1-sha256        | ecdsa-secp256r1-sha256        |
| ecdsa-secp384r1-sha384        | ecdsa-secp384r1-sha384        |
| ecdsa-secp521r1-sha512        | ecdsa-secp521r1-sha512        |
| x509v3-rsa-pkcs1-sha1         | x509v3-rsa-pkcs1-sha1         |
| x509v3-rsa2048-pkcs1-sha256   | x509v3-rsa2048-pkcs1-sha1     |
| x509v3-ecdsa-secp256r1-sha256 | x509v3-ecdsa-secp256r1-sha256 |
| x509v3-ecdsa-secp384r1-sha384 | x509v3-ecdsa-secp384r1-sha384 |
| x509v3-ecdsa-secp521r1-sha512 | x509v3-ecdsa-secp521r1-sha512 |
+-------------------------------+-------------------------------+</artwork>
        </figure><figure
          title="Table 2   The SSH Key-exchange-alg Compatibility Matrix">
          <artwork align="center">+-------------------------------+-------------------------------+
| sshcmn:key-exchange-alg       | ct:key-negotiation-algorithm  |
+-------------------------------+-------------------------------+
| diffie-hellman-group14-sha1   | diffie-hellman-group14-sha1   |
| diffie-hellman-group14-sha256 | diffie-hellman-group14-sha256 |
| diffie-hellman-group15-sha512 | diffie-hellman-group15-sha512 |
| diffie-hellman-group16-sha512 | diffie-hellman-group16-sha512 |
| diffie-hellman-group17-sha512 | diffie-hellman-group17-sha512 |
| diffie-hellman-group18-sha512 | diffie-hellman-group18-sha512 |
| ecdh-sha2-secp256r1           | ecdh-sha2-secp256r1           |
| ecdh-sha2-secp384r1           | ecdh-sha2-secp384r1           |
+-------------------------------+-------------------------------+</artwork>
        </figure><figure
          title="Table 3   The SSH Encryption-alg Compatibility Matrix">
          <artwork align="center">+-----------------------+---------------------------------------+
| sshcmn:encryption-alg | ct:symmetric-key-encryption-algorithm |
+-----------------------+---------------------------------------+
| aes-128-cbc           | aes-128-cbc                           |
| aes-192-cbc           | aes-192-cbc                           |
| aes-256-cbc           | aes-256-cbc                           |
| aes-128-ctr           | aes-128-ctr                           |
| aes-192-ctr           | aes-192-ctr                           |
| aes-256-ctr           | aes-256-ctr                           |
+-----------------------+---------------------------------------+</artwork>
        </figure><figure
          title="Table 4   The SSH Mac-alg Compatibility Matrix">
          <artwork align="center">+----------------+-------------------+
| sshcmn:mac-alg | ct:mac-algorithm  |
+----------------+-------------------+
| hmac-sha1      | hmac-sha1         |
| hmac-sha1-96   | hmac-sha1-96      |
| hmac-sha2-256  | hmac-sha2-256     |
| hmac-sha2-512  | hmac-sha2-512     |
+----------------+-------------------+</artwork>
        </figure></t>

      <t>As is seen in the tables above, the names of the “sshcmn” algorithms
      are all identical to the names of algorithms defined in <xref
      target="I-D.ietf-netconf-crypto-types"/>. While appearing to be
      redundant, it is important to realize that not all the algorithms
      defined in <xref target="I-D.ietf-netconf-crypto-types"/> are supported
      by SSH. That is, the algorithms supported by SSH are a subset of the
      algorithms defined in <xref target="I-D.ietf-netconf-crypto-types"/>.
      The algorithms used by SSH are redefined in this document in order to
      constrain the algorithms that may be selected to just the ones used by
      SSH.</t>

      <t>Features are defined for algorithms that are OPTIONAL or are not
      widely supported by popular implementations. Note that the list of
      algorithms is not exhaustive. As well, some algorithms that are REQUIRED
      by <xref target="RFC4253"/> are missing, notably "ssh-dss" and
      "diffie-hellman-group1-sha1" due to their weak security and there being
      alternatives that are widely supported.</t>

      <section title="Tree Diagram">
        <t>The following tree diagram <xref target="RFC8340"/> provides an
        overview of the data model for the "ietf-ssh-common" module.</t>

        <t><figure>
            <artwork><![CDATA[
module: ietf-ssh-common

  grouping transport-params-grouping
    +-- host-key
    |  +-- host-key-alg*   identityref
    +-- key-exchange
    |  +-- key-exchange-alg*   identityref
    +-- encryption
    |  +-- encryption-alg*   identityref
    +-- mac
       +-- mac-alg*   identityref
]]></artwork>
          </figure></t>
      </section>

      <section title="Example Usage">
        <t>This following example illustrates how the
        transport-params-grouping appears when populated with some data.</t>

        <t><figure>
            <artwork><![CDATA[
<transport-params
  xmlns="urn:ietf:params:xml:ns:yang:ietf-ssh-common"
  xmlns:algs="urn:ietf:params:xml:ns:yang:ietf-ssh-common">
  <host-key>
    <host-key-alg>algs:x509v3-rsa2048-sha256</host-key-alg>
    <host-key-alg>algs:ssh-rsa</host-key-alg>
  </host-key>
  <key-exchange>
    <key-exchange-alg>
      algs:diffie-hellman-group-exchange-sha256
    </key-exchange-alg>
  </key-exchange>
  <encryption>
    <encryption-alg>algs:aes256-ctr</encryption-alg>
    <encryption-alg>algs:aes192-ctr</encryption-alg>
    <encryption-alg>algs:aes128-ctr</encryption-alg>
    <encryption-alg>algs:aes256-cbc</encryption-alg>
    <encryption-alg>algs:aes192-cbc</encryption-alg>
    <encryption-alg>algs:aes128-cbc</encryption-alg>
  </encryption>
  <mac>
    <mac-alg>algs:hmac-sha2-256</mac-alg>
    <mac-alg>algs:hmac-sha2-512</mac-alg>
  </mac>
</transport-params>
]]></artwork>
          </figure></t>
      </section>

      <section anchor="ssh-common-yang-module" title="YANG Module">
        <t>This YANG module has normative references to <xref
        target="RFC4253"/>, <xref target="RFC4344"/>, <xref
        target="RFC4419"/>, <xref target="RFC5656"/>, <xref
        target="RFC6187"/>, and <xref target="RFC6668"/>.</t>

        <t><figure>
            <artwork><![CDATA[
<CODE BEGINS> file "ietf-ssh-common@2019-03-09.yang"
module ietf-ssh-common {
  yang-version 1.1;
  namespace "urn:ietf:params:xml:ns:yang:ietf-ssh-common";
  prefix "sshcmn";

  organization
   "IETF NETCONF (Network Configuration) Working Group";

  contact
   "WG Web:   <http://datatracker.ietf.org/wg/netconf/>
    WG List:  <mailto:netconf@ietf.org>
    Author:   Kent Watsen <mailto:kent+ietf@watsen.net>
    Author:   Gary Wu <mailto:garywu@cisco.com>";

  description
   "This module defines a common features, identities, and
    groupings for Secure Shell (SSH).

    The key words 'MUST', 'MUST NOT', 'REQUIRED', 'SHALL',
    'SHALL NOT', 'SHOULD', 'SHOULD NOT', 'RECOMMENDED',
    'NOT RECOMMENDED', 'MAY', and 'OPTIONAL' in this document
    are to be interpreted as described in BCP 14 [RFC2119]
    [RFC8174] when, and only when, they appear in all
    capitals, as shown here.

    Copyright (c) 2019 IETF Trust and the persons identified as
    authors of the code. All rights reserved.

    Redistribution and use in source and binary forms, with or
    without modification, is permitted pursuant to, and subject
    to the license terms contained in, the Simplified BSD
    License set forth in Section 4.c of the IETF Trust's
    Legal Provisions Relating to IETF Documents
    (http://trustee.ietf.org/license-info).

    This version of this YANG module is part of RFC XXXX; see
    the RFC itself for full legal notices.";

  revision "2019-03-09" {
    description
     "Initial version";
    reference
     "RFC XXXX: YANG Groupings for SSH Clients and SSH Servers";
  }

  // features

  feature ssh-ecc {
    description
      "Elliptic Curve Cryptography is supported for SSH.";
    reference
      "RFC 5656: Elliptic Curve Algorithm Integration in the
                 Secure Shell Transport Layer";
  }

  feature ssh-x509-certs {
    description
      "X.509v3 certificates are supported for SSH per RFC 6187.";
    reference
      "RFC 6187: X.509v3 Certificates for Secure Shell
                 Authentication";
  }

  feature ssh-dh-group-exchange {
    description
      "Diffie-Hellman Group Exchange is supported for SSH.";
    reference
      "RFC 4419: Diffie-Hellman Group Exchange for the
                 Secure Shell (SSH) Transport Layer Protocol";
  }

  feature ssh-ctr {
    description
      "SDCTR encryption mode is supported for SSH.";
    reference
      "RFC 4344: The Secure Shell (SSH) Transport Layer
                 Encryption Modes";
  }

  feature ssh-sha2 {
    description
      "The SHA2 family of cryptographic hash functions is
       supported for SSH.";
    reference
      "FIPS PUB 180-4: Secure Hash Standard (SHS)";
  }

  // identities

  identity public-key-alg-base {
    description
      "Base identity used to identify public key algorithms.";
  }

  identity ssh-dss {
    base public-key-alg-base;
    description
      "Digital Signature Algorithm using SHA-1 as the
       hashing algorithm.";
    reference
      "RFC 4253:
         The Secure Shell (SSH) Transport Layer Protocol";
  }

  identity ssh-rsa {
    base public-key-alg-base;
    description
      "RSASSA-PKCS1-v1_5 signature scheme using SHA-1 as the
       hashing algorithm.";
    reference
      "RFC 4253:
         The Secure Shell (SSH) Transport Layer Protocol";
  }

  identity ecdsa-sha2-nistp256 {
    base public-key-alg-base;
    if-feature "ssh-ecc and ssh-sha2";
    description
      "Elliptic Curve Digital Signature Algorithm (ECDSA) using the
       nistp256 curve and the SHA2 family of hashing algorithms.";
    reference
      "RFC 5656: Elliptic Curve Algorithm Integration in the
                 Secure Shell Transport Layer";
  }

  identity ecdsa-sha2-nistp384 {
    base public-key-alg-base;
    if-feature "ssh-ecc and ssh-sha2";
    description
      "Elliptic Curve Digital Signature Algorithm (ECDSA) using the
       nistp384 curve and the SHA2 family of hashing algorithms.";
    reference
      "RFC 5656: Elliptic Curve Algorithm Integration in the
                 Secure Shell Transport Layer";
  }

  identity ecdsa-sha2-nistp521 {
    base public-key-alg-base;
    if-feature "ssh-ecc and ssh-sha2";
    description
      "Elliptic Curve Digital Signature Algorithm (ECDSA) using the
       nistp521 curve and the SHA2 family of hashing algorithms.";
    reference
      "RFC 5656: Elliptic Curve Algorithm Integration in the
                 Secure Shell Transport Layer";
  }

  identity x509v3-ssh-rsa {
    base public-key-alg-base;
    if-feature ssh-x509-certs;
    description
      "RSASSA-PKCS1-v1_5 signature scheme using a public key stored
       in an X.509v3 certificate and using SHA-1 as the hashing
       algorithm.";
    reference
      "RFC 6187: X.509v3 Certificates for Secure Shell
                 Authentication";
  }

  identity x509v3-rsa2048-sha256 {
    base public-key-alg-base;
    if-feature "ssh-x509-certs and ssh-sha2";
    description
      "RSASSA-PKCS1-v1_5 signature scheme using a public key stored
       in an X.509v3 certificate and using SHA-256 as the hashing
       algorithm.  RSA keys conveyed using this format MUST have a
       modulus of at least 2048 bits.";
    reference
      "RFC 6187: X.509v3 Certificates for Secure Shell
                 Authentication";
  }

  identity x509v3-ecdsa-sha2-nistp256 {
    base public-key-alg-base;
    if-feature "ssh-ecc and ssh-x509-certs and ssh-sha2";
    description
      "Elliptic Curve Digital Signature Algorithm (ECDSA)
       using the nistp256 curve with a public key stored in
       an X.509v3 certificate and using the SHA2 family of
       hashing algorithms.";
    reference
      "RFC 6187: X.509v3 Certificates for Secure Shell
                 Authentication";
  }

  identity x509v3-ecdsa-sha2-nistp384 {
    base public-key-alg-base;
    if-feature "ssh-ecc and ssh-x509-certs and ssh-sha2";
    description
      "Elliptic Curve Digital Signature Algorithm (ECDSA)
       using the nistp384 curve with a public key stored in
       an X.509v3 certificate and using the SHA2 family of
       hashing algorithms.";
    reference
      "RFC 6187: X.509v3 Certificates for Secure Shell
                 Authentication";
  }

  identity x509v3-ecdsa-sha2-nistp521 {
    base public-key-alg-base;
    if-feature "ssh-ecc and ssh-x509-certs and ssh-sha2";
    description
      "Elliptic Curve Digital Signature Algorithm (ECDSA)
       using the nistp521 curve with a public key stored in
       an X.509v3 certificate and using the SHA2 family of
       hashing algorithms.";
    reference
      "RFC 6187: X.509v3 Certificates for Secure Shell
                 Authentication";
  }

  identity key-exchange-alg-base {
    description
      "Base identity used to identify key exchange algorithms.";
  }

  identity diffie-hellman-group14-sha1 {
    base key-exchange-alg-base;
    description
      "Diffie-Hellman key exchange with SHA-1 as HASH and
       Oakley Group 14 (2048-bit MODP Group).";
    reference
      "RFC 4253: The Secure Shell (SSH) Transport Layer Protocol";
  }

  identity diffie-hellman-group-exchange-sha1 {
    base key-exchange-alg-base;
    if-feature ssh-dh-group-exchange;
    description
      "Diffie-Hellman Group and Key Exchange with SHA-1 as HASH.";
    reference
      "RFC 4419: Diffie-Hellman Group Exchange for the
                 Secure Shell (SSH) Transport Layer Protocol";
  }

  identity diffie-hellman-group-exchange-sha256 {
    base key-exchange-alg-base;
    if-feature "ssh-dh-group-exchange and ssh-sha2";
    description
      "Diffie-Hellman Group and Key Exchange with SHA-256 as HASH.";
    reference
      "RFC 4419: Diffie-Hellman Group Exchange for the
                 Secure Shell (SSH) Transport Layer Protocol";
  }

  identity ecdh-sha2-nistp256 {
    base key-exchange-alg-base;
    if-feature "ssh-ecc and ssh-sha2";
    description
      "Elliptic Curve Diffie-Hellman (ECDH) key exchange using the
       nistp256 curve and the SHA2 family of hashing algorithms.";
    reference
      "RFC 5656: Elliptic Curve Algorithm Integration in the
                 Secure Shell Transport Layer";
  }

  identity ecdh-sha2-nistp384 {
    base key-exchange-alg-base;
    if-feature "ssh-ecc and ssh-sha2";
    description
      "Elliptic Curve Diffie-Hellman (ECDH) key exchange using the
       nistp384 curve and the SHA2 family of hashing algorithms.";
    reference
      "RFC 5656: Elliptic Curve Algorithm Integration in the
                 Secure Shell Transport Layer";
  }

  identity ecdh-sha2-nistp521 {
    base key-exchange-alg-base;
    if-feature "ssh-ecc and ssh-sha2";
    description
      "Elliptic Curve Diffie-Hellman (ECDH) key exchange using the
       nistp521 curve and the SHA2 family of hashing algorithms.";
    reference
      "RFC 5656: Elliptic Curve Algorithm Integration in the
                 Secure Shell Transport Layer";
  }

  identity encryption-alg-base {
    description
      "Base identity used to identify encryption algorithms.";
  }

  identity triple-des-cbc {
    base encryption-alg-base;
    description
      "Three-key 3DES in CBC mode.";
    reference
      "RFC 4253: The Secure Shell (SSH) Transport Layer Protocol";
  }

  identity aes128-cbc {
    base encryption-alg-base;
    description
     "AES in CBC mode, with a 128-bit key.";
    reference
     "RFC 4253: The Secure Shell (SSH) Transport Layer Protocol";
  }

  identity aes192-cbc {
    base encryption-alg-base;
    description
      "AES in CBC mode, with a 192-bit key.";
    reference
      "RFC 4253: The Secure Shell (SSH) Transport Layer Protocol";
  }

  identity aes256-cbc {
    base encryption-alg-base;
    description
      "AES in CBC mode, with a 256-bit key.";
    reference
      "RFC 4253: The Secure Shell (SSH) Transport Layer Protocol";
  }

  identity aes128-ctr {
    base encryption-alg-base;
    if-feature ssh-ctr;
    description
      "AES in SDCTR mode, with 128-bit key.";
    reference
      "RFC 4344: The Secure Shell (SSH) Transport Layer Encryption
                 Modes";
  }

  identity aes192-ctr {
    base encryption-alg-base;
    if-feature ssh-ctr;
    description
      "AES in SDCTR mode, with 192-bit key.";
    reference
      "RFC 4344: The Secure Shell (SSH) Transport Layer Encryption
                 Modes";
  }

  identity aes256-ctr {
    base encryption-alg-base;
    if-feature ssh-ctr;
    description
      "AES in SDCTR mode, with 256-bit key.";
    reference
      "RFC 4344: The Secure Shell (SSH) Transport Layer Encryption
         Modes";
  }

  identity mac-alg-base {
    description
      "Base identity used to identify message authentication
       code (MAC) algorithms.";
  }

  identity hmac-sha1 {
    base mac-alg-base;
    description
      "HMAC-SHA1";
    reference
      "RFC 4253: The Secure Shell (SSH) Transport Layer Protocol";
  }

  identity hmac-sha2-256 {
    base mac-alg-base;
    if-feature "ssh-sha2";
    description
      "HMAC-SHA2-256";
    reference
      "RFC 6668: SHA-2 Data Integrity Verification for the
                 Secure Shell (SSH) Transport Layer Protocol";
  }

  identity hmac-sha2-512 {
    base mac-alg-base;
    if-feature "ssh-sha2";
    description
      "HMAC-SHA2-512";
    reference
      "RFC 6668: SHA-2 Data Integrity Verification for the
                 Secure Shell (SSH) Transport Layer Protocol";
  }

  // groupings

  grouping transport-params-grouping {
    description
      "A reusable grouping for SSH transport parameters.";
    reference
      "RFC 4253: The Secure Shell (SSH) Transport Layer Protocol";
    container host-key {
      description
        "Parameters regarding host key.";
      leaf-list host-key-alg {
        type identityref {
          base public-key-alg-base;
        }
        ordered-by user;
        description
          "Acceptable host key algorithms in order of descending
           preference.  The configured host key algorithms should
           be compatible with the algorithm used by the configured
           private key.  Please see Section 5 of RFC XXXX for
           valid combinations.

           If this leaf-list is not configured (has zero elements)
           the acceptable host key algorithms are implementation-
           defined.";
        reference
          "RFC XXXX: YANG Groupings for SSH Clients and SSH Servers";
      }
    }
    container key-exchange {
      description
        "Parameters regarding key exchange.";
      leaf-list key-exchange-alg {
        type identityref {
          base key-exchange-alg-base;
        }
        ordered-by user;
        description
         "Acceptable key exchange algorithms in order of descending
          preference.

          If this leaf-list is not configured (has zero elements)
          the acceptable key exchange algorithms are implementation
          defined.";
      }
    }
    container encryption {
      description
        "Parameters regarding encryption.";
      leaf-list encryption-alg {
        type identityref {
          base encryption-alg-base;
        }
        ordered-by user;
        description
         "Acceptable encryption algorithms in order of descending
          preference.

          If this leaf-list is not configured (has zero elements)
          the acceptable encryption algorithms are implementation
          defined.";
      }
    }
    container mac {
      description
        "Parameters regarding message authentication code (MAC).";
      leaf-list mac-alg {
        type identityref {
          base mac-alg-base;
        }
        ordered-by user;
        description
          "Acceptable MAC algorithms in order of descending
           preference.

           If this leaf-list is not configured (has zero elements)
           the acceptable MAC algorithms are implementation-
           defined.";
      }
    }

  } // transport-params-grouping

}
<CODE ENDS>
]]></artwork>
          </figure></t>
      </section>
    </section>

    <section title="Security Considerations">
      <t>The YANG modules defined in this document are designed to be accessed
      via YANG based management protocols, such as NETCONF <xref
      target="RFC6241"/> and RESTCONF <xref target="RFC8040"/>. Both of these
      protocols have mandatory-to-implement secure transport layers (e.g.,
      SSH, TLS) with mutual authentication.</t>

      <t>The NETCONF access control model (NACM) <xref target="RFC8341"/>
      provides the means to restrict access for particular users to a
      pre-configured subset of all available protocol operations and
      content.</t>

      <t>Since the modules defined in this document define only groupings,
      these considerations are primarily for the designers of other modules
      that use these groupings.</t>

      <t>There are a number of data nodes defined in the YANG modules that are
      writable/creatable/deletable (i.e., config true, which is the default).
      These data nodes may be considered sensitive or vulnerable in some
      network environments. Write operations (e.g., edit-config) to these data
      nodes without proper protection can have a negative effect on network
      operations. These are the subtrees and data nodes and their
      sensitivity/vulnerability: <list hangIndent="6" style="hanging">
          <t hangText="   /:">The entire data tree defined by all the modules
          defined in this draft are sensitive to write operations. For
          instance, the addition or removal of references to keys,
          certificates, trusted anchors, etc., can dramatically alter the
          implemented security policy. However, no NACM annotations are
          applied as the data SHOULD be editable by users other than a
          designated 'recovery session'.</t>

          <!-- KENT, FIXME -->
        </list></t>

      <t>Some of the readable data nodes in the YANG modules may be considered
      sensitive or vulnerable in some network environments. It is thus
      important to control read access (e.g., via get, get-config, or
      notification) to these data nodes. These are the subtrees and data nodes
      and their sensitivity/vulnerability: <list hangIndent="6"
          style="hanging">
          <t hangText="   /client-auth/password:">This node in the
          'ietf-ssh-client' module is additionally sensitive to read
          operations such that, in normal use cases, it should never be
          returned to a client. The only time this node should be returned is
          to support backup/restore type workflows. However, no NACM
          annotations are applied as the data SHOULD be writable by users
          other than a designated 'recovery session'.</t>

          <!-- KENT, FIXME -->
        </list></t>

      <t>Some of the RPC operations in this YANG module may be considered
      sensitive or vulnerable in some network environments. It is thus
      important to control access to these operations. These are the
      operations and their sensitivity/vulnerability: <list hangIndent="6"
          style="hanging">
          <t hangText="   NONE"/>
        </list></t>
    </section>

    <section title="IANA Considerations">
      <section title="The IETF XML Registry">
        <t>This document registers three URIs in the "ns" subregistry of the
        IETF XML Registry <xref target="RFC3688"/>. Following the format in
        <xref target="RFC3688"/>, the following registrations are
        requested:</t>

        <t><figure>
            <artwork>
   URI: urn:ietf:params:xml:ns:yang:ietf-ssh-client
   Registrant Contact: The NETCONF WG of the IETF.
   XML: N/A, the requested URI is an XML namespace.

   URI: urn:ietf:params:xml:ns:yang:ietf-ssh-server
   Registrant Contact: The NETCONF WG of the IETF.
   XML: N/A, the requested URI is an XML namespace.

   URI: urn:ietf:params:xml:ns:yang:ietf-ssh-common
   Registrant Contact: The NETCONF WG of the IETF.
   XML: N/A, the requested URI is an XML namespace.
</artwork>
          </figure></t>
      </section>

      <section title="The YANG Module Names Registry">
        <t>This document registers three YANG modules in the YANG Module Names
        registry <xref target="RFC6020"/>. Following the format in <xref
        target="RFC6020"/>, the following registrations are requested:</t>

        <t><figure>
            <artwork>
   name:         ietf-ssh-client
   namespace:    urn:ietf:params:xml:ns:yang:ietf-ssh-client
   prefix:       sshc
   reference:    RFC XXXX

   name:         ietf-ssh-server
   namespace:    urn:ietf:params:xml:ns:yang:ietf-ssh-server
   prefix:       sshs
   reference:    RFC XXXX

   name:         ietf-ssh-common
   namespace:    urn:ietf:params:xml:ns:yang:ietf-ssh-common
   prefix:       sshcmn
   reference:    RFC XXXX
</artwork>
          </figure></t>
      </section>
    </section>
  </middle>

  <back>
    <references title="Normative References">
      <?rfc include="reference.RFC.2119.xml"?>

      <?rfc include="reference.RFC.4344.xml"?>

      <?rfc include="reference.RFC.4419.xml"?>

      <?rfc include="reference.RFC.5656.xml"?>

      <?rfc include="reference.RFC.6020.xml"?>

      <?rfc include="reference.RFC.6187.xml"?>

      <?rfc include="reference.RFC.6668.xml"?>

      <?rfc include="reference.RFC.7950.xml"?>

      <?rfc include="reference.RFC.8174.xml"?>

      <?rfc include="reference.RFC.8341.xml"?>

      <?rfc include="reference.I-D.ietf-netconf-trust-anchors"?>

      <?rfc include="reference.I-D.ietf-netconf-keystore"?>

      <?rfc include="reference.I-D.ietf-netconf-crypto-types"?>
    </references>

    <references title="Informative References">
      <!--<reference anchor='FIPS180-4' target="http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf">
          <front>
            <title>Secure Hash Standard (SHS)</title>
            <author fullname='National Institute of Standards and Technology'/>
            <date year='2012' month='March'/>
          </front>
          <seriesInfo name="FIPS PUB" value="180-4"/>
        </reference>-->

      <?rfc include="reference.RFC.3688.xml"?>

      <?rfc include="reference.RFC.4252.xml"?>

      <?rfc include="reference.RFC.4253.xml"?>

      <?rfc include="reference.RFC.4254.xml"?>

      <?rfc include="reference.RFC.6241.xml"?>

      <?rfc include="reference.RFC.6242.xml"?>

      <?rfc include="reference.RFC.7317.xml"?>

      <?rfc include="reference.RFC.8040.xml"?>

      <?rfc include="reference.RFC.8071.xml"?>

      <?rfc include="reference.RFC.8340.xml"?>

      <reference anchor="OPENSSH" target="http://www.openssh.com">
        <front>
          <title>OpenSSH</title>

          <author fullname="The OpenBSD Project"/>

          <date year="2016"/>
        </front>
      </reference>
    </references>

    <section title="Change Log">
      <section title="00 to 01">
        <t><list style="symbols">
            <t>Noted that '0.0.0.0' and '::' might have special meanings.</t>

            <t>Renamed "keychain" to "keystore".</t>
          </list></t>
      </section>

      <section title="01 to 02">
        <t><list style="symbols">
            <t>Removed the groupings 'listening-ssh-client-grouping' and
            'listening-ssh-server-grouping'. Now modules only contain the
            transport-independent groupings.</t>

            <t>Simplified the "client-auth" part in the ietf-ssh-client
            module. It now inlines what it used to point to keystore for.</t>

            <t>Added cipher suites for various algorithms into new
            'ietf-ssh-common' module.</t>
          </list></t>
      </section>

      <section title="02 to 03">
        <t><list style="symbols">
            <t>Removed 'RESTRICTED' enum from 'password' leaf type.</t>

            <t>Added a 'must' statement to container 'server-auth' asserting
            that at least one of the various auth mechanisms must be
            specified.</t>

            <t>Fixed description statement for leaf 'trusted-ca-certs'.</t>
          </list></t>
      </section>

      <section title="03 to 04">
        <t><list style="symbols">
            <t>Change title to "YANG Groupings for SSH Clients and SSH
            Servers"</t>

            <t>Added reference to RFC 6668</t>

            <t>Added RFC 8174 to Requirements Language Section.</t>

            <t>Enhanced description statement for ietf-ssh-server's
            "trusted-ca-certs" leaf.</t>

            <t>Added mandatory true to ietf-ssh-client's "client-auth"
            'choice' statement.</t>

            <t>Changed the YANG prefix for module ietf-ssh-common from
            'sshcom' to 'sshcmn'.</t>

            <t>Removed the compression algorithms as they are not commonly
            configurable in vendors' implementations.</t>

            <t>Updating descriptions in transport-params-grouping and the
            servers's usage of it.</t>

            <t>Now tree diagrams reference ietf-netmod-yang-tree-diagrams</t>

            <t>Updated YANG to use typedefs around leafrefs to common keystore
            paths</t>

            <t>Now inlines key and certificates (no longer a leafref to
            keystore)</t>
          </list></t>
      </section>

      <section title="04 to 05">
        <t><list style="symbols">
            <t>Merged changes from co-author.</t>
          </list></t>
      </section>

      <section title="05 to 06">
        <t><list style="symbols">
            <t>Updated to use trust anchors from trust-anchors draft (was
            keystore draft)</t>

            <t>Now uses new keystore grouping enabling asymmetric key to be
            either locally defined or a reference to the keystore.</t>
          </list></t>
      </section>

      <section title="06 to 07">
        <t><list style="symbols">
            <t>factored the ssh-[client|server]-groupings into more reusable
            groupings.</t>

            <t>added if-feature statements for the new "ssh-host-keys" and
            "x509-certificates" features defined in
            draft-ietf-netconf-trust-anchors.</t>
          </list></t>
      </section>

      <section title="07 to 08">
        <t>
          <list style="symbols">
            <t>Added a number of compatibility matrices to Section 5 (thanks Frank!)</t>
            <t>Clarified that any configured "host-key-alg" values need to be 
               compatible with the configured private key.</t>
          </list>
        </t>
      </section>

      <section title="08 to 09">
        <t>
          <list style="symbols">
            <t>Updated examples to reflect update to groupings defined in the keystore -09 draft.</t>
            <t>Add SSH keepalives features and groupings.</t>
            <t>Prefixed top-level SSH grouping nodes with 'ssh-' and support mashups.</t>
            <t>Updated copyright date, boilerplate template, affiliation, and folding algorithm.</t>
          </list>
        </t>
      </section>
    </section>

    <section numbered="no" title="Acknowledgements">
      <t>The authors would like to thank for following for lively discussions
      on list and in the halls (ordered by last name): Andy Bierman, Martin
      Bjorklund, Benoit Claise, Mehmet Ersue, Balázs Kovács, David Lamparter,
      Alan Luchuk, Ladislav Lhotka, Radek Krejci, Tom Petch, Juergen
      Schoenwaelder, Phil Shafer, Sean Turner, Michal Vaško, and Bert
      Wijnen.</t>
    </section>
  </back>
</rfc>
