--- old/build/openssh/build.sh	Wed Feb 10 16:24:59 2016
+++ new/build/openssh/build.sh	Wed Feb 10 16:24:59 2016
@@ -47,32 +47,37 @@
     "
 # Feature choices
 CONFIGURE_OPTS="
+    --with-audit=solaris
+    --with-kerberos5=$PREFIX/usr
+    --with-pam
+    --with-sandbox=solaris
     --with-solaris-contracts
-    --with-solaris-projects
+    --with-solaris-privs
     --with-tcp-wrappers
-    --with-ssl-engine
-    --with-pam
-    --with-audit=solaris
+    --with-4in6
+    --enable-strip=no
+    --without-rpath
     --disable-lastlog
+    --with-privsep-user=daemon
+    --with-ssl-engine
+    --with-solaris-projects
     "
 
-install_smf() {
-    logmsg "Installing SMF components"
-    logcmd mkdir -p $DESTDIR/lib/svc/manifest/network || \
-        logerr "--- Failed to create manifest directory"
-    logcmd cp $SRCDIR/ssh.xml $DESTDIR/lib/svc/manifest/network/ || \
-        logerr "--- Failed to copy manifest file"
-    logcmd mkdir -p $DESTDIR/lib/svc/method || \
-        logerr "--- Failed to create method directory"
-    logcmd cp $SRCDIR/method-sshd $DESTDIR/lib/svc/method/sshd || \
-        logerr "--- Failed to copy method script"
+CFLAGS+="-DPAM_ENHANCEMENT -DSET_USE_PAM -DPAM_BUGFIX -DDTRACE_SFTP "
+CFLAGS+="-I/usr/include/kerberosv5 -DKRB5_BUILD_FIX -DDISABLE_BANNER "
+CFLAGS+="-DDEPRECATE_SUNSSH_OPT -DOPTION_DEFAULT_VALUE -DSANDBOX_SOLARIS"
+
+auto_reconf() {
+        # This package needs a whack upside the head post-patches!
+        pushd $TMPDIR/$BUILDDIR
+        autoreconf -fi
+        popd
 }
 
-CFLAGS+="-DPAM_ENHANCEMENT -DSET_USE_PAM -DPAM_BUGFIX -DDTRACE_SFTP"
-
 init
 download_source $PROG $PROG $VER
 patch_source
+auto_reconf
 prep_build
 run_autoconf
 build
@@ -90,7 +95,6 @@
 SUMMARY="OpenSSH Server"
 DESC="OpenSSH Secure Shell protocol Server"
 RUN_DEPENDS_IPS="-pkg:/service/network/ssh pkg:/network/openssh@$VER"
-install_smf
 make_package server.mog
 
 clean_up
--- old/build/openssh/client.mog	Wed Feb 10 16:25:00 2016
+++ new/build/openssh/client.mog	Wed Feb 10 16:25:00 2016
@@ -1,6 +1,12 @@
 <transform file path=etc/ssh/moduli -> drop>
 <transform file path=etc/ssh/sshd_config -> drop>
+<transform dir path=lib/svc/manifest/network -> drop>
+<transform file path=lib/svc/manifest/network/ssh.xml -> drop>
+<transform dir path=lib/svc/method -> drop>
+<transform file path=lib/svc/method/sshd -> drop>
 <transform file path=usr/libexec/sftp-server -> drop>
+<transform dir path=usr/lib/dtrace -> drop>
+<transform file path=usr/lib/dtrace/sftp.d -> drop>
 <transform dir path=usr/sbin -> drop>
 <transform file path=usr/sbin/sshd -> drop>
 <transform file path=usr/share/man/man4/moduli.4 -> drop>
--- old/build/openssh/method-sshd	Wed Feb 10 16:25:00 2016
+++ /dev/null	Wed Feb 10 16:17:37 2016
@@ -1,21 +0,0 @@
-#!/bin/sh
-
-# SMF method script for OpenSSH server
-# Copyright 2013 OmniTI Computer Consulting, Inc.  All rights reserved.
-# Use is subject to license terms.
-#
-
-. /lib/svc/share/smf_include.sh
-
-CONFDIR=/etc/ssh
-
-[ -x /usr/sbin/sshd ] || exit $SMF_EXIT_ERR_FATAL
-
-case $1 in
-    "start")
-        /usr/bin/ssh-keygen -A || exit $SMF_EXIT_ERR_FATAL
-        /usr/sbin/sshd
-        ;;
-esac        
-
-exit $SMF_EXIT_OK
--- /dev/null	Wed Feb 10 16:25:00 2016
+++ new/build/openssh/patches/0001-upstream-commit.patch	Wed Feb 10 16:25:00 2016
@@ -0,0 +1,36 @@
+From 8a430bc35d1ee437ce913eefeca1d04d759fc145 Mon Sep 17 00:00:00 2001
+From: "djm@openbsd.org" <djm@openbsd.org>
+Date: Mon, 21 Sep 2015 04:31:00 +0000
+Subject: [PATCH 01/36] upstream commit
+
+fix possible hang on closed output; bz#2469 reported by Tomas
+ Kuthan ok markus@
+
+Upstream-ID: f7afd41810f8540f524284f1be6b970859f94fe3
+---
+ packet.c | 5 +++--
+ 1 file changed, 3 insertions(+), 2 deletions(-)
+
+diff --git a/packet.c b/packet.c
+index 7b5c419..11fe25c 100644
+--- a/packet.c
++++ b/packet.c
+@@ -1,4 +1,4 @@
+-/* $OpenBSD: packet.c,v 1.214 2015/08/20 22:32:42 deraadt Exp $ */
++/* $OpenBSD: packet.c,v 1.215 2015/09/21 04:31:00 djm Exp $ */
+ /*
+  * Author: Tatu Ylonen <ylo@cs.hut.fi>
+  * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
+@@ -2041,7 +2041,8 @@ ssh_packet_write_wait(struct ssh *ssh)
+ 	    NFDBITS), sizeof(fd_mask));
+ 	if (setp == NULL)
+ 		return SSH_ERR_ALLOC_FAIL;
+-	ssh_packet_write_poll(ssh);
++	if ((r = ssh_packet_write_poll(ssh)) != 0)
++		return r;
+ 	while (ssh_packet_have_data_to_write(ssh)) {
+ 		memset(setp, 0, howmany(state->connection_out + 1,
+ 		    NFDBITS) * sizeof(fd_mask));
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:00 2016
+++ new/build/openssh/patches/0002-Support-Illumos-Solaris-fine-grained-privileges.patch	Wed Feb 10 16:25:00 2016
@@ -0,0 +1,588 @@
+From b09b8dcdda058d6f237baf50810f13e5b6aa47bb Mon Sep 17 00:00:00 2001
+From: Damien Miller <djm@mindrot.org>
+Date: Fri, 8 Jan 2016 14:24:56 +1100
+Subject: [PATCH 02/36] Support Illumos/Solaris fine-grained privileges
+
+Includes a pre-auth privsep sandbox and several pledge()
+emulations. bz#2511, patch by Alex Wilson.
+
+ok dtucker@
+---
+ Makefile.in                   |   5 +-
+ configure.ac                  |  38 +++++++++++++-
+ mux.c                         |   4 ++
+ openbsd-compat/port-solaris.c | 114 ++++++++++++++++++++++++++++++++++++++++++
+ openbsd-compat/port-solaris.h |   3 ++
+ platform-pledge.c             |  71 ++++++++++++++++++++++++++
+ platform.h                    |   5 ++
+ sandbox-solaris.c             | 107 +++++++++++++++++++++++++++++++++++++++
+ sftp-server.c                 |   3 ++
+ ssh-agent.c                   |   2 +
+ uidswap.c                     |  18 ++++---
+ 11 files changed, 360 insertions(+), 10 deletions(-)
+ create mode 100644 platform-pledge.c
+ create mode 100644 sandbox-solaris.c
+
+diff --git a/Makefile.in b/Makefile.in
+index 40cc7aa..8494713 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -91,7 +91,8 @@ LIBSSH_OBJS=${LIBOPENSSH_OBJS} \
+ 	sc25519.o ge25519.o fe25519.o ed25519.o verify.o hash.o blocks.o \
+ 	kex.o kexdh.o kexgex.o kexecdh.o kexc25519.o \
+ 	kexdhc.o kexgexc.o kexecdhc.o kexc25519c.o \
+-	kexdhs.o kexgexs.o kexecdhs.o kexc25519s.o
++	kexdhs.o kexgexs.o kexecdhs.o kexc25519s.o \
++	platform-pledge.o
+ 
+ SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \
+ 	sshconnect.o sshconnect1.o sshconnect2.o mux.o \
+@@ -110,7 +111,7 @@ SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \
+ 	sftp-server.o sftp-common.o \
+ 	roaming_common.o roaming_serv.o \
+ 	sandbox-null.o sandbox-rlimit.o sandbox-systrace.o sandbox-darwin.o \
+-	sandbox-seccomp-filter.o sandbox-capsicum.o
++	sandbox-seccomp-filter.o sandbox-capsicum.o sandbox-solaris.o
+ 
+ MANPAGES	= moduli.5.out scp.1.out ssh-add.1.out ssh-agent.1.out ssh-keygen.1.out ssh-keyscan.1.out ssh.1.out sshd.8.out sftp-server.8.out sftp.1.out ssh-keysign.8.out ssh-pkcs11-helper.8.out sshd_config.5.out ssh_config.5.out
+ MANPAGES_IN	= moduli.5 scp.1 ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh-keyscan.1 ssh.1 sshd.8 sftp-server.8 sftp.1 ssh-keysign.8 ssh-pkcs11-helper.8 sshd_config.5 ssh_config.5
+diff --git a/configure.ac b/configure.ac
+index 9b05c30..b06cede 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -469,6 +469,11 @@ AC_CHECK_HEADERS([sys/un.h], [], [], [
+ SIA_MSG="no"
+ SPC_MSG="no"
+ SP_MSG="no"
++SPP_MSG="no"
++
++# Support for Solaris/Illumos privileges (this test is used by both
++# the --with-solaris-privs option and --with-sandbox=solaris).
++SOLARIS_PRIVS="no"
+ 
+ # Check for some target-specific stuff
+ case "$host" in
+@@ -575,6 +580,8 @@ case "$host" in
+ 	LIBS="$LIBS /usr/lib/textreadmode.o"
+ 	AC_DEFINE([HAVE_CYGWIN], [1], [Define if you are on Cygwin])
+ 	AC_DEFINE([USE_PIPES], [1], [Use PIPES instead of a socketpair()])
++	AC_DEFINE([NO_UID_RESTORATION_TEST], [1],
++		[Define to disable UID restoration test])
+ 	AC_DEFINE([DISABLE_SHADOW], [1],
+ 		[Define if you want to disable shadow passwords])
+ 	AC_DEFINE([NO_X11_UNIX_SOCKETS], [1],
+@@ -889,13 +896,18 @@ mips-sony-bsd|mips-sony-newsos4)
+ 	else
+ 		AC_MSG_RESULT([no])
+ 	fi
++	AC_CHECK_FUNC([setppriv],
++		[ AC_CHECK_HEADERS([priv.h], [
++			SOLARIS_PRIVS="yes"
++		])
++	])
+ 	AC_ARG_WITH([solaris-contracts],
+ 		[  --with-solaris-contracts Enable Solaris process contracts (experimental)],
+ 		[
+ 		AC_CHECK_LIB([contract], [ct_tmpl_activate],
+ 			[ AC_DEFINE([USE_SOLARIS_PROCESS_CONTRACTS], [1],
+ 				[Define if you have Solaris process contracts])
+-			  SSHDLIBS="$SSHDLIBS -lcontract"
++			  LIBS="$LIBS -lcontract"
+ 			  SPC_MSG="yes" ], )
+ 		],
+ 	)
+@@ -905,10 +917,27 @@ mips-sony-bsd|mips-sony-newsos4)
+ 		AC_CHECK_LIB([project], [setproject],
+ 			[ AC_DEFINE([USE_SOLARIS_PROJECTS], [1],
+ 				[Define if you have Solaris projects])
+-			SSHDLIBS="$SSHDLIBS -lproject"
++			LIBS="$LIBS -lproject"
+ 			SP_MSG="yes" ], )
+ 		],
+ 	)
++	AC_ARG_WITH([solaris-privs],
++		[  --with-solaris-privs    Enable Solaris/Illumos privileges (experimental)],
++		[
++		AC_MSG_CHECKING([for Solaris/Illumos privilege support])
++		if test "x$SOLARIS_PRIVS" = "xyes" ; then
++			AC_MSG_RESULT([found])
++			AC_DEFINE([NO_UID_RESTORATION_TEST], [1],
++				[Define to disable UID restoration test])
++			AC_DEFINE([USE_SOLARIS_PRIVS], [1],
++				[Define if you have Solaris privileges])
++			SPP_MSG="yes"
++		else
++			AC_MSG_RESULT([not found])
++			AC_MSG_ERROR([*** must have support for Solaris privileges to use --with-solaris-privs])
++		fi
++		],
++	)
+ 	TEST_SHELL=$SHELL	# let configure find us a capable shell
+ 	;;
+ *-*-sunos4*)
+@@ -3147,6 +3176,10 @@ elif test "x$sandbox_arg" = "xrlimit" || \
+ 		AC_MSG_ERROR([rlimit sandbox requires select to work with rlimit])
+ 	SANDBOX_STYLE="rlimit"
+ 	AC_DEFINE([SANDBOX_RLIMIT], [1], [Sandbox using setrlimit(2)])
++elif test "x$sandbox_arg" = "xsolaris" || \
++   ( test -z "$sandbox_arg" && test "x$SOLARIS_PRIVS" = "xyes" ) ; then
++	SANDBOX_STYLE="solaris"
++	AC_DEFINE([SANDBOX_SOLARIS], [1], [Sandbox using Solaris/Illumos privileges])
+ elif test -z "$sandbox_arg" || test "x$sandbox_arg" = "xno" || \
+      test "x$sandbox_arg" = "xnone" || test "x$sandbox_arg" = "xnull" ; then
+ 	SANDBOX_STYLE="none"
+@@ -4933,6 +4966,7 @@ echo "              MD5 password support: $MD5_MSG"
+ echo "                   libedit support: $LIBEDIT_MSG"
+ echo "  Solaris process contract support: $SPC_MSG"
+ echo "           Solaris project support: $SP_MSG"
++echo "         Solaris privilege support: $SPP_MSG"
+ echo "       IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
+ echo "           Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
+ echo "                  BSD Auth support: $BSD_AUTH_MSG"
+diff --git a/mux.c b/mux.c
+index e6136fd..8c2a53a 100644
+--- a/mux.c
++++ b/mux.c
+@@ -1889,6 +1889,8 @@ mux_client_request_session(int fd)
+ 	}
+ 	muxclient_request_id++;
+ 
++	platform_pledge_mux();
++
+ 	signal(SIGHUP, control_client_sighandler);
+ 	signal(SIGINT, control_client_sighandler);
+ 	signal(SIGTERM, control_client_sighandler);
+@@ -1996,6 +1998,8 @@ mux_client_request_stdio_fwd(int fd)
+ 	    mm_send_fd(fd, STDOUT_FILENO) == -1)
+ 		fatal("%s: send fds failed", __func__);
+ 
++	platform_pledge_mux();
++
+ 	debug3("%s: stdio forward request sent", __func__);
+ 
+ 	/* Read their reply */
+diff --git a/openbsd-compat/port-solaris.c b/openbsd-compat/port-solaris.c
+index 25382f1..962cd16 100644
+--- a/openbsd-compat/port-solaris.c
++++ b/openbsd-compat/port-solaris.c
+@@ -227,3 +227,117 @@ solaris_set_default_project(struct passwd *pw)
+ 	}
+ }
+ #endif /* USE_SOLARIS_PROJECTS */
++
++#ifdef USE_SOLARIS_PRIVS
++# ifdef HAVE_PRIV_H
++#  include <priv.h>
++# endif
++
++void
++solaris_drop_privs_pinfo_net_fork_exec(void)
++{
++	priv_set_t *pset = NULL, *npset = NULL;
++
++	/*
++	 * Note: this variant avoids dropping DAC filesystem rights, in case
++	 * the process calling it is running as root and should have the
++	 * ability to read/write/chown any file on the system.
++	 *
++	 * We start with the basic set, then *add* the DAC rights to it while
++	 * taking away other parts of BASIC we don't need. Then we intersect
++	 * this with our existing PERMITTED set. In this way we keep any
++	 * DAC rights we had before, while otherwise reducing ourselves to
++	 * the minimum set of privileges we need to proceed.
++	 *
++	 * This also means we drop any other parts of "root" that we don't
++	 * need (e.g. the ability to kill any process, create new device nodes
++	 * etc etc).
++	 */
++
++	if ((pset = priv_allocset()) == NULL ||
++	    (npset = priv_allocset()) == NULL)
++		fatal("priv_allocset: %s", strerror(errno));
++
++	priv_basicset(npset);
++
++	if (priv_addset(npset, PRIV_FILE_CHOWN) != 0 ||
++	    priv_addset(npset, PRIV_FILE_DAC_READ) != 0 ||
++	    priv_addset(npset, PRIV_FILE_DAC_SEARCH) != 0 ||
++	    priv_addset(npset, PRIV_FILE_DAC_WRITE) != 0 ||
++	    priv_addset(npset, PRIV_FILE_OWNER) != 0)
++		fatal("priv_addset: %s", strerror(errno));
++
++	if (priv_delset(npset, PRIV_FILE_LINK_ANY) != 0 ||
++	    priv_delset(npset, PRIV_NET_ACCESS) != 0 ||
++	    priv_delset(npset, PRIV_PROC_EXEC) != 0 ||
++	    priv_delset(npset, PRIV_PROC_FORK) != 0 ||
++	    priv_delset(npset, PRIV_PROC_INFO) != 0 ||
++	    priv_delset(npset, PRIV_PROC_SESSION) != 0)
++		fatal("priv_delset: %s", strerror(errno));
++
++	if (getppriv(PRIV_PERMITTED, pset) != 0)
++		fatal("getppriv: %s", strerror(errno));
++
++	priv_intersect(pset, npset);
++
++	if (setppriv(PRIV_SET, PRIV_PERMITTED, npset) != 0 ||
++	    setppriv(PRIV_SET, PRIV_LIMIT, npset) != 0 ||
++	    setppriv(PRIV_SET, PRIV_INHERITABLE, npset) != 0)
++		fatal("setppriv: %s", strerror(errno));
++
++	priv_freeset(pset);
++	priv_freeset(npset);
++}
++
++void
++solaris_drop_privs_root_pinfo_net(void)
++{
++	priv_set_t *pset = NULL;
++
++	if ((pset = priv_allocset()) == NULL)
++		fatal("priv_allocset: %s", strerror(errno));
++
++	/* Start with "basic" and drop everything we don't need. */
++	priv_basicset(pset);
++
++	if (priv_delset(pset, PRIV_FILE_LINK_ANY) != 0 ||
++	    priv_delset(pset, PRIV_NET_ACCESS) != 0 ||
++	    priv_delset(pset, PRIV_PROC_INFO) != 0 ||
++	    priv_delset(pset, PRIV_PROC_SESSION) != 0)
++		fatal("priv_delset: %s", strerror(errno));
++
++	if (setppriv(PRIV_SET, PRIV_PERMITTED, pset) != 0 ||
++	    setppriv(PRIV_SET, PRIV_LIMIT, pset) != 0 ||
++	    setppriv(PRIV_SET, PRIV_INHERITABLE, pset) != 0)
++		fatal("setppriv: %s", strerror(errno));
++
++	priv_freeset(pset);
++}
++
++void
++solaris_drop_privs_root_pinfo_net_exec(void)
++{
++	priv_set_t *pset = NULL;
++
++	if ((pset = priv_allocset()) == NULL)
++		fatal("priv_allocset: %s", strerror(errno));
++
++	/* Start with "basic" and drop everything we don't need. */
++	priv_basicset(pset);
++
++	if (priv_delset(pset, PRIV_FILE_LINK_ANY) != 0 ||
++	    priv_delset(pset, PRIV_NET_ACCESS) != 0 ||
++	    priv_delset(pset, PRIV_PROC_EXEC) != 0 ||
++	    priv_delset(pset, PRIV_PROC_INFO) != 0 ||
++	    priv_delset(pset, PRIV_PROC_SESSION) != 0)
++		fatal("priv_delset: %s", strerror(errno));
++
++	if (setppriv(PRIV_SET, PRIV_PERMITTED, pset) != 0 ||
++	    setppriv(PRIV_SET, PRIV_LIMIT, pset) != 0 ||
++	    setppriv(PRIV_SET, PRIV_INHERITABLE, pset) != 0)
++		fatal("setppriv: %s", strerror(errno));
++
++	priv_freeset(pset);
++}
++
++#endif
+diff --git a/openbsd-compat/port-solaris.h b/openbsd-compat/port-solaris.h
+index cd442e7..b077e18 100644
+--- a/openbsd-compat/port-solaris.h
++++ b/openbsd-compat/port-solaris.h
+@@ -26,5 +26,8 @@ void solaris_contract_pre_fork(void);
+ void solaris_contract_post_fork_child(void);
+ void solaris_contract_post_fork_parent(pid_t pid);
+ void solaris_set_default_project(struct passwd *);
++void solaris_drop_privs_pinfo_net_fork_exec(void);
++void solaris_drop_privs_root_pinfo_net(void);
++void solaris_drop_privs_root_pinfo_net_exec(void);
+ 
+ #endif
+diff --git a/platform-pledge.c b/platform-pledge.c
+new file mode 100644
+index 0000000..4a6ec15
+--- /dev/null
++++ b/platform-pledge.c
+@@ -0,0 +1,71 @@
++/*
++ * Copyright (c) 2015 Joyent, Inc
++ * Author: Alex Wilson <alex.wilson@joyent.com>
++ *
++ * Permission to use, copy, modify, and distribute this software for any
++ * purpose with or without fee is hereby granted, provided that the above
++ * copyright notice and this permission notice appear in all copies.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
++ */
++
++#include "includes.h"
++
++#include <sys/types.h>
++
++#include <stdarg.h>
++#include <unistd.h>
++
++#include "platform.h"
++
++#include "openbsd-compat/openbsd-compat.h"
++
++/*
++ * Drop any fine-grained privileges that are not needed for post-startup
++ * operation of ssh-agent
++ *
++ * Should be as close as possible to pledge("stdio cpath unix id proc exec", ...)
++ */
++void
++platform_pledge_agent(void)
++{
++#ifdef USE_SOLARIS_PRIVS
++	/*
++	 * Note: Solaris priv dropping is closer to tame() than pledge(), but
++	 * we will use what we have.
++	 */
++	solaris_drop_privs_root_pinfo_net();
++#endif
++}
++
++/*
++ * Drop any fine-grained privileges that are not needed for post-startup
++ * operation of sftp-server
++ */
++void
++platform_pledge_sftp_server(void)
++{
++#ifdef USE_SOLARIS_PRIVS
++	solaris_drop_privs_pinfo_net_fork_exec();
++#endif
++}
++
++/*
++ * Drop any fine-grained privileges that are not needed for the post-startup
++ * operation of the SSH client mux
++ *
++ * Should be as close as possible to pledge("stdio proc tty", ...)
++ */
++void
++platform_pledge_mux(void)
++{
++#ifdef USE_SOLARIS_PRIVS
++	solaris_drop_privs_root_pinfo_net_exec();
++#endif
++}
+diff --git a/platform.h b/platform.h
+index 1c7a45d..e687c99 100644
+--- a/platform.h
++++ b/platform.h
+@@ -31,3 +31,8 @@ void platform_setusercontext_post_groups(struct passwd *);
+ char *platform_get_krb5_client(const char *);
+ char *platform_krb5_get_principal_name(const char *);
+ int platform_sys_dir_uid(uid_t);
++
++/* in platform-pledge.c */
++void platform_pledge_agent(void);
++void platform_pledge_sftp_server(void);
++void platform_pledge_mux(void);
+diff --git a/sandbox-solaris.c b/sandbox-solaris.c
+new file mode 100644
+index 0000000..98714e1
+--- /dev/null
++++ b/sandbox-solaris.c
+@@ -0,0 +1,107 @@
++/*
++ * Copyright (c) 2015 Joyent, Inc
++ * Author: Alex Wilson <alex.wilson@joyent.com>
++ *
++ * Permission to use, copy, modify, and distribute this software for any
++ * purpose with or without fee is hereby granted, provided that the above
++ * copyright notice and this permission notice appear in all copies.
++ *
++ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
++ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
++ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
++ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
++ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
++ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
++ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
++ */
++
++#include "includes.h"
++
++#ifdef SANDBOX_SOLARIS
++#ifndef USE_SOLARIS_PRIVS
++# error "--with-solaris-privs must be used with the Solaris sandbox"
++#endif
++
++#include <sys/types.h>
++
++#include <errno.h>
++#include <stdarg.h>
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <unistd.h>
++#ifdef HAVE_PRIV_H
++# include <priv.h>
++#endif
++
++#include "log.h"
++#include "ssh-sandbox.h"
++#include "xmalloc.h"
++
++struct ssh_sandbox {
++	priv_set_t *pset;
++};
++
++struct ssh_sandbox *
++ssh_sandbox_init(struct monitor *monitor)
++{
++	struct ssh_sandbox *box = NULL;
++
++	box = xcalloc(1, sizeof(*box));
++	box->pset = priv_allocset();
++
++	if (box->pset == NULL) {
++		free(box);
++		return NULL;
++	}
++
++	/* Start with "basic" and drop everything we don't need. */
++	priv_basicset(box->pset);
++
++	/* Drop everything except the ability to use already-opened files */
++	if (priv_delset(box->pset, PRIV_FILE_LINK_ANY) != 0 ||
++	    priv_delset(box->pset, PRIV_NET_ACCESS) != 0 ||
++	    priv_delset(box->pset, PRIV_PROC_EXEC) != 0 ||
++	    priv_delset(box->pset, PRIV_PROC_FORK) != 0 ||
++	    priv_delset(box->pset, PRIV_PROC_INFO) != 0 ||
++	    priv_delset(box->pset, PRIV_PROC_SESSION) != 0) {
++		free(box);
++		return NULL;
++	}
++
++	/* These may not be available on older Solaris-es */
++# if defined(PRIV_FILE_READ) && defined(PRIV_FILE_WRITE)
++	if (priv_delset(box->pset, PRIV_FILE_READ) != 0 ||
++	    priv_delset(box->pset, PRIV_FILE_WRITE) != 0) {
++		free(box);
++		return NULL;
++	}
++# endif
++
++	return box;
++}
++
++void
++ssh_sandbox_child(struct ssh_sandbox *box)
++{
++	if (setppriv(PRIV_SET, PRIV_PERMITTED, box->pset) != 0 ||
++	    setppriv(PRIV_SET, PRIV_LIMIT, box->pset) != 0 ||
++	    setppriv(PRIV_SET, PRIV_INHERITABLE, box->pset) != 0)
++		fatal("setppriv: %s", strerror(errno));
++}
++
++void
++ssh_sandbox_parent_finish(struct ssh_sandbox *box)
++{
++	priv_freeset(box->pset);
++	box->pset = NULL;
++	free(box);
++}
++
++void
++ssh_sandbox_parent_preauth(struct ssh_sandbox *box, pid_t child_pid)
++{
++	/* Nothing to do here */
++}
++
++#endif /* SANDBOX_SOLARIS */
+diff --git a/sftp-server.c b/sftp-server.c
+index eac11d7..3877c03 100644
+--- a/sftp-server.c
++++ b/sftp-server.c
+@@ -1598,6 +1598,9 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
+ 		fatal("unable to make the process undumpable");
+ #endif /* defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE) */
+ 
++	/* Drop any fine-grained privileges we don't need */
++	platform_pledge_sftp_server();
++
+ 	if ((cp = getenv("SSH_CONNECTION")) != NULL) {
+ 		client_addr = xstrdup(cp);
+ 		if ((cp = strchr(client_addr, ' ')) == NULL) {
+diff --git a/ssh-agent.c b/ssh-agent.c
+index a335ea3..6c2f6d5 100644
+--- a/ssh-agent.c
++++ b/ssh-agent.c
+@@ -1402,6 +1402,8 @@ skip:
+ 	signal(SIGTERM, cleanup_handler);
+ 	nalloc = 0;
+ 
++	platform_pledge_agent();
++
+ 	while (1) {
+ 		prepare_select(&readsetp, &writesetp, &max_fd, &nalloc, &tvp);
+ 		result = select(max_fd + 1, readsetp, writesetp, NULL, tvp);
+diff --git a/uidswap.c b/uidswap.c
+index 0702e1d..8bf6b24 100644
+--- a/uidswap.c
++++ b/uidswap.c
+@@ -134,7 +134,7 @@ temporarily_use_uid(struct passwd *pw)
+ void
+ permanently_drop_suid(uid_t uid)
+ {
+-#ifndef HAVE_CYGWIN
++#ifndef NO_UID_RESTORATION_TEST
+ 	uid_t old_uid = getuid();
+ #endif
+ 
+@@ -142,8 +142,14 @@ permanently_drop_suid(uid_t uid)
+ 	if (setresuid(uid, uid, uid) < 0)
+ 		fatal("setresuid %u: %.100s", (u_int)uid, strerror(errno));
+ 
+-#ifndef HAVE_CYGWIN
+-	/* Try restoration of UID if changed (test clearing of saved uid) */
++#ifndef NO_UID_RESTORATION_TEST
++	/*
++	 * Try restoration of UID if changed (test clearing of saved uid).
++	 *
++	 * Note that we don't do this on Cygwin, or on Solaris-based platforms
++	 * where fine-grained privileges are available (the user might be
++	 * deliberately allowed the right to setuid back to root).
++	 */
+ 	if (old_uid != uid &&
+ 	    (setuid(old_uid) != -1 || seteuid(old_uid) != -1))
+ 		fatal("%s: was able to restore old [e]uid", __func__);
+@@ -199,7 +205,7 @@ restore_uid(void)
+ void
+ permanently_set_uid(struct passwd *pw)
+ {
+-#ifndef HAVE_CYGWIN
++#ifndef NO_UID_RESTORATION_TEST
+ 	uid_t old_uid = getuid();
+ 	gid_t old_gid = getgid();
+ #endif
+@@ -227,7 +233,7 @@ permanently_set_uid(struct passwd *pw)
+ 	if (setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) < 0)
+ 		fatal("setresuid %u: %.100s", (u_int)pw->pw_uid, strerror(errno));
+ 
+-#ifndef HAVE_CYGWIN
++#ifndef NO_UID_RESTORATION_TEST
+ 	/* Try restoration of GID if changed (test clearing of saved gid) */
+ 	if (old_gid != pw->pw_gid && pw->pw_uid != 0 &&
+ 	    (setgid(old_gid) != -1 || setegid(old_gid) != -1))
+@@ -241,7 +247,7 @@ permanently_set_uid(struct passwd *pw)
+ 		    (u_int)pw->pw_gid);
+ 	}
+ 
+-#ifndef HAVE_CYGWIN
++#ifndef NO_UID_RESTORATION_TEST
+ 	/* Try restoration of UID if changed (test clearing of saved uid) */
+ 	if (old_uid != pw->pw_uid &&
+ 	    (setuid(old_uid) != -1 || seteuid(old_uid) != -1))
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:00 2016
+++ new/build/openssh/patches/0003-Skip-config-check.patch	Wed Feb 10 16:25:00 2016
@@ -0,0 +1,41 @@
+From eadecda3468eb0abe55c94d0f8193cefa9f6b1f9 Mon Sep 17 00:00:00 2001
+From: oracle <solaris@oracle.com>
+Date: Mon, 3 Aug 2015 14:31:53 -0700
+Subject: [PATCH 03/36] Skip config check
+
+#
+# This change is to remove some misleading error messages when running
+# "gmake install". OpenSSH mixes the building and running together. Some
+# system setup checking for running the program needs to be removed, because
+# they are not suitable in a build system.  This is for Solaris only, so we
+# will not contribute back this change to the upstream community.
+#
+---
+ Makefile.in | 11 ++++++++++-
+ 1 file changed, 10 insertions(+), 1 deletion(-)
+
+diff --git a/Makefile.in b/Makefile.in
+index 8494713..bc4660f 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -292,7 +292,16 @@ install-nokeys: $(CONFIGFILES) $(MANPAGES) $(TARGETS) install-files install-sysc
+ install-nosysconf: $(CONFIGFILES) $(MANPAGES) $(TARGETS) install-files
+ 
+ check-config:
+-	-$(DESTDIR)$(sbindir)/sshd -t -f $(DESTDIR)$(sysconfdir)/sshd_config
++# On Solaris, to workaround OpenSSH's unlucky mixing of 'building ssh' and
++# 'running ssh', on build machine the following requisites shouldn't be
++# enforced:
++#     1) existence of privsep user sshd
++#     2) existence of privsep directory /var/empty
++#     3) read permissions for /etc/ssh/ssh_host_[rsa,dsa]_key 
++#
++#	-$(DESTDIR)$(sbindir)/sshd -t -f $(DESTDIR)$(sysconfdir)/sshd_config
++#
++	@echo 'Oracle Solaris: skipping check-config'
+ 
+ install-files:
+ 	$(srcdir)/mkinstalldirs $(DESTDIR)$(bindir)
+-- 
+2.5.4 (Apple Git-61)
+
--- old/build/openssh/patches/0002-PAM-Support.patch	Wed Feb 10 16:25:00 2016
+++ /dev/null	Wed Feb 10 16:25:00 2016
@@ -1,54 +0,0 @@
-From 26f612877a2a9db59657a74d178079f92f01eb97 Mon Sep 17 00:00:00 2001
-From: oracle <solaris@oracle.com>
-Date: Mon, 3 Aug 2015 14:34:19 -0700
-Subject: [PATCH 02/30] PAM Support
-
-#
-# To comply to the Solaris PAM policy, the UsePAM option is changed to be
-# always on and not configurable on Solaris.  This is for Solaris only, so we
-# will not contribute the changes to the upstream community.
-#
-
-*** orig/servconf.c	Mon Dec  5 17:23:03 2011
----
- servconf.c | 14 ++++++++++++++
- 1 file changed, 14 insertions(+)
-
-diff --git a/servconf.c b/servconf.c
-index 6c7a91e..5e8ed97 100644
---- a/servconf.c
-+++ b/servconf.c
-@@ -185,7 +185,12 @@ fill_default_server_options(ServerOptions *options)
- 
- 	/* Portable-specific options */
- 	if (options->use_pam == -1)
-+#ifdef SET_USE_PAM
-+		/* use_pam should be always set to 1 on Solaris */
-+		options->use_pam = 1;
-+#else
- 		options->use_pam = 0;
-+#endif
- 
- 	/* Standard Options */
- 	if (options->protocol == SSH_PROTO_UNKNOWN)
-@@ -997,8 +1002,17 @@ process_server_config_line(ServerOptions *options, char *line,
- 	switch (opcode) {
- 	/* Portable-specific options */
- 	case sUsePAM:
-+#ifdef SET_USE_PAM
-+		/* UsePAM is always on and not configurable on Solaris */
-+		logit("%s line %d: ignoring UsePAM option value."
-+		    " This option is always on.", filename, linenum);
-+		while (arg)
-+			arg = strdelim(&cp);
-+		break; 
-+#else
- 		intptr = &options->use_pam;
- 		goto parse_flag;
-+#endif
- 
- 	/* Standard Options */
- 	case sBadOption:
--- 
-2.3.2 (Apple Git-55)
-
--- /dev/null	Wed Feb 10 16:25:00 2016
+++ new/build/openssh/patches/0004-PAM-Support.patch	Wed Feb 10 16:25:00 2016
@@ -0,0 +1,54 @@
+From c57262f2123c44f2e306df153d6a3be1558ba228 Mon Sep 17 00:00:00 2001
+From: oracle <solaris@oracle.com>
+Date: Mon, 3 Aug 2015 14:34:19 -0700
+Subject: [PATCH 04/36] PAM Support
+
+#
+# To comply to the Solaris PAM policy, the UsePAM option is changed to be
+# always on and not configurable on Solaris.  This is for Solaris only, so we
+# will not contribute the changes to the upstream community.
+#
+
+*** orig/servconf.c	Mon Dec  5 17:23:03 2011
+---
+ servconf.c | 14 ++++++++++++++
+ 1 file changed, 14 insertions(+)
+
+diff --git a/servconf.c b/servconf.c
+index 6c7a91e..5e8ed97 100644
+--- a/servconf.c
++++ b/servconf.c
+@@ -185,7 +185,12 @@ fill_default_server_options(ServerOptions *options)
+ 
+ 	/* Portable-specific options */
+ 	if (options->use_pam == -1)
++#ifdef SET_USE_PAM
++		/* use_pam should be always set to 1 on Solaris */
++		options->use_pam = 1;
++#else
+ 		options->use_pam = 0;
++#endif
+ 
+ 	/* Standard Options */
+ 	if (options->protocol == SSH_PROTO_UNKNOWN)
+@@ -997,8 +1002,17 @@ process_server_config_line(ServerOptions *options, char *line,
+ 	switch (opcode) {
+ 	/* Portable-specific options */
+ 	case sUsePAM:
++#ifdef SET_USE_PAM
++		/* UsePAM is always on and not configurable on Solaris */
++		logit("%s line %d: ignoring UsePAM option value."
++		    " This option is always on.", filename, linenum);
++		while (arg)
++			arg = strdelim(&cp);
++		break; 
++#else
+ 		intptr = &options->use_pam;
+ 		goto parse_flag;
++#endif
+ 
+ 	/* Standard Options */
+ 	case sBadOption:
+-- 
+2.5.4 (Apple Git-61)
+
--- old/build/openssh/patches/0003-lastlogin.patch	Wed Feb 10 16:25:00 2016
+++ /dev/null	Wed Feb 10 16:25:00 2016
@@ -1,69 +0,0 @@
-From f0ec680c71b9c2f0c2d729d58231dca27593a5b4 Mon Sep 17 00:00:00 2001
-From: oracle <solaris@oracle.com>
-Date: Mon, 3 Aug 2015 14:34:41 -0700
-Subject: [PATCH 03/30] lastlogin
-
-# The man page change here is Solaris-specific and thus is not being
-# contributed back to the upstream community.  The servconf.c change
-# was developed in-house and has been submitted upstream to OpenSSH for
-# their consideration:
-# https://bugzilla.mindrot.org/show_bug.cgi?id=2278
-#
-# OpenSSH normally updates lastlog when users login and reads lastlog to
-# determine the last login time of the user however on Solaris the
-# pam_unix_session(5) module handles both of these tasks so we compile
-# OpenSSH with --disable-lastlog to disable all lastlog references.
-# This means the sshd_config option of PrintLastLog is now ignored and
-# can't be changed so we update sshd's configuration parsing to flag
-# this as unsupported and update the man page here.
-#
-*** old/servconf.c Wed Sep 17 02:54:26 2014
----
- servconf.c    | 4 ++++
- sshd_config.5 | 7 ++++---
- 2 files changed, 8 insertions(+), 3 deletions(-)
-
-diff --git a/servconf.c b/servconf.c
-index 5e8ed97..4ec6b57 100644
---- a/servconf.c
-+++ b/servconf.c
-@@ -504,7 +504,11 @@ static struct {
- 	{ "listenaddress", sListenAddress, SSHCFG_GLOBAL },
- 	{ "addressfamily", sAddressFamily, SSHCFG_GLOBAL },
- 	{ "printmotd", sPrintMotd, SSHCFG_GLOBAL },
-+#ifdef DISABLE_LASTLOG
-+	{ "printlastlog", sUnsupported, SSHCFG_GLOBAL },
-+#else
- 	{ "printlastlog", sPrintLastLog, SSHCFG_GLOBAL },
-+#endif
- 	{ "ignorerhosts", sIgnoreRhosts, SSHCFG_GLOBAL },
- 	{ "ignoreuserknownhosts", sIgnoreUserKnownHosts, SSHCFG_GLOBAL },
- 	{ "x11forwarding", sX11Forwarding, SSHCFG_ALL },
-diff --git a/sshd_config.5 b/sshd_config.5
-index b18d340..476f71c 100644
---- a/sshd_config.5
-+++ b/sshd_config.5
-@@ -1300,8 +1300,8 @@ Specifies whether
- .Xr sshd 8
- should print the date and time of the last user login when a user logs
- in interactively.
--The default is
--.Dq yes .
-+On Solaris this option is always ignored since pam_unix_session(5)
-+reports the last login time.
- .It Cm PrintMotd
- Specifies whether
- .Xr sshd 8
-@@ -1721,7 +1721,8 @@ This file should be writable by root only, but it is recommended
- (though not necessary) that it be world-readable.
- .El
- .Sh SEE ALSO
--.Xr sshd 8
-+.Xr sshd 8 ,
-+.Xr pam_unix_session 5
- .Sh AUTHORS
- OpenSSH is a derivative of the original and free
- ssh 1.2.12 release by Tatu Ylonen.
--- 
-2.3.2 (Apple Git-55)
-
--- /dev/null	Wed Feb 10 16:25:00 2016
+++ new/build/openssh/patches/0005-lastlogin.patch	Wed Feb 10 16:25:00 2016
@@ -0,0 +1,69 @@
+From 1bcd61d5d1b9cec96dbbe7254758cb97e60779d0 Mon Sep 17 00:00:00 2001
+From: oracle <solaris@oracle.com>
+Date: Mon, 3 Aug 2015 14:34:41 -0700
+Subject: [PATCH 05/36] lastlogin
+
+# The man page change here is Solaris-specific and thus is not being
+# contributed back to the upstream community.  The servconf.c change
+# was developed in-house and has been submitted upstream to OpenSSH for
+# their consideration:
+# https://bugzilla.mindrot.org/show_bug.cgi?id=2278
+#
+# OpenSSH normally updates lastlog when users login and reads lastlog to
+# determine the last login time of the user however on Solaris the
+# pam_unix_session(5) module handles both of these tasks so we compile
+# OpenSSH with --disable-lastlog to disable all lastlog references.
+# This means the sshd_config option of PrintLastLog is now ignored and
+# can't be changed so we update sshd's configuration parsing to flag
+# this as unsupported and update the man page here.
+#
+*** old/servconf.c Wed Sep 17 02:54:26 2014
+---
+ servconf.c    | 4 ++++
+ sshd_config.5 | 7 ++++---
+ 2 files changed, 8 insertions(+), 3 deletions(-)
+
+diff --git a/servconf.c b/servconf.c
+index 5e8ed97..4ec6b57 100644
+--- a/servconf.c
++++ b/servconf.c
+@@ -504,7 +504,11 @@ static struct {
+ 	{ "listenaddress", sListenAddress, SSHCFG_GLOBAL },
+ 	{ "addressfamily", sAddressFamily, SSHCFG_GLOBAL },
+ 	{ "printmotd", sPrintMotd, SSHCFG_GLOBAL },
++#ifdef DISABLE_LASTLOG
++	{ "printlastlog", sUnsupported, SSHCFG_GLOBAL },
++#else
+ 	{ "printlastlog", sPrintLastLog, SSHCFG_GLOBAL },
++#endif
+ 	{ "ignorerhosts", sIgnoreRhosts, SSHCFG_GLOBAL },
+ 	{ "ignoreuserknownhosts", sIgnoreUserKnownHosts, SSHCFG_GLOBAL },
+ 	{ "x11forwarding", sX11Forwarding, SSHCFG_ALL },
+diff --git a/sshd_config.5 b/sshd_config.5
+index b18d340..476f71c 100644
+--- a/sshd_config.5
++++ b/sshd_config.5
+@@ -1300,8 +1300,8 @@ Specifies whether
+ .Xr sshd 8
+ should print the date and time of the last user login when a user logs
+ in interactively.
+-The default is
+-.Dq yes .
++On Solaris this option is always ignored since pam_unix_session(5)
++reports the last login time.
+ .It Cm PrintMotd
+ Specifies whether
+ .Xr sshd 8
+@@ -1721,7 +1721,8 @@ This file should be writable by root only, but it is recommended
+ (though not necessary) that it be world-readable.
+ .El
+ .Sh SEE ALSO
+-.Xr sshd 8
++.Xr sshd 8 ,
++.Xr pam_unix_session 5
+ .Sh AUTHORS
+ OpenSSH is a derivative of the original and free
+ ssh 1.2.12 release by Tatu Ylonen.
+-- 
+2.5.4 (Apple Git-61)
+
--- old/build/openssh/patches/0004-Reorganise-man-pages-into-Illumos-numbering-adjust-t.patch	Wed Feb 10 16:25:00 2016
+++ /dev/null	Wed Feb 10 16:25:00 2016
@@ -1,9905 +0,0 @@
-From 0b784f8f36fc30f8722e784777fe012062beb0d3 Mon Sep 17 00:00:00 2001
-From: oracle <solaris@oracle.com>
-Date: Mon, 3 Aug 2015 14:34:55 -0700
-Subject: [PATCH 04/30] Reorganise man pages into Illumos numbering, adjust
- text
-
----
- Makefile.in          |   22 +-
- moduli.4             |  127 ++++
- moduli.5             |  127 ----
- sftp-server.1m       |  170 +++++
- sftp-server.8        |  170 -----
- ssh-keysign.1m       |   93 +++
- ssh-keysign.8        |   93 ---
- ssh-pkcs11-helper.1m |   43 ++
- ssh-pkcs11-helper.8  |   43 --
- ssh_config.4         | 1726 +++++++++++++++++++++++++++++++++++++++++++++++++
- ssh_config.5         | 1726 -------------------------------------------------
- sshd.1m              |  971 ++++++++++++++++++++++++++++
- sshd.8               |  971 ----------------------------
- sshd_config.4        | 1736 ++++++++++++++++++++++++++++++++++++++++++++++++++
- sshd_config.5        | 1736 --------------------------------------------------
- 15 files changed, 4877 insertions(+), 4877 deletions(-)
- create mode 100644 moduli.4
- delete mode 100644 moduli.5
- create mode 100644 sftp-server.1m
- delete mode 100644 sftp-server.8
- create mode 100644 ssh-keysign.1m
- delete mode 100644 ssh-keysign.8
- create mode 100644 ssh-pkcs11-helper.1m
- delete mode 100644 ssh-pkcs11-helper.8
- create mode 100644 ssh_config.4
- delete mode 100644 ssh_config.5
- create mode 100644 sshd.1m
- delete mode 100644 sshd.8
- create mode 100644 sshd_config.4
- delete mode 100644 sshd_config.5
-
-diff --git a/Makefile.in b/Makefile.in
-index 8e52bca..0dd46b1 100644
---- a/Makefile.in
-+++ b/Makefile.in
-@@ -112,8 +112,8 @@ SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \
- 	sandbox-null.o sandbox-rlimit.o sandbox-systrace.o sandbox-darwin.o \
- 	sandbox-seccomp-filter.o sandbox-capsicum.o
- 
--MANPAGES	= moduli.5.out scp.1.out ssh-add.1.out ssh-agent.1.out ssh-keygen.1.out ssh-keyscan.1.out ssh.1.out sshd.8.out sftp-server.8.out sftp.1.out ssh-keysign.8.out ssh-pkcs11-helper.8.out sshd_config.5.out ssh_config.5.out
--MANPAGES_IN	= moduli.5 scp.1 ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh-keyscan.1 ssh.1 sshd.8 sftp-server.8 sftp.1 ssh-keysign.8 ssh-pkcs11-helper.8 sshd_config.5 ssh_config.5
-+MANPAGES	= moduli.4.out scp.1.out ssh-add.1.out ssh-agent.1.out ssh-keygen.1.out ssh-keyscan.1.out ssh.1.out sshd.1m.out sftp-server.1m.out sftp.1.out ssh-keysign.1m.out ssh-pkcs11-helper.1m.out sshd_config.4.out ssh_config.4.out
-+MANPAGES_IN	= moduli.4 scp.1 ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh-keyscan.1 ssh.1 sshd.1m sftp-server.1m sftp.1 ssh-keysign.1m ssh-pkcs11-helper.1m sshd_config.4 ssh_config.4
- MANTYPE		= @MANTYPE@
- 
- CONFIGFILES=sshd_config.out ssh_config.out moduli.out
-@@ -307,8 +307,8 @@ install-files:
- 	$(srcdir)/mkinstalldirs $(DESTDIR)$(sbindir)
- 	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)
- 	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/$(mansubdir)1
--	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/$(mansubdir)5
--	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/$(mansubdir)8
-+	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/$(mansubdir)4
-+	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/$(mansubdir)1m
- 	$(srcdir)/mkinstalldirs $(DESTDIR)$(libexecdir)
- 	(umask 022 ; $(srcdir)/mkinstalldirs $(DESTDIR)$(PRIVSEP_PATH))
- 	$(INSTALL) -m 0755 $(STRIP_OPT) ssh$(EXEEXT) $(DESTDIR)$(bindir)/ssh$(EXEEXT)
-@@ -328,14 +328,14 @@ install-files:
- 	$(INSTALL) -m 644 ssh-agent.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-agent.1
- 	$(INSTALL) -m 644 ssh-keygen.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-keygen.1
- 	$(INSTALL) -m 644 ssh-keyscan.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-keyscan.1
--	$(INSTALL) -m 644 moduli.5.out $(DESTDIR)$(mandir)/$(mansubdir)5/moduli.5
--	$(INSTALL) -m 644 sshd_config.5.out $(DESTDIR)$(mandir)/$(mansubdir)5/sshd_config.5
--	$(INSTALL) -m 644 ssh_config.5.out $(DESTDIR)$(mandir)/$(mansubdir)5/ssh_config.5
--	$(INSTALL) -m 644 sshd.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/sshd.8
-+	$(INSTALL) -m 644 moduli.4.out $(DESTDIR)$(mandir)/$(mansubdir)4/moduli.4
-+	$(INSTALL) -m 644 sshd_config.4.out $(DESTDIR)$(mandir)/$(mansubdir)4/sshd_config.4
-+	$(INSTALL) -m 644 ssh_config.4.out $(DESTDIR)$(mandir)/$(mansubdir)4/ssh_config.4
-+	$(INSTALL) -m 644 sshd.1m.out $(DESTDIR)$(mandir)/$(mansubdir)1m/sshd.1m
- 	$(INSTALL) -m 644 sftp.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/sftp.1
--	$(INSTALL) -m 644 sftp-server.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/sftp-server.8
--	$(INSTALL) -m 644 ssh-keysign.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/ssh-keysign.8
--	$(INSTALL) -m 644 ssh-pkcs11-helper.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/ssh-pkcs11-helper.8
-+	$(INSTALL) -m 644 sftp-server.1m.out $(DESTDIR)$(mandir)/$(mansubdir)1m/sftp-server.1m
-+	$(INSTALL) -m 644 ssh-keysign.1m.out $(DESTDIR)$(mandir)/$(mansubdir)1m/ssh-keysign.1m
-+	$(INSTALL) -m 644 ssh-pkcs11-helper.1m.out $(DESTDIR)$(mandir)/$(mansubdir)1m/ssh-pkcs11-helper.1m
- 	-rm -f $(DESTDIR)$(bindir)/slogin
- 	ln -s ./ssh$(EXEEXT) $(DESTDIR)$(bindir)/slogin
- 	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/slogin.1
-diff --git a/moduli.4 b/moduli.4
-new file mode 100644
-index 0000000..f87556b
---- /dev/null
-+++ b/moduli.4
-@@ -0,0 +1,127 @@
-+.\"	$OpenBSD: moduli.5,v 1.17 2012/09/26 17:34:38 jmc Exp $
-+.\"
-+.\" Copyright (c) 2008 Damien Miller <djm@mindrot.org>
-+.\"
-+.\" Permission to use, copy, modify, and distribute this software for any
-+.\" purpose with or without fee is hereby granted, provided that the above
-+.\" copyright notice and this permission notice appear in all copies.
-+.\"
-+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-+.Dd $Mdocdate: September 26 2012 $
-+.Dt MODULI 4
-+.Os
-+.Sh NAME
-+.Nm moduli
-+.Nd Diffie-Hellman moduli
-+.Sh DESCRIPTION
-+The
-+.Pa /etc/moduli
-+file contains prime numbers and generators for use by
-+.Xr sshd 1M
-+in the Diffie-Hellman Group Exchange key exchange method.
-+.Pp
-+New moduli may be generated with
-+.Xr ssh-keygen 1
-+using a two-step process.
-+An initial
-+.Em candidate generation
-+pass, using
-+.Ic ssh-keygen -G ,
-+calculates numbers that are likely to be useful.
-+A second
-+.Em primality testing
-+pass, using
-+.Ic ssh-keygen -T ,
-+provides a high degree of assurance that the numbers are prime and are
-+safe for use in Diffie-Hellman operations by
-+.Xr sshd 1M .
-+This
-+.Nm
-+format is used as the output from each pass.
-+.Pp
-+The file consists of newline-separated records, one per modulus,
-+containing seven space-separated fields.
-+These fields are as follows:
-+.Bl -tag -width Description -offset indent
-+.It timestamp
-+The time that the modulus was last processed as YYYYMMDDHHMMSS.
-+.It type
-+Decimal number specifying the internal structure of the prime modulus.
-+Supported types are:
-+.Pp
-+.Bl -tag -width 0x00 -compact
-+.It 0
-+Unknown, not tested.
-+.It 2
-+"Safe" prime; (p-1)/2 is also prime.
-+.It 4
-+Sophie Germain; 2p+1 is also prime.
-+.El
-+.Pp
-+Moduli candidates initially produced by
-+.Xr ssh-keygen 1
-+are Sophie Germain primes (type 4).
-+Further primality testing with
-+.Xr ssh-keygen 1
-+produces safe prime moduli (type 2) that are ready for use in
-+.Xr sshd 1M .
-+Other types are not used by OpenSSH.
-+.It tests
-+Decimal number indicating the type of primality tests that the number
-+has been subjected to represented as a bitmask of the following values:
-+.Pp
-+.Bl -tag -width 0x00 -compact
-+.It 0x00
-+Not tested.
-+.It 0x01
-+Composite number \(en not prime.
-+.It 0x02
-+Sieve of Eratosthenes.
-+.It 0x04
-+Probabilistic Miller-Rabin primality tests.
-+.El
-+.Pp
-+The
-+.Xr ssh-keygen 1
-+moduli candidate generation uses the Sieve of Eratosthenes (flag 0x02).
-+Subsequent
-+.Xr ssh-keygen 1
-+primality tests are Miller-Rabin tests (flag 0x04).
-+.It trials
-+Decimal number indicating the number of primality trials
-+that have been performed on the modulus.
-+.It size
-+Decimal number indicating the size of the prime in bits.
-+.It generator
-+The recommended generator for use with this modulus (hexadecimal).
-+.It modulus
-+The modulus itself in hexadecimal.
-+.El
-+.Pp
-+When performing Diffie-Hellman Group Exchange,
-+.Xr sshd 1M
-+first estimates the size of the modulus required to produce enough
-+Diffie-Hellman output to sufficiently key the selected symmetric cipher.
-+.Xr sshd 1M
-+then randomly selects a modulus from
-+.Fa /etc/moduli
-+that best meets the size requirement.
-+.Sh SEE ALSO
-+.Xr ssh-keygen 1 ,
-+.Xr sshd 1M
-+.Sh STANDARDS
-+.Rs
-+.%A M. Friedl
-+.%A N. Provos
-+.%A W. Simpson
-+.%D March 2006
-+.%R RFC 4419
-+.%T Diffie-Hellman Group Exchange for the Secure Shell (SSH) Transport Layer Protocol
-+.%D 2006
-+.Re
-diff --git a/moduli.5 b/moduli.5
-deleted file mode 100644
-index ef0de08..0000000
---- a/moduli.5
-+++ /dev/null
-@@ -1,127 +0,0 @@
--.\"	$OpenBSD: moduli.5,v 1.17 2012/09/26 17:34:38 jmc Exp $
--.\"
--.\" Copyright (c) 2008 Damien Miller <djm@mindrot.org>
--.\"
--.\" Permission to use, copy, modify, and distribute this software for any
--.\" purpose with or without fee is hereby granted, provided that the above
--.\" copyright notice and this permission notice appear in all copies.
--.\"
--.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
--.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
--.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
--.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
--.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
--.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
--.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--.Dd $Mdocdate: September 26 2012 $
--.Dt MODULI 5
--.Os
--.Sh NAME
--.Nm moduli
--.Nd Diffie-Hellman moduli
--.Sh DESCRIPTION
--The
--.Pa /etc/moduli
--file contains prime numbers and generators for use by
--.Xr sshd 8
--in the Diffie-Hellman Group Exchange key exchange method.
--.Pp
--New moduli may be generated with
--.Xr ssh-keygen 1
--using a two-step process.
--An initial
--.Em candidate generation
--pass, using
--.Ic ssh-keygen -G ,
--calculates numbers that are likely to be useful.
--A second
--.Em primality testing
--pass, using
--.Ic ssh-keygen -T ,
--provides a high degree of assurance that the numbers are prime and are
--safe for use in Diffie-Hellman operations by
--.Xr sshd 8 .
--This
--.Nm
--format is used as the output from each pass.
--.Pp
--The file consists of newline-separated records, one per modulus,
--containing seven space-separated fields.
--These fields are as follows:
--.Bl -tag -width Description -offset indent
--.It timestamp
--The time that the modulus was last processed as YYYYMMDDHHMMSS.
--.It type
--Decimal number specifying the internal structure of the prime modulus.
--Supported types are:
--.Pp
--.Bl -tag -width 0x00 -compact
--.It 0
--Unknown, not tested.
--.It 2
--"Safe" prime; (p-1)/2 is also prime.
--.It 4
--Sophie Germain; 2p+1 is also prime.
--.El
--.Pp
--Moduli candidates initially produced by
--.Xr ssh-keygen 1
--are Sophie Germain primes (type 4).
--Further primality testing with
--.Xr ssh-keygen 1
--produces safe prime moduli (type 2) that are ready for use in
--.Xr sshd 8 .
--Other types are not used by OpenSSH.
--.It tests
--Decimal number indicating the type of primality tests that the number
--has been subjected to represented as a bitmask of the following values:
--.Pp
--.Bl -tag -width 0x00 -compact
--.It 0x00
--Not tested.
--.It 0x01
--Composite number \(en not prime.
--.It 0x02
--Sieve of Eratosthenes.
--.It 0x04
--Probabilistic Miller-Rabin primality tests.
--.El
--.Pp
--The
--.Xr ssh-keygen 1
--moduli candidate generation uses the Sieve of Eratosthenes (flag 0x02).
--Subsequent
--.Xr ssh-keygen 1
--primality tests are Miller-Rabin tests (flag 0x04).
--.It trials
--Decimal number indicating the number of primality trials
--that have been performed on the modulus.
--.It size
--Decimal number indicating the size of the prime in bits.
--.It generator
--The recommended generator for use with this modulus (hexadecimal).
--.It modulus
--The modulus itself in hexadecimal.
--.El
--.Pp
--When performing Diffie-Hellman Group Exchange,
--.Xr sshd 8
--first estimates the size of the modulus required to produce enough
--Diffie-Hellman output to sufficiently key the selected symmetric cipher.
--.Xr sshd 8
--then randomly selects a modulus from
--.Fa /etc/moduli
--that best meets the size requirement.
--.Sh SEE ALSO
--.Xr ssh-keygen 1 ,
--.Xr sshd 8
--.Sh STANDARDS
--.Rs
--.%A M. Friedl
--.%A N. Provos
--.%A W. Simpson
--.%D March 2006
--.%R RFC 4419
--.%T Diffie-Hellman Group Exchange for the Secure Shell (SSH) Transport Layer Protocol
--.%D 2006
--.Re
-diff --git a/sftp-server.1m b/sftp-server.1m
-new file mode 100644
-index 0000000..42354c2
---- /dev/null
-+++ b/sftp-server.1m
-@@ -0,0 +1,170 @@
-+.\" $OpenBSD: sftp-server.8,v 1.27 2014/12/11 04:16:14 djm Exp $
-+.\"
-+.\" Copyright (c) 2000 Markus Friedl.  All rights reserved.
-+.\"
-+.\" Redistribution and use in source and binary forms, with or without
-+.\" modification, are permitted provided that the following conditions
-+.\" are met:
-+.\" 1. Redistributions of source code must retain the above copyright
-+.\"    notice, this list of conditions and the following disclaimer.
-+.\" 2. Redistributions in binary form must reproduce the above copyright
-+.\"    notice, this list of conditions and the following disclaimer in the
-+.\"    documentation and/or other materials provided with the distribution.
-+.\"
-+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-+.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-+.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-+.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-+.\"
-+.Dd $Mdocdate: December 11 2014 $
-+.Dt SFTP-SERVER 1M
-+.Os
-+.Sh NAME
-+.Nm sftp-server
-+.Nd SFTP server subsystem
-+.Sh SYNOPSIS
-+.Nm sftp-server
-+.Bk -words
-+.Op Fl ehR
-+.Op Fl d Ar start_directory
-+.Op Fl f Ar log_facility
-+.Op Fl l Ar log_level
-+.Op Fl P Ar blacklisted_requests
-+.Op Fl p Ar whitelisted_requests
-+.Op Fl u Ar umask
-+.Ek
-+.Nm
-+.Fl Q Ar protocol_feature
-+.Sh DESCRIPTION
-+.Nm
-+is a program that speaks the server side of SFTP protocol
-+to stdout and expects client requests from stdin.
-+.Nm
-+is not intended to be called directly, but from
-+.Xr sshd 1M
-+using the
-+.Cm Subsystem
-+option.
-+.Pp
-+Command-line flags to
-+.Nm
-+should be specified in the
-+.Cm Subsystem
-+declaration.
-+See
-+.Xr sshd_config 4
-+for more information.
-+.Pp
-+Valid options are:
-+.Bl -tag -width Ds
-+.It Fl d Ar start_directory
-+specifies an alternate starting directory for users.
-+The pathname may contain the following tokens that are expanded at runtime:
-+%% is replaced by a literal '%',
-+%d is replaced by the home directory of the user being authenticated,
-+and %u is replaced by the username of that user.
-+The default is to use the user's home directory.
-+This option is useful in conjunction with the
-+.Xr sshd_config 4
-+.Cm ChrootDirectory
-+option.
-+.It Fl e
-+Causes
-+.Nm
-+to print logging information to stderr instead of syslog for debugging.
-+.It Fl f Ar log_facility
-+Specifies the facility code that is used when logging messages from
-+.Nm .
-+The possible values are: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2,
-+LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7.
-+The default is AUTH.
-+.It Fl h
-+Displays
-+.Nm
-+usage information.
-+.It Fl l Ar log_level
-+Specifies which messages will be logged by
-+.Nm .
-+The possible values are:
-+QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3.
-+INFO and VERBOSE log transactions that
-+.Nm
-+performs on behalf of the client.
-+DEBUG and DEBUG1 are equivalent.
-+DEBUG2 and DEBUG3 each specify higher levels of debugging output.
-+The default is ERROR.
-+.It Fl P Ar blacklisted_requests
-+Specify a comma-separated list of SFTP protocol requests that are banned by
-+the server.
-+.Nm
-+will reply to any blacklisted request with a failure.
-+The
-+.Fl Q
-+flag can be used to determine the supported request types.
-+If both a blacklist and a whitelist are specified, then the blacklist is
-+applied before the whitelist.
-+.It Fl p Ar whitelisted_requests
-+Specify a comma-separated list of SFTP protocol requests that are permitted
-+by the server.
-+All request types that are not on the whitelist will be logged and replied
-+to with a failure message.
-+.Pp
-+Care must be taken when using this feature to ensure that requests made
-+implicitly by SFTP clients are permitted.
-+.It Fl Q Ar protocol_feature
-+Query protocol features supported by
-+.Nm .
-+At present the only feature that may be queried is
-+.Dq requests ,
-+which may be used for black or whitelisting (flags
-+.Fl P
-+and
-+.Fl p
-+respectively).
-+.It Fl R
-+Places this instance of
-+.Nm
-+into a read-only mode.
-+Attempts to open files for writing, as well as other operations that change
-+the state of the filesystem, will be denied.
-+.It Fl u Ar umask
-+Sets an explicit
-+.Xr umask 2
-+to be applied to newly-created files and directories, instead of the
-+user's default mask.
-+.El
-+.Pp
-+On some systems,
-+.Nm
-+must be able to access
-+.Pa /dev/log
-+for logging to work, and use of
-+.Nm
-+in a chroot configuration therefore requires that
-+.Xr syslogd 8
-+establish a logging socket inside the chroot directory.
-+.Sh SEE ALSO
-+.Xr sftp 1 ,
-+.Xr ssh 1 ,
-+.Xr sshd_config 4 ,
-+.Xr sshd 1M
-+.Rs
-+.%A T. Ylonen
-+.%A S. Lehtinen
-+.%T "SSH File Transfer Protocol"
-+.%N draft-ietf-secsh-filexfer-02.txt
-+.%D October 2001
-+.%O work in progress material
-+.Re
-+.Sh HISTORY
-+.Nm
-+first appeared in
-+.Ox 2.8 .
-+.Sh AUTHORS
-+.An Markus Friedl Aq Mt markus@openbsd.org
-diff --git a/sftp-server.8 b/sftp-server.8
-deleted file mode 100644
-index c117398..0000000
---- a/sftp-server.8
-+++ /dev/null
-@@ -1,170 +0,0 @@
--.\" $OpenBSD: sftp-server.8,v 1.27 2014/12/11 04:16:14 djm Exp $
--.\"
--.\" Copyright (c) 2000 Markus Friedl.  All rights reserved.
--.\"
--.\" Redistribution and use in source and binary forms, with or without
--.\" modification, are permitted provided that the following conditions
--.\" are met:
--.\" 1. Redistributions of source code must retain the above copyright
--.\"    notice, this list of conditions and the following disclaimer.
--.\" 2. Redistributions in binary form must reproduce the above copyright
--.\"    notice, this list of conditions and the following disclaimer in the
--.\"    documentation and/or other materials provided with the distribution.
--.\"
--.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
--.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
--.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
--.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
--.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
--.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
--.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
--.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
--.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
--.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--.\"
--.Dd $Mdocdate: December 11 2014 $
--.Dt SFTP-SERVER 8
--.Os
--.Sh NAME
--.Nm sftp-server
--.Nd SFTP server subsystem
--.Sh SYNOPSIS
--.Nm sftp-server
--.Bk -words
--.Op Fl ehR
--.Op Fl d Ar start_directory
--.Op Fl f Ar log_facility
--.Op Fl l Ar log_level
--.Op Fl P Ar blacklisted_requests
--.Op Fl p Ar whitelisted_requests
--.Op Fl u Ar umask
--.Ek
--.Nm
--.Fl Q Ar protocol_feature
--.Sh DESCRIPTION
--.Nm
--is a program that speaks the server side of SFTP protocol
--to stdout and expects client requests from stdin.
--.Nm
--is not intended to be called directly, but from
--.Xr sshd 8
--using the
--.Cm Subsystem
--option.
--.Pp
--Command-line flags to
--.Nm
--should be specified in the
--.Cm Subsystem
--declaration.
--See
--.Xr sshd_config 5
--for more information.
--.Pp
--Valid options are:
--.Bl -tag -width Ds
--.It Fl d Ar start_directory
--specifies an alternate starting directory for users.
--The pathname may contain the following tokens that are expanded at runtime:
--%% is replaced by a literal '%',
--%d is replaced by the home directory of the user being authenticated,
--and %u is replaced by the username of that user.
--The default is to use the user's home directory.
--This option is useful in conjunction with the
--.Xr sshd_config 5
--.Cm ChrootDirectory
--option.
--.It Fl e
--Causes
--.Nm
--to print logging information to stderr instead of syslog for debugging.
--.It Fl f Ar log_facility
--Specifies the facility code that is used when logging messages from
--.Nm .
--The possible values are: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2,
--LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7.
--The default is AUTH.
--.It Fl h
--Displays
--.Nm
--usage information.
--.It Fl l Ar log_level
--Specifies which messages will be logged by
--.Nm .
--The possible values are:
--QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3.
--INFO and VERBOSE log transactions that
--.Nm
--performs on behalf of the client.
--DEBUG and DEBUG1 are equivalent.
--DEBUG2 and DEBUG3 each specify higher levels of debugging output.
--The default is ERROR.
--.It Fl P Ar blacklisted_requests
--Specify a comma-separated list of SFTP protocol requests that are banned by
--the server.
--.Nm
--will reply to any blacklisted request with a failure.
--The
--.Fl Q
--flag can be used to determine the supported request types.
--If both a blacklist and a whitelist are specified, then the blacklist is
--applied before the whitelist.
--.It Fl p Ar whitelisted_requests
--Specify a comma-separated list of SFTP protocol requests that are permitted
--by the server.
--All request types that are not on the whitelist will be logged and replied
--to with a failure message.
--.Pp
--Care must be taken when using this feature to ensure that requests made
--implicitly by SFTP clients are permitted.
--.It Fl Q Ar protocol_feature
--Query protocol features supported by
--.Nm .
--At present the only feature that may be queried is
--.Dq requests ,
--which may be used for black or whitelisting (flags
--.Fl P
--and
--.Fl p
--respectively).
--.It Fl R
--Places this instance of
--.Nm
--into a read-only mode.
--Attempts to open files for writing, as well as other operations that change
--the state of the filesystem, will be denied.
--.It Fl u Ar umask
--Sets an explicit
--.Xr umask 2
--to be applied to newly-created files and directories, instead of the
--user's default mask.
--.El
--.Pp
--On some systems,
--.Nm
--must be able to access
--.Pa /dev/log
--for logging to work, and use of
--.Nm
--in a chroot configuration therefore requires that
--.Xr syslogd 8
--establish a logging socket inside the chroot directory.
--.Sh SEE ALSO
--.Xr sftp 1 ,
--.Xr ssh 1 ,
--.Xr sshd_config 5 ,
--.Xr sshd 8
--.Rs
--.%A T. Ylonen
--.%A S. Lehtinen
--.%T "SSH File Transfer Protocol"
--.%N draft-ietf-secsh-filexfer-02.txt
--.%D October 2001
--.%O work in progress material
--.Re
--.Sh HISTORY
--.Nm
--first appeared in
--.Ox 2.8 .
--.Sh AUTHORS
--.An Markus Friedl Aq Mt markus@openbsd.org
-diff --git a/ssh-keysign.1m b/ssh-keysign.1m
-new file mode 100644
-index 0000000..60c96ad
---- /dev/null
-+++ b/ssh-keysign.1m
-@@ -0,0 +1,93 @@
-+.\" $OpenBSD: ssh-keysign.8,v 1.14 2013/12/07 11:58:46 naddy Exp $
-+.\"
-+.\" Copyright (c) 2002 Markus Friedl.  All rights reserved.
-+.\"
-+.\" Redistribution and use in source and binary forms, with or without
-+.\" modification, are permitted provided that the following conditions
-+.\" are met:
-+.\" 1. Redistributions of source code must retain the above copyright
-+.\"    notice, this list of conditions and the following disclaimer.
-+.\" 2. Redistributions in binary form must reproduce the above copyright
-+.\"    notice, this list of conditions and the following disclaimer in the
-+.\"    documentation and/or other materials provided with the distribution.
-+.\"
-+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-+.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-+.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-+.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-+.\"
-+.Dd $Mdocdate: December 7 2013 $
-+.Dt SSH-KEYSIGN 1M
-+.Os
-+.Sh NAME
-+.Nm ssh-keysign
-+.Nd ssh helper program for host-based authentication
-+.Sh SYNOPSIS
-+.Nm
-+.Sh DESCRIPTION
-+.Nm
-+is used by
-+.Xr ssh 1
-+to access the local host keys and generate the digital signature
-+required during host-based authentication with SSH protocol version 2.
-+.Pp
-+.Nm
-+is disabled by default and can only be enabled in the
-+global client configuration file
-+.Pa /etc/ssh/ssh_config
-+by setting
-+.Cm EnableSSHKeysign
-+to
-+.Dq yes .
-+.Pp
-+.Nm
-+is not intended to be invoked by the user, but from
-+.Xr ssh 1 .
-+See
-+.Xr ssh 1
-+and
-+.Xr sshd 1M
-+for more information about host-based authentication.
-+.Sh FILES
-+.Bl -tag -width Ds -compact
-+.It Pa /etc/ssh/ssh_config
-+Controls whether
-+.Nm
-+is enabled.
-+.Pp
-+.It Pa /etc/ssh/ssh_host_dsa_key
-+.It Pa /etc/ssh/ssh_host_ecdsa_key
-+.It Pa /etc/ssh/ssh_host_ed25519_key
-+.It Pa /etc/ssh/ssh_host_rsa_key
-+These files contain the private parts of the host keys used to
-+generate the digital signature.
-+They should be owned by root, readable only by root, and not
-+accessible to others.
-+Since they are readable only by root,
-+.Nm
-+must be set-uid root if host-based authentication is used.
-+.Pp
-+.It Pa /etc/ssh/ssh_host_dsa_key-cert.pub
-+.It Pa /etc/ssh/ssh_host_ecdsa_key-cert.pub
-+.It Pa /etc/ssh/ssh_host_ed25519_key-cert.pub
-+.It Pa /etc/ssh/ssh_host_rsa_key-cert.pub
-+If these files exist they are assumed to contain public certificate
-+information corresponding with the private keys above.
-+.El
-+.Sh SEE ALSO
-+.Xr ssh 1 ,
-+.Xr ssh-keygen 1 ,
-+.Xr ssh_config 4 ,
-+.Xr sshd 1M
-+.Sh HISTORY
-+.Nm
-+first appeared in
-+.Ox 3.2 .
-+.Sh AUTHORS
-+.An Markus Friedl Aq Mt markus@openbsd.org
-diff --git a/ssh-keysign.8 b/ssh-keysign.8
-deleted file mode 100644
-index 69d0829..0000000
---- a/ssh-keysign.8
-+++ /dev/null
-@@ -1,93 +0,0 @@
--.\" $OpenBSD: ssh-keysign.8,v 1.14 2013/12/07 11:58:46 naddy Exp $
--.\"
--.\" Copyright (c) 2002 Markus Friedl.  All rights reserved.
--.\"
--.\" Redistribution and use in source and binary forms, with or without
--.\" modification, are permitted provided that the following conditions
--.\" are met:
--.\" 1. Redistributions of source code must retain the above copyright
--.\"    notice, this list of conditions and the following disclaimer.
--.\" 2. Redistributions in binary form must reproduce the above copyright
--.\"    notice, this list of conditions and the following disclaimer in the
--.\"    documentation and/or other materials provided with the distribution.
--.\"
--.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
--.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
--.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
--.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
--.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
--.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
--.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
--.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
--.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
--.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--.\"
--.Dd $Mdocdate: December 7 2013 $
--.Dt SSH-KEYSIGN 8
--.Os
--.Sh NAME
--.Nm ssh-keysign
--.Nd ssh helper program for host-based authentication
--.Sh SYNOPSIS
--.Nm
--.Sh DESCRIPTION
--.Nm
--is used by
--.Xr ssh 1
--to access the local host keys and generate the digital signature
--required during host-based authentication with SSH protocol version 2.
--.Pp
--.Nm
--is disabled by default and can only be enabled in the
--global client configuration file
--.Pa /etc/ssh/ssh_config
--by setting
--.Cm EnableSSHKeysign
--to
--.Dq yes .
--.Pp
--.Nm
--is not intended to be invoked by the user, but from
--.Xr ssh 1 .
--See
--.Xr ssh 1
--and
--.Xr sshd 8
--for more information about host-based authentication.
--.Sh FILES
--.Bl -tag -width Ds -compact
--.It Pa /etc/ssh/ssh_config
--Controls whether
--.Nm
--is enabled.
--.Pp
--.It Pa /etc/ssh/ssh_host_dsa_key
--.It Pa /etc/ssh/ssh_host_ecdsa_key
--.It Pa /etc/ssh/ssh_host_ed25519_key
--.It Pa /etc/ssh/ssh_host_rsa_key
--These files contain the private parts of the host keys used to
--generate the digital signature.
--They should be owned by root, readable only by root, and not
--accessible to others.
--Since they are readable only by root,
--.Nm
--must be set-uid root if host-based authentication is used.
--.Pp
--.It Pa /etc/ssh/ssh_host_dsa_key-cert.pub
--.It Pa /etc/ssh/ssh_host_ecdsa_key-cert.pub
--.It Pa /etc/ssh/ssh_host_ed25519_key-cert.pub
--.It Pa /etc/ssh/ssh_host_rsa_key-cert.pub
--If these files exist they are assumed to contain public certificate
--information corresponding with the private keys above.
--.El
--.Sh SEE ALSO
--.Xr ssh 1 ,
--.Xr ssh-keygen 1 ,
--.Xr ssh_config 5 ,
--.Xr sshd 8
--.Sh HISTORY
--.Nm
--first appeared in
--.Ox 3.2 .
--.Sh AUTHORS
--.An Markus Friedl Aq Mt markus@openbsd.org
-diff --git a/ssh-pkcs11-helper.1m b/ssh-pkcs11-helper.1m
-new file mode 100644
-index 0000000..646b1fa
---- /dev/null
-+++ b/ssh-pkcs11-helper.1m
-@@ -0,0 +1,43 @@
-+.\" $OpenBSD: ssh-pkcs11-helper.8,v 1.4 2013/07/16 00:07:52 schwarze Exp $
-+.\"
-+.\" Copyright (c) 2010 Markus Friedl.  All rights reserved.
-+.\"
-+.\" Permission to use, copy, modify, and distribute this software for any
-+.\" purpose with or without fee is hereby granted, provided that the above
-+.\" copyright notice and this permission notice appear in all copies.
-+.\"
-+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-+.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-+.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-+.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
-+.\"
-+.Dd $Mdocdate: July 16 2013 $
-+.Dt SSH-PKCS11-HELPER 1M
-+.Os
-+.Sh NAME
-+.Nm ssh-pkcs11-helper
-+.Nd ssh-agent helper program for PKCS#11 support
-+.Sh SYNOPSIS
-+.Nm
-+.Sh DESCRIPTION
-+.Nm
-+is used by
-+.Xr ssh-agent 1
-+to access keys provided by a PKCS#11 token.
-+.Pp
-+.Nm
-+is not intended to be invoked by the user, but from
-+.Xr ssh-agent 1 .
-+.Sh SEE ALSO
-+.Xr ssh 1 ,
-+.Xr ssh-add 1 ,
-+.Xr ssh-agent 1
-+.Sh HISTORY
-+.Nm
-+first appeared in
-+.Ox 4.7 .
-+.Sh AUTHORS
-+.An Markus Friedl Aq Mt markus@openbsd.org
-diff --git a/ssh-pkcs11-helper.8 b/ssh-pkcs11-helper.8
-deleted file mode 100644
-index 3728c4e..0000000
---- a/ssh-pkcs11-helper.8
-+++ /dev/null
-@@ -1,43 +0,0 @@
--.\" $OpenBSD: ssh-pkcs11-helper.8,v 1.4 2013/07/16 00:07:52 schwarze Exp $
--.\"
--.\" Copyright (c) 2010 Markus Friedl.  All rights reserved.
--.\"
--.\" Permission to use, copy, modify, and distribute this software for any
--.\" purpose with or without fee is hereby granted, provided that the above
--.\" copyright notice and this permission notice appear in all copies.
--.\"
--.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
--.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
--.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
--.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
--.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
--.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
--.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--.\"
--.Dd $Mdocdate: July 16 2013 $
--.Dt SSH-PKCS11-HELPER 8
--.Os
--.Sh NAME
--.Nm ssh-pkcs11-helper
--.Nd ssh-agent helper program for PKCS#11 support
--.Sh SYNOPSIS
--.Nm
--.Sh DESCRIPTION
--.Nm
--is used by
--.Xr ssh-agent 1
--to access keys provided by a PKCS#11 token.
--.Pp
--.Nm
--is not intended to be invoked by the user, but from
--.Xr ssh-agent 1 .
--.Sh SEE ALSO
--.Xr ssh 1 ,
--.Xr ssh-add 1 ,
--.Xr ssh-agent 1
--.Sh HISTORY
--.Nm
--first appeared in
--.Ox 4.7 .
--.Sh AUTHORS
--.An Markus Friedl Aq Mt markus@openbsd.org
-diff --git a/ssh_config.4 b/ssh_config.4
-new file mode 100644
-index 0000000..8c099eb
---- /dev/null
-+++ b/ssh_config.4
-@@ -0,0 +1,1726 @@
-+.\"
-+.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
-+.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
-+.\"                    All rights reserved
-+.\"
-+.\" As far as I am concerned, the code I have written for this software
-+.\" can be used freely for any purpose.  Any derived versions of this
-+.\" software must be clearly marked as such, and if the derived work is
-+.\" incompatible with the protocol description in the RFC file, it must be
-+.\" called by a name other than "ssh" or "Secure Shell".
-+.\"
-+.\" Copyright (c) 1999,2000 Markus Friedl.  All rights reserved.
-+.\" Copyright (c) 1999 Aaron Campbell.  All rights reserved.
-+.\" Copyright (c) 1999 Theo de Raadt.  All rights reserved.
-+.\"
-+.\" Redistribution and use in source and binary forms, with or without
-+.\" modification, are permitted provided that the following conditions
-+.\" are met:
-+.\" 1. Redistributions of source code must retain the above copyright
-+.\"    notice, this list of conditions and the following disclaimer.
-+.\" 2. Redistributions in binary form must reproduce the above copyright
-+.\"    notice, this list of conditions and the following disclaimer in the
-+.\"    documentation and/or other materials provided with the distribution.
-+.\"
-+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-+.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-+.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-+.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-+.\"
-+.\" $OpenBSD: ssh_config.5,v 1.215 2015/08/14 15:32:41 jmc Exp $
-+.Dd $Mdocdate: August 14 2015 $
-+.Dt SSH_CONFIG 4
-+.Os
-+.Sh NAME
-+.Nm ssh_config
-+.Nd OpenSSH SSH client configuration files
-+.Sh SYNOPSIS
-+.Nm ~/.ssh/config
-+.Nm /etc/ssh/ssh_config
-+.Sh DESCRIPTION
-+.Xr ssh 1
-+obtains configuration data from the following sources in
-+the following order:
-+.Pp
-+.Bl -enum -offset indent -compact
-+.It
-+command-line options
-+.It
-+user's configuration file
-+.Pq Pa ~/.ssh/config
-+.It
-+system-wide configuration file
-+.Pq Pa /etc/ssh/ssh_config
-+.El
-+.Pp
-+For each parameter, the first obtained value
-+will be used.
-+The configuration files contain sections separated by
-+.Dq Host
-+specifications, and that section is only applied for hosts that
-+match one of the patterns given in the specification.
-+The matched host name is usually the one given on the command line
-+(see the
-+.Cm CanonicalizeHostname
-+option for exceptions.)
-+.Pp
-+Since the first obtained value for each parameter is used, more
-+host-specific declarations should be given near the beginning of the
-+file, and general defaults at the end.
-+.Pp
-+The configuration file has the following format:
-+.Pp
-+Empty lines and lines starting with
-+.Ql #
-+are comments.
-+Otherwise a line is of the format
-+.Dq keyword arguments .
-+Configuration options may be separated by whitespace or
-+optional whitespace and exactly one
-+.Ql = ;
-+the latter format is useful to avoid the need to quote whitespace
-+when specifying configuration options using the
-+.Nm ssh ,
-+.Nm scp ,
-+and
-+.Nm sftp
-+.Fl o
-+option.
-+Arguments may optionally be enclosed in double quotes
-+.Pq \&"
-+in order to represent arguments containing spaces.
-+.Pp
-+The possible
-+keywords and their meanings are as follows (note that
-+keywords are case-insensitive and arguments are case-sensitive):
-+.Bl -tag -width Ds
-+.It Cm Host
-+Restricts the following declarations (up to the next
-+.Cm Host
-+or
-+.Cm Match
-+keyword) to be only for those hosts that match one of the patterns
-+given after the keyword.
-+If more than one pattern is provided, they should be separated by whitespace.
-+A single
-+.Ql *
-+as a pattern can be used to provide global
-+defaults for all hosts.
-+The host is usually the
-+.Ar hostname
-+argument given on the command line
-+(see the
-+.Cm CanonicalizeHostname
-+option for exceptions.)
-+.Pp
-+A pattern entry may be negated by prefixing it with an exclamation mark
-+.Pq Sq !\& .
-+If a negated entry is matched, then the
-+.Cm Host
-+entry is ignored, regardless of whether any other patterns on the line
-+match.
-+Negated matches are therefore useful to provide exceptions for wildcard
-+matches.
-+.Pp
-+See
-+.Sx PATTERNS
-+for more information on patterns.
-+.It Cm Match
-+Restricts the following declarations (up to the next
-+.Cm Host
-+or
-+.Cm Match
-+keyword) to be used only when the conditions following the
-+.Cm Match
-+keyword are satisfied.
-+Match conditions are specified using one or more critera
-+or the single token
-+.Cm all
-+which always matches.
-+The available criteria keywords are:
-+.Cm canonical ,
-+.Cm exec ,
-+.Cm host ,
-+.Cm originalhost ,
-+.Cm user ,
-+and
-+.Cm localuser .
-+The
-+.Cm all
-+criteria must appear alone or immediately after
-+.Cm canonical .
-+Other criteria may be combined arbitrarily.
-+All criteria but
-+.Cm all
-+and
-+.Cm canonical
-+require an argument.
-+Criteria may be negated by prepending an exclamation mark
-+.Pq Sq !\& .
-+.Pp
-+The
-+.Cm canonical
-+keyword matches only when the configuration file is being re-parsed
-+after hostname canonicalization (see the
-+.Cm CanonicalizeHostname
-+option.)
-+This may be useful to specify conditions that work with canonical host
-+names only.
-+The
-+.Cm exec
-+keyword executes the specified command under the user's shell.
-+If the command returns a zero exit status then the condition is considered true.
-+Commands containing whitespace characters must be quoted.
-+The following character sequences in the command will be expanded prior to
-+execution:
-+.Ql %L
-+will be substituted by the first component of the local host name,
-+.Ql %l
-+will be substituted by the local host name (including any domain name),
-+.Ql %h
-+will be substituted by the target host name,
-+.Ql %n
-+will be substituted by the original target host name
-+specified on the command-line,
-+.Ql %p
-+the destination port,
-+.Ql %r
-+by the remote login username, and
-+.Ql %u
-+by the username of the user running
-+.Xr ssh 1 .
-+.Pp
-+The other keywords' criteria must be single entries or comma-separated
-+lists and may use the wildcard and negation operators described in the
-+.Sx PATTERNS
-+section.
-+The criteria for the
-+.Cm host
-+keyword are matched against the target hostname, after any substitution
-+by the
-+.Cm Hostname
-+or
-+.Cm CanonicalizeHostname
-+options.
-+The
-+.Cm originalhost
-+keyword matches against the hostname as it was specified on the command-line.
-+The
-+.Cm user
-+keyword matches against the target username on the remote host.
-+The
-+.Cm localuser
-+keyword matches against the name of the local user running
-+.Xr ssh 1
-+(this keyword may be useful in system-wide
-+.Nm
-+files).
-+.It Cm AddressFamily
-+Specifies which address family to use when connecting.
-+Valid arguments are
-+.Dq any ,
-+.Dq inet
-+(use IPv4 only), or
-+.Dq inet6
-+(use IPv6 only).
-+.It Cm BatchMode
-+If set to
-+.Dq yes ,
-+passphrase/password querying will be disabled.
-+This option is useful in scripts and other batch jobs where no user
-+is present to supply the password.
-+The argument must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is
-+.Dq no .
-+.It Cm BindAddress
-+Use the specified address on the local machine as the source address of
-+the connection.
-+Only useful on systems with more than one address.
-+Note that this option does not work if
-+.Cm UsePrivilegedPort
-+is set to
-+.Dq yes .
-+.It Cm CanonicalDomains
-+When
-+.Cm CanonicalizeHostname
-+is enabled, this option specifies the list of domain suffixes in which to
-+search for the specified destination host.
-+.It Cm CanonicalizeFallbackLocal
-+Specifies whether to fail with an error when hostname canonicalization fails.
-+The default,
-+.Dq yes ,
-+will attempt to look up the unqualified hostname using the system resolver's
-+search rules.
-+A value of
-+.Dq no
-+will cause
-+.Xr ssh 1
-+to fail instantly if
-+.Cm CanonicalizeHostname
-+is enabled and the target hostname cannot be found in any of the domains
-+specified by
-+.Cm CanonicalDomains .
-+.It Cm CanonicalizeHostname
-+Controls whether explicit hostname canonicalization is performed.
-+The default,
-+.Dq no ,
-+is not to perform any name rewriting and let the system resolver handle all
-+hostname lookups.
-+If set to
-+.Dq yes
-+then, for connections that do not use a
-+.Cm ProxyCommand ,
-+.Xr ssh 1
-+will attempt to canonicalize the hostname specified on the command line
-+using the
-+.Cm CanonicalDomains
-+suffixes and
-+.Cm CanonicalizePermittedCNAMEs
-+rules.
-+If
-+.Cm CanonicalizeHostname
-+is set to
-+.Dq always ,
-+then canonicalization is applied to proxied connections too.
-+.Pp
-+If this option is enabled, then the configuration files are processed
-+again using the new target name to pick up any new configuration in matching
-+.Cm Host
-+and
-+.Cm Match
-+stanzas.
-+.It Cm CanonicalizeMaxDots
-+Specifies the maximum number of dot characters in a hostname before
-+canonicalization is disabled.
-+The default,
-+.Dq 1 ,
-+allows a single dot (i.e. hostname.subdomain).
-+.It Cm CanonicalizePermittedCNAMEs
-+Specifies rules to determine whether CNAMEs should be followed when
-+canonicalizing hostnames.
-+The rules consist of one or more arguments of
-+.Ar source_domain_list : Ns Ar target_domain_list ,
-+where
-+.Ar source_domain_list
-+is a pattern-list of domains that may follow CNAMEs in canonicalization,
-+and
-+.Ar target_domain_list
-+is a pattern-list of domains that they may resolve to.
-+.Pp
-+For example,
-+.Dq *.a.example.com:*.b.example.com,*.c.example.com
-+will allow hostnames matching
-+.Dq *.a.example.com
-+to be canonicalized to names in the
-+.Dq *.b.example.com
-+or
-+.Dq *.c.example.com
-+domains.
-+.It Cm ChallengeResponseAuthentication
-+Specifies whether to use challenge-response authentication.
-+The argument to this keyword must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is
-+.Dq yes .
-+.It Cm CheckHostIP
-+If this flag is set to
-+.Dq yes ,
-+.Xr ssh 1
-+will additionally check the host IP address in the
-+.Pa known_hosts
-+file.
-+This allows ssh to detect if a host key changed due to DNS spoofing
-+and will add addresses of destination hosts to
-+.Pa ~/.ssh/known_hosts
-+in the process, regardless of the setting of
-+.Cm StrictHostKeyChecking .
-+If the option is set to
-+.Dq no ,
-+the check will not be executed.
-+The default is
-+.Dq yes .
-+.It Cm Cipher
-+Specifies the cipher to use for encrypting the session
-+in protocol version 1.
-+Currently,
-+.Dq blowfish ,
-+.Dq 3des ,
-+and
-+.Dq des
-+are supported.
-+.Ar des
-+is only supported in the
-+.Xr ssh 1
-+client for interoperability with legacy protocol 1 implementations
-+that do not support the
-+.Ar 3des
-+cipher.
-+Its use is strongly discouraged due to cryptographic weaknesses.
-+The default is
-+.Dq 3des .
-+.It Cm Ciphers
-+Specifies the ciphers allowed for protocol version 2
-+in order of preference.
-+Multiple ciphers must be comma-separated.
-+If the specified value begins with a
-+.Sq +
-+character, then the specified ciphers will be appended to the default set
-+instead of replacing them.
-+.Pp
-+The supported ciphers are:
-+.Pp
-+.Bl -item -compact -offset indent
-+.It
-+3des-cbc
-+.It
-+aes128-cbc
-+.It
-+aes192-cbc
-+.It
-+aes256-cbc
-+.It
-+aes128-ctr
-+.It
-+aes192-ctr
-+.It
-+aes256-ctr
-+.It
-+aes128-gcm@openssh.com
-+.It
-+aes256-gcm@openssh.com
-+.It
-+arcfour
-+.It
-+arcfour128
-+.It
-+arcfour256
-+.It
-+blowfish-cbc
-+.It
-+cast128-cbc
-+.It
-+chacha20-poly1305@openssh.com
-+.El
-+.Pp
-+The default is:
-+.Bd -literal -offset indent
-+chacha20-poly1305@openssh.com,
-+aes128-ctr,aes192-ctr,aes256-ctr,
-+aes128-gcm@openssh.com,aes256-gcm@openssh.com,
-+arcfour256,arcfour128,
-+aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,
-+aes192-cbc,aes256-cbc,arcfour
-+.Ed
-+.Pp
-+The list of available ciphers may also be obtained using the
-+.Fl Q
-+option of
-+.Xr ssh 1
-+with an argument of
-+.Dq cipher .
-+.It Cm ClearAllForwardings
-+Specifies that all local, remote, and dynamic port forwardings
-+specified in the configuration files or on the command line be
-+cleared.
-+This option is primarily useful when used from the
-+.Xr ssh 1
-+command line to clear port forwardings set in
-+configuration files, and is automatically set by
-+.Xr scp 1
-+and
-+.Xr sftp 1 .
-+The argument must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is
-+.Dq no .
-+.It Cm Compression
-+Specifies whether to use compression.
-+The argument must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is
-+.Dq no .
-+.It Cm CompressionLevel
-+Specifies the compression level to use if compression is enabled.
-+The argument must be an integer from 1 (fast) to 9 (slow, best).
-+The default level is 6, which is good for most applications.
-+The meaning of the values is the same as in
-+.Xr gzip 1 .
-+Note that this option applies to protocol version 1 only.
-+.It Cm ConnectionAttempts
-+Specifies the number of tries (one per second) to make before exiting.
-+The argument must be an integer.
-+This may be useful in scripts if the connection sometimes fails.
-+The default is 1.
-+.It Cm ConnectTimeout
-+Specifies the timeout (in seconds) used when connecting to the
-+SSH server, instead of using the default system TCP timeout.
-+This value is used only when the target is down or really unreachable,
-+not when it refuses the connection.
-+.It Cm ControlMaster
-+Enables the sharing of multiple sessions over a single network connection.
-+When set to
-+.Dq yes ,
-+.Xr ssh 1
-+will listen for connections on a control socket specified using the
-+.Cm ControlPath
-+argument.
-+Additional sessions can connect to this socket using the same
-+.Cm ControlPath
-+with
-+.Cm ControlMaster
-+set to
-+.Dq no
-+(the default).
-+These sessions will try to reuse the master instance's network connection
-+rather than initiating new ones, but will fall back to connecting normally
-+if the control socket does not exist, or is not listening.
-+.Pp
-+Setting this to
-+.Dq ask
-+will cause ssh
-+to listen for control connections, but require confirmation using
-+.Xr ssh-askpass 1 .
-+If the
-+.Cm ControlPath
-+cannot be opened,
-+ssh will continue without connecting to a master instance.
-+.Pp
-+X11 and
-+.Xr ssh-agent 1
-+forwarding is supported over these multiplexed connections, however the
-+display and agent forwarded will be the one belonging to the master
-+connection i.e. it is not possible to forward multiple displays or agents.
-+.Pp
-+Two additional options allow for opportunistic multiplexing: try to use a
-+master connection but fall back to creating a new one if one does not already
-+exist.
-+These options are:
-+.Dq auto
-+and
-+.Dq autoask .
-+The latter requires confirmation like the
-+.Dq ask
-+option.
-+.It Cm ControlPath
-+Specify the path to the control socket used for connection sharing as described
-+in the
-+.Cm ControlMaster
-+section above or the string
-+.Dq none
-+to disable connection sharing.
-+In the path,
-+.Ql %L
-+will be substituted by the first component of the local host name,
-+.Ql %l
-+will be substituted by the local host name (including any domain name),
-+.Ql %h
-+will be substituted by the target host name,
-+.Ql %n
-+will be substituted by the original target host name
-+specified on the command line,
-+.Ql %p
-+the destination port,
-+.Ql %r
-+by the remote login username,
-+.Ql %u
-+by the username of the user running
-+.Xr ssh 1 , and
-+.Ql \&%C
-+by a hash of the concatenation: %l%h%p%r.
-+It is recommended that any
-+.Cm ControlPath
-+used for opportunistic connection sharing include
-+at least %h, %p, and %r (or alternatively %C) and be placed in a directory
-+that is not writable by other users.
-+This ensures that shared connections are uniquely identified.
-+.It Cm ControlPersist
-+When used in conjunction with
-+.Cm ControlMaster ,
-+specifies that the master connection should remain open
-+in the background (waiting for future client connections)
-+after the initial client connection has been closed.
-+If set to
-+.Dq no ,
-+then the master connection will not be placed into the background,
-+and will close as soon as the initial client connection is closed.
-+If set to
-+.Dq yes
-+or
-+.Dq 0 ,
-+then the master connection will remain in the background indefinitely
-+(until killed or closed via a mechanism such as the
-+.Xr ssh 1
-+.Dq Fl O No exit
-+option).
-+If set to a time in seconds, or a time in any of the formats documented in
-+.Xr sshd_config 4 ,
-+then the backgrounded master connection will automatically terminate
-+after it has remained idle (with no client connections) for the
-+specified time.
-+.It Cm DynamicForward
-+Specifies that a TCP port on the local machine be forwarded
-+over the secure channel, and the application
-+protocol is then used to determine where to connect to from the
-+remote machine.
-+.Pp
-+The argument must be
-+.Sm off
-+.Oo Ar bind_address : Oc Ar port .
-+.Sm on
-+IPv6 addresses can be specified by enclosing addresses in square brackets.
-+By default, the local port is bound in accordance with the
-+.Cm GatewayPorts
-+setting.
-+However, an explicit
-+.Ar bind_address
-+may be used to bind the connection to a specific address.
-+The
-+.Ar bind_address
-+of
-+.Dq localhost
-+indicates that the listening port be bound for local use only, while an
-+empty address or
-+.Sq *
-+indicates that the port should be available from all interfaces.
-+.Pp
-+Currently the SOCKS4 and SOCKS5 protocols are supported, and
-+.Xr ssh 1
-+will act as a SOCKS server.
-+Multiple forwardings may be specified, and
-+additional forwardings can be given on the command line.
-+Only the superuser can forward privileged ports.
-+.It Cm EnableSSHKeysign
-+Setting this option to
-+.Dq yes
-+in the global client configuration file
-+.Pa /etc/ssh/ssh_config
-+enables the use of the helper program
-+.Xr ssh-keysign 8
-+during
-+.Cm HostbasedAuthentication .
-+The argument must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is
-+.Dq no .
-+This option should be placed in the non-hostspecific section.
-+See
-+.Xr ssh-keysign 8
-+for more information.
-+.It Cm EscapeChar
-+Sets the escape character (default:
-+.Ql ~ ) .
-+The escape character can also
-+be set on the command line.
-+The argument should be a single character,
-+.Ql ^
-+followed by a letter, or
-+.Dq none
-+to disable the escape
-+character entirely (making the connection transparent for binary
-+data).
-+.It Cm ExitOnForwardFailure
-+Specifies whether
-+.Xr ssh 1
-+should terminate the connection if it cannot set up all requested
-+dynamic, tunnel, local, and remote port forwardings.
-+The argument must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is
-+.Dq no .
-+.It Cm FingerprintHash
-+Specifies the hash algorithm used when displaying key fingerprints.
-+Valid options are:
-+.Dq md5
-+and
-+.Dq sha256 .
-+The default is
-+.Dq sha256 .
-+.It Cm ForwardAgent
-+Specifies whether the connection to the authentication agent (if any)
-+will be forwarded to the remote machine.
-+The argument must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is
-+.Dq no .
-+.Pp
-+Agent forwarding should be enabled with caution.
-+Users with the ability to bypass file permissions on the remote host
-+(for the agent's Unix-domain socket)
-+can access the local agent through the forwarded connection.
-+An attacker cannot obtain key material from the agent,
-+however they can perform operations on the keys that enable them to
-+authenticate using the identities loaded into the agent.
-+.It Cm ForwardX11
-+Specifies whether X11 connections will be automatically redirected
-+over the secure channel and
-+.Ev DISPLAY
-+set.
-+The argument must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is
-+.Dq no .
-+.Pp
-+X11 forwarding should be enabled with caution.
-+Users with the ability to bypass file permissions on the remote host
-+(for the user's X11 authorization database)
-+can access the local X11 display through the forwarded connection.
-+An attacker may then be able to perform activities such as keystroke monitoring
-+if the
-+.Cm ForwardX11Trusted
-+option is also enabled.
-+.It Cm ForwardX11Timeout
-+Specify a timeout for untrusted X11 forwarding
-+using the format described in the
-+TIME FORMATS section of
-+.Xr sshd_config 4 .
-+X11 connections received by
-+.Xr ssh 1
-+after this time will be refused.
-+The default is to disable untrusted X11 forwarding after twenty minutes has
-+elapsed.
-+.It Cm ForwardX11Trusted
-+If this option is set to
-+.Dq yes ,
-+remote X11 clients will have full access to the original X11 display.
-+.Pp
-+If this option is set to
-+.Dq no ,
-+remote X11 clients will be considered untrusted and prevented
-+from stealing or tampering with data belonging to trusted X11
-+clients.
-+Furthermore, the
-+.Xr xauth 1
-+token used for the session will be set to expire after 20 minutes.
-+Remote clients will be refused access after this time.
-+.Pp
-+The default is
-+.Dq no .
-+.Pp
-+See the X11 SECURITY extension specification for full details on
-+the restrictions imposed on untrusted clients.
-+.It Cm GatewayPorts
-+Specifies whether remote hosts are allowed to connect to local
-+forwarded ports.
-+By default,
-+.Xr ssh 1
-+binds local port forwardings to the loopback address.
-+This prevents other remote hosts from connecting to forwarded ports.
-+.Cm GatewayPorts
-+can be used to specify that ssh
-+should bind local port forwardings to the wildcard address,
-+thus allowing remote hosts to connect to forwarded ports.
-+The argument must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is
-+.Dq no .
-+.It Cm GlobalKnownHostsFile
-+Specifies one or more files to use for the global
-+host key database, separated by whitespace.
-+The default is
-+.Pa /etc/ssh/ssh_known_hosts ,
-+.Pa /etc/ssh/ssh_known_hosts2 .
-+.It Cm GSSAPIAuthentication
-+Specifies whether user authentication based on GSSAPI is allowed.
-+The default is
-+.Dq no .
-+Note that this option applies to protocol version 2 only.
-+.It Cm GSSAPIDelegateCredentials
-+Forward (delegate) credentials to the server.
-+The default is
-+.Dq no .
-+Note that this option applies to protocol version 2 only.
-+.It Cm HashKnownHosts
-+Indicates that
-+.Xr ssh 1
-+should hash host names and addresses when they are added to
-+.Pa ~/.ssh/known_hosts .
-+These hashed names may be used normally by
-+.Xr ssh 1
-+and
-+.Xr sshd 1M ,
-+but they do not reveal identifying information should the file's contents
-+be disclosed.
-+The default is
-+.Dq no .
-+Note that existing names and addresses in known hosts files
-+will not be converted automatically,
-+but may be manually hashed using
-+.Xr ssh-keygen 1 .
-+.It Cm HostbasedAuthentication
-+Specifies whether to try rhosts based authentication with public key
-+authentication.
-+The argument must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is
-+.Dq no .
-+This option applies to protocol version 2 only and
-+is similar to
-+.Cm RhostsRSAAuthentication .
-+.It Cm HostbasedKeyTypes
-+Specifies the key types that will be used for hostbased authentication
-+as a comma-separated pattern list.
-+Alternately if the specified value begins with a
-+.Sq +
-+character, then the specified key types will be appended to the default set
-+instead of replacing them.
-+The default for this option is:
-+.Bd -literal -offset 3n
-+ecdsa-sha2-nistp256-cert-v01@openssh.com,
-+ecdsa-sha2-nistp384-cert-v01@openssh.com,
-+ecdsa-sha2-nistp521-cert-v01@openssh.com,
-+ssh-ed25519-cert-v01@openssh.com,
-+ssh-rsa-cert-v01@openssh.com,
-+ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
-+ssh-ed25519,ssh-rsa
-+.Ed
-+.Pp
-+The
-+.Fl Q
-+option of
-+.Xr ssh 1
-+may be used to list supported key types.
-+.It Cm HostKeyAlgorithms
-+Specifies the protocol version 2 host key algorithms
-+that the client wants to use in order of preference.
-+Alternately if the specified value begins with a
-+.Sq +
-+character, then the specified key types will be appended to the default set
-+instead of replacing them.
-+The default for this option is:
-+.Bd -literal -offset 3n
-+ecdsa-sha2-nistp256-cert-v01@openssh.com,
-+ecdsa-sha2-nistp384-cert-v01@openssh.com,
-+ecdsa-sha2-nistp521-cert-v01@openssh.com,
-+ssh-ed25519-cert-v01@openssh.com,
-+ssh-rsa-cert-v01@openssh.com,
-+ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
-+ssh-ed25519,ssh-rsa
-+.Ed
-+.Pp
-+If hostkeys are known for the destination host then this default is modified
-+to prefer their algorithms.
-+.Pp
-+The list of available key types may also be obtained using the
-+.Fl Q
-+option of
-+.Xr ssh 1
-+with an argument of
-+.Dq key .
-+.It Cm HostKeyAlias
-+Specifies an alias that should be used instead of the
-+real host name when looking up or saving the host key
-+in the host key database files.
-+This option is useful for tunneling SSH connections
-+or for multiple servers running on a single host.
-+.It Cm HostName
-+Specifies the real host name to log into.
-+This can be used to specify nicknames or abbreviations for hosts.
-+If the hostname contains the character sequence
-+.Ql %h ,
-+then this will be replaced with the host name specified on the command line
-+(this is useful for manipulating unqualified names).
-+The character sequence
-+.Ql %%
-+will be replaced by a single
-+.Ql %
-+character, which may be used when specifying IPv6 link-local addresses.
-+.Pp
-+The default is the name given on the command line.
-+Numeric IP addresses are also permitted (both on the command line and in
-+.Cm HostName
-+specifications).
-+.It Cm IdentitiesOnly
-+Specifies that
-+.Xr ssh 1
-+should only use the authentication identity files configured in the
-+.Nm
-+files,
-+even if
-+.Xr ssh-agent 1
-+or a
-+.Cm PKCS11Provider
-+offers more identities.
-+The argument to this keyword must be
-+.Dq yes
-+or
-+.Dq no .
-+This option is intended for situations where ssh-agent
-+offers many different identities.
-+The default is
-+.Dq no .
-+.It Cm IdentityFile
-+Specifies a file from which the user's DSA, ECDSA, Ed25519 or RSA authentication
-+identity is read.
-+The default is
-+.Pa ~/.ssh/identity
-+for protocol version 1, and
-+.Pa ~/.ssh/id_dsa ,
-+.Pa ~/.ssh/id_ecdsa ,
-+.Pa ~/.ssh/id_ed25519
-+and
-+.Pa ~/.ssh/id_rsa
-+for protocol version 2.
-+Additionally, any identities represented by the authentication agent
-+will be used for authentication unless
-+.Cm IdentitiesOnly
-+is set.
-+.Xr ssh 1
-+will try to load certificate information from the filename obtained by
-+appending
-+.Pa -cert.pub
-+to the path of a specified
-+.Cm IdentityFile .
-+.Pp
-+The file name may use the tilde
-+syntax to refer to a user's home directory or one of the following
-+escape characters:
-+.Ql %d
-+(local user's home directory),
-+.Ql %u
-+(local user name),
-+.Ql %l
-+(local host name),
-+.Ql %h
-+(remote host name) or
-+.Ql %r
-+(remote user name).
-+.Pp
-+It is possible to have
-+multiple identity files specified in configuration files; all these
-+identities will be tried in sequence.
-+Multiple
-+.Cm IdentityFile
-+directives will add to the list of identities tried (this behaviour
-+differs from that of other configuration directives).
-+.Pp
-+.Cm IdentityFile
-+may be used in conjunction with
-+.Cm IdentitiesOnly
-+to select which identities in an agent are offered during authentication.
-+.It Cm IgnoreUnknown
-+Specifies a pattern-list of unknown options to be ignored if they are
-+encountered in configuration parsing.
-+This may be used to suppress errors if
-+.Nm
-+contains options that are unrecognised by
-+.Xr ssh 1 .
-+It is recommended that
-+.Cm IgnoreUnknown
-+be listed early in the configuration file as it will not be applied
-+to unknown options that appear before it.
-+.It Cm IPQoS
-+Specifies the IPv4 type-of-service or DSCP class for connections.
-+Accepted values are
-+.Dq af11 ,
-+.Dq af12 ,
-+.Dq af13 ,
-+.Dq af21 ,
-+.Dq af22 ,
-+.Dq af23 ,
-+.Dq af31 ,
-+.Dq af32 ,
-+.Dq af33 ,
-+.Dq af41 ,
-+.Dq af42 ,
-+.Dq af43 ,
-+.Dq cs0 ,
-+.Dq cs1 ,
-+.Dq cs2 ,
-+.Dq cs3 ,
-+.Dq cs4 ,
-+.Dq cs5 ,
-+.Dq cs6 ,
-+.Dq cs7 ,
-+.Dq ef ,
-+.Dq lowdelay ,
-+.Dq throughput ,
-+.Dq reliability ,
-+or a numeric value.
-+This option may take one or two arguments, separated by whitespace.
-+If one argument is specified, it is used as the packet class unconditionally.
-+If two values are specified, the first is automatically selected for
-+interactive sessions and the second for non-interactive sessions.
-+The default is
-+.Dq lowdelay
-+for interactive sessions and
-+.Dq throughput
-+for non-interactive sessions.
-+.It Cm KbdInteractiveAuthentication
-+Specifies whether to use keyboard-interactive authentication.
-+The argument to this keyword must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is
-+.Dq yes .
-+.It Cm KbdInteractiveDevices
-+Specifies the list of methods to use in keyboard-interactive authentication.
-+Multiple method names must be comma-separated.
-+The default is to use the server specified list.
-+The methods available vary depending on what the server supports.
-+For an OpenSSH server,
-+it may be zero or more of:
-+.Dq bsdauth ,
-+.Dq pam ,
-+and
-+.Dq skey .
-+.It Cm KexAlgorithms
-+Specifies the available KEX (Key Exchange) algorithms.
-+Multiple algorithms must be comma-separated.
-+Alternately if the specified value begins with a
-+.Sq +
-+character, then the specified methods will be appended to the default set
-+instead of replacing them.
-+The default is:
-+.Bd -literal -offset indent
-+curve25519-sha256@libssh.org,
-+ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,
-+diffie-hellman-group-exchange-sha256,
-+diffie-hellman-group-exchange-sha1,
-+diffie-hellman-group14-sha1
-+.Ed
-+.Pp
-+The list of available key exchange algorithms may also be obtained using the
-+.Fl Q
-+option of
-+.Xr ssh 1
-+with an argument of
-+.Dq kex .
-+.It Cm LocalCommand
-+Specifies a command to execute on the local machine after successfully
-+connecting to the server.
-+The command string extends to the end of the line, and is executed with
-+the user's shell.
-+The following escape character substitutions will be performed:
-+.Ql %d
-+(local user's home directory),
-+.Ql %h
-+(remote host name),
-+.Ql %l
-+(local host name),
-+.Ql %n
-+(host name as provided on the command line),
-+.Ql %p
-+(remote port),
-+.Ql %r
-+(remote user name) or
-+.Ql %u
-+(local user name) or
-+.Ql \&%C
-+by a hash of the concatenation: %l%h%p%r.
-+.Pp
-+The command is run synchronously and does not have access to the
-+session of the
-+.Xr ssh 1
-+that spawned it.
-+It should not be used for interactive commands.
-+.Pp
-+This directive is ignored unless
-+.Cm PermitLocalCommand
-+has been enabled.
-+.It Cm LocalForward
-+Specifies that a TCP port on the local machine be forwarded over
-+the secure channel to the specified host and port from the remote machine.
-+The first argument must be
-+.Sm off
-+.Oo Ar bind_address : Oc Ar port
-+.Sm on
-+and the second argument must be
-+.Ar host : Ns Ar hostport .
-+IPv6 addresses can be specified by enclosing addresses in square brackets.
-+Multiple forwardings may be specified, and additional forwardings can be
-+given on the command line.
-+Only the superuser can forward privileged ports.
-+By default, the local port is bound in accordance with the
-+.Cm GatewayPorts
-+setting.
-+However, an explicit
-+.Ar bind_address
-+may be used to bind the connection to a specific address.
-+The
-+.Ar bind_address
-+of
-+.Dq localhost
-+indicates that the listening port be bound for local use only, while an
-+empty address or
-+.Sq *
-+indicates that the port should be available from all interfaces.
-+.It Cm LogLevel
-+Gives the verbosity level that is used when logging messages from
-+.Xr ssh 1 .
-+The possible values are:
-+QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3.
-+The default is INFO.
-+DEBUG and DEBUG1 are equivalent.
-+DEBUG2 and DEBUG3 each specify higher levels of verbose output.
-+.It Cm MACs
-+Specifies the MAC (message authentication code) algorithms
-+in order of preference.
-+The MAC algorithm is used in protocol version 2
-+for data integrity protection.
-+Multiple algorithms must be comma-separated.
-+If the specified value begins with a
-+.Sq +
-+character, then the specified algorithms will be appended to the default set
-+instead of replacing them.
-+.Pp
-+The algorithms that contain
-+.Dq -etm
-+calculate the MAC after encryption (encrypt-then-mac).
-+These are considered safer and their use recommended.
-+.Pp
-+The default is:
-+.Bd -literal -offset indent
-+umac-64-etm@openssh.com,umac-128-etm@openssh.com,
-+hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,
-+umac-64@openssh.com,umac-128@openssh.com,
-+hmac-sha2-256,hmac-sha2-512,
-+hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,
-+hmac-ripemd160-etm@openssh.com,
-+hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,
-+hmac-md5,hmac-sha1,hmac-ripemd160,
-+hmac-sha1-96,hmac-md5-96
-+.Ed
-+.Pp
-+The list of available MAC algorithms may also be obtained using the
-+.Fl Q
-+option of
-+.Xr ssh 1
-+with an argument of
-+.Dq mac .
-+.It Cm NoHostAuthenticationForLocalhost
-+This option can be used if the home directory is shared across machines.
-+In this case localhost will refer to a different machine on each of
-+the machines and the user will get many warnings about changed host keys.
-+However, this option disables host authentication for localhost.
-+The argument to this keyword must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is to check the host key for localhost.
-+.It Cm NumberOfPasswordPrompts
-+Specifies the number of password prompts before giving up.
-+The argument to this keyword must be an integer.
-+The default is 3.
-+.It Cm PasswordAuthentication
-+Specifies whether to use password authentication.
-+The argument to this keyword must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is
-+.Dq yes .
-+.It Cm PermitLocalCommand
-+Allow local command execution via the
-+.Ic LocalCommand
-+option or using the
-+.Ic !\& Ns Ar command
-+escape sequence in
-+.Xr ssh 1 .
-+The argument must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is
-+.Dq no .
-+.It Cm PKCS11Provider
-+Specifies which PKCS#11 provider to use.
-+The argument to this keyword is the PKCS#11 shared library
-+.Xr ssh 1
-+should use to communicate with a PKCS#11 token providing the user's
-+private RSA key.
-+.It Cm Port
-+Specifies the port number to connect on the remote host.
-+The default is 22.
-+.It Cm PreferredAuthentications
-+Specifies the order in which the client should try protocol 2
-+authentication methods.
-+This allows a client to prefer one method (e.g.\&
-+.Cm keyboard-interactive )
-+over another method (e.g.\&
-+.Cm password ) .
-+The default is:
-+.Bd -literal -offset indent
-+gssapi-with-mic,hostbased,publickey,
-+keyboard-interactive,password
-+.Ed
-+.It Cm Protocol
-+Specifies the protocol versions
-+.Xr ssh 1
-+should support in order of preference.
-+The possible values are
-+.Sq 1
-+and
-+.Sq 2 .
-+Multiple versions must be comma-separated.
-+When this option is set to
-+.Dq 2,1
-+.Nm ssh
-+will try version 2 and fall back to version 1
-+if version 2 is not available.
-+The default is
-+.Sq 2 .
-+.It Cm ProxyCommand
-+Specifies the command to use to connect to the server.
-+The command
-+string extends to the end of the line, and is executed
-+using the user's shell
-+.Ql exec
-+directive to avoid a lingering shell process.
-+.Pp
-+In the command string, any occurrence of
-+.Ql %h
-+will be substituted by the host name to
-+connect,
-+.Ql %p
-+by the port, and
-+.Ql %r
-+by the remote user name.
-+The command can be basically anything,
-+and should read from its standard input and write to its standard output.
-+It should eventually connect an
-+.Xr sshd 8
-+server running on some machine, or execute
-+.Ic sshd -i
-+somewhere.
-+Host key management will be done using the
-+HostName of the host being connected (defaulting to the name typed by
-+the user).
-+Setting the command to
-+.Dq none
-+disables this option entirely.
-+Note that
-+.Cm CheckHostIP
-+is not available for connects with a proxy command.
-+.Pp
-+This directive is useful in conjunction with
-+.Xr nc 1
-+and its proxy support.
-+For example, the following directive would connect via an HTTP proxy at
-+192.0.2.0:
-+.Bd -literal -offset 3n
-+ProxyCommand /usr/bin/nc -X connect -x 192.0.2.0:8080 %h %p
-+.Ed
-+.It Cm ProxyUseFdpass
-+Specifies that
-+.Cm ProxyCommand
-+will pass a connected file descriptor back to
-+.Xr ssh 1
-+instead of continuing to execute and pass data.
-+The default is
-+.Dq no .
-+.It Cm PubkeyAcceptedKeyTypes
-+Specifies the key types that will be used for public key authentication
-+as a comma-separated pattern list.
-+Alternately if the specified value begins with a
-+.Sq +
-+character, then the key types after it will be appended to the default
-+instead of replacing it.
-+The default for this option is:
-+.Bd -literal -offset 3n
-+ecdsa-sha2-nistp256-cert-v01@openssh.com,
-+ecdsa-sha2-nistp384-cert-v01@openssh.com,
-+ecdsa-sha2-nistp521-cert-v01@openssh.com,
-+ssh-ed25519-cert-v01@openssh.com,
-+ssh-rsa-cert-v01@openssh.com,
-+ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
-+ssh-ed25519,ssh-rsa
-+.Ed
-+.Pp
-+The
-+.Fl Q
-+option of
-+.Xr ssh 1
-+may be used to list supported key types.
-+.It Cm PubkeyAuthentication
-+Specifies whether to try public key authentication.
-+The argument to this keyword must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is
-+.Dq yes .
-+This option applies to protocol version 2 only.
-+.It Cm RekeyLimit
-+Specifies the maximum amount of data that may be transmitted before the
-+session key is renegotiated, optionally followed a maximum amount of
-+time that may pass before the session key is renegotiated.
-+The first argument is specified in bytes and may have a suffix of
-+.Sq K ,
-+.Sq M ,
-+or
-+.Sq G
-+to indicate Kilobytes, Megabytes, or Gigabytes, respectively.
-+The default is between
-+.Sq 1G
-+and
-+.Sq 4G ,
-+depending on the cipher.
-+The optional second value is specified in seconds and may use any of the
-+units documented in the
-+TIME FORMATS section of
-+.Xr sshd_config 4 .
-+The default value for
-+.Cm RekeyLimit
-+is
-+.Dq default none ,
-+which means that rekeying is performed after the cipher's default amount
-+of data has been sent or received and no time based rekeying is done.
-+This option applies to protocol version 2 only.
-+.It Cm RemoteForward
-+Specifies that a TCP port on the remote machine be forwarded over
-+the secure channel to the specified host and port from the local machine.
-+The first argument must be
-+.Sm off
-+.Oo Ar bind_address : Oc Ar port
-+.Sm on
-+and the second argument must be
-+.Ar host : Ns Ar hostport .
-+IPv6 addresses can be specified by enclosing addresses in square brackets.
-+Multiple forwardings may be specified, and additional
-+forwardings can be given on the command line.
-+Privileged ports can be forwarded only when
-+logging in as root on the remote machine.
-+.Pp
-+If the
-+.Ar port
-+argument is
-+.Ql 0 ,
-+the listen port will be dynamically allocated on the server and reported
-+to the client at run time.
-+.Pp
-+If the
-+.Ar bind_address
-+is not specified, the default is to only bind to loopback addresses.
-+If the
-+.Ar bind_address
-+is
-+.Ql *
-+or an empty string, then the forwarding is requested to listen on all
-+interfaces.
-+Specifying a remote
-+.Ar bind_address
-+will only succeed if the server's
-+.Cm GatewayPorts
-+option is enabled (see
-+.Xr sshd_config 4 ) .
-+.It Cm RequestTTY
-+Specifies whether to request a pseudo-tty for the session.
-+The argument may be one of:
-+.Dq no
-+(never request a TTY),
-+.Dq yes
-+(always request a TTY when standard input is a TTY),
-+.Dq force
-+(always request a TTY) or
-+.Dq auto
-+(request a TTY when opening a login session).
-+This option mirrors the
-+.Fl t
-+and
-+.Fl T
-+flags for
-+.Xr ssh 1 .
-+.It Cm RevokedHostKeys
-+Specifies revoked host public keys.
-+Keys listed in this file will be refused for host authentication.
-+Note that if this file does not exist or is not readable,
-+then host authentication will be refused for all hosts.
-+Keys may be specified as a text file, listing one public key per line, or as
-+an OpenSSH Key Revocation List (KRL) as generated by
-+.Xr ssh-keygen 1 .
-+For more information on KRLs, see the KEY REVOCATION LISTS section in
-+.Xr ssh-keygen 1 .
-+.It Cm RhostsRSAAuthentication
-+Specifies whether to try rhosts based authentication with RSA host
-+authentication.
-+The argument must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is
-+.Dq no .
-+This option applies to protocol version 1 only and requires
-+.Xr ssh 1
-+to be setuid root.
-+.It Cm RSAAuthentication
-+Specifies whether to try RSA authentication.
-+The argument to this keyword must be
-+.Dq yes
-+or
-+.Dq no .
-+RSA authentication will only be
-+attempted if the identity file exists, or an authentication agent is
-+running.
-+The default is
-+.Dq yes .
-+Note that this option applies to protocol version 1 only.
-+.It Cm SendEnv
-+Specifies what variables from the local
-+.Xr environ 7
-+should be sent to the server.
-+Note that environment passing is only supported for protocol 2.
-+The server must also support it, and the server must be configured to
-+accept these environment variables.
-+Note that the
-+.Ev TERM
-+environment variable is always sent whenever a
-+pseudo-terminal is requested as it is required by the protocol.
-+Refer to
-+.Cm AcceptEnv
-+in
-+.Xr sshd_config 4
-+for how to configure the server.
-+Variables are specified by name, which may contain wildcard characters.
-+Multiple environment variables may be separated by whitespace or spread
-+across multiple
-+.Cm SendEnv
-+directives.
-+The default is not to send any environment variables.
-+.Pp
-+See
-+.Sx PATTERNS
-+for more information on patterns.
-+.It Cm ServerAliveCountMax
-+Sets the number of server alive messages (see below) which may be
-+sent without
-+.Xr ssh 1
-+receiving any messages back from the server.
-+If this threshold is reached while server alive messages are being sent,
-+ssh will disconnect from the server, terminating the session.
-+It is important to note that the use of server alive messages is very
-+different from
-+.Cm TCPKeepAlive
-+(below).
-+The server alive messages are sent through the encrypted channel
-+and therefore will not be spoofable.
-+The TCP keepalive option enabled by
-+.Cm TCPKeepAlive
-+is spoofable.
-+The server alive mechanism is valuable when the client or
-+server depend on knowing when a connection has become inactive.
-+.Pp
-+The default value is 3.
-+If, for example,
-+.Cm ServerAliveInterval
-+(see below) is set to 15 and
-+.Cm ServerAliveCountMax
-+is left at the default, if the server becomes unresponsive,
-+ssh will disconnect after approximately 45 seconds.
-+This option applies to protocol version 2 only.
-+.It Cm ServerAliveInterval
-+Sets a timeout interval in seconds after which if no data has been received
-+from the server,
-+.Xr ssh 1
-+will send a message through the encrypted
-+channel to request a response from the server.
-+The default
-+is 0, indicating that these messages will not be sent to the server.
-+This option applies to protocol version 2 only.
-+.It Cm StreamLocalBindMask
-+Sets the octal file creation mode mask
-+.Pq umask
-+used when creating a Unix-domain socket file for local or remote
-+port forwarding.
-+This option is only used for port forwarding to a Unix-domain socket file.
-+.Pp
-+The default value is 0177, which creates a Unix-domain socket file that is
-+readable and writable only by the owner.
-+Note that not all operating systems honor the file mode on Unix-domain
-+socket files.
-+.It Cm StreamLocalBindUnlink
-+Specifies whether to remove an existing Unix-domain socket file for local
-+or remote port forwarding before creating a new one.
-+If the socket file already exists and
-+.Cm StreamLocalBindUnlink
-+is not enabled,
-+.Nm ssh
-+will be unable to forward the port to the Unix-domain socket file.
-+This option is only used for port forwarding to a Unix-domain socket file.
-+.Pp
-+The argument must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is
-+.Dq no .
-+.It Cm StrictHostKeyChecking
-+If this flag is set to
-+.Dq yes ,
-+.Xr ssh 1
-+will never automatically add host keys to the
-+.Pa ~/.ssh/known_hosts
-+file, and refuses to connect to hosts whose host key has changed.
-+This provides maximum protection against trojan horse attacks,
-+though it can be annoying when the
-+.Pa /etc/ssh/ssh_known_hosts
-+file is poorly maintained or when connections to new hosts are
-+frequently made.
-+This option forces the user to manually
-+add all new hosts.
-+If this flag is set to
-+.Dq no ,
-+ssh will automatically add new host keys to the
-+user known hosts files.
-+If this flag is set to
-+.Dq ask ,
-+new host keys
-+will be added to the user known host files only after the user
-+has confirmed that is what they really want to do, and
-+ssh will refuse to connect to hosts whose host key has changed.
-+The host keys of
-+known hosts will be verified automatically in all cases.
-+The argument must be
-+.Dq yes ,
-+.Dq no ,
-+or
-+.Dq ask .
-+The default is
-+.Dq ask .
-+.It Cm TCPKeepAlive
-+Specifies whether the system should send TCP keepalive messages to the
-+other side.
-+If they are sent, death of the connection or crash of one
-+of the machines will be properly noticed.
-+However, this means that
-+connections will die if the route is down temporarily, and some people
-+find it annoying.
-+.Pp
-+The default is
-+.Dq yes
-+(to send TCP keepalive messages), and the client will notice
-+if the network goes down or the remote host dies.
-+This is important in scripts, and many users want it too.
-+.Pp
-+To disable TCP keepalive messages, the value should be set to
-+.Dq no .
-+.It Cm Tunnel
-+Request
-+.Xr tun 4
-+device forwarding between the client and the server.
-+The argument must be
-+.Dq yes ,
-+.Dq point-to-point
-+(layer 3),
-+.Dq ethernet
-+(layer 2),
-+or
-+.Dq no .
-+Specifying
-+.Dq yes
-+requests the default tunnel mode, which is
-+.Dq point-to-point .
-+The default is
-+.Dq no .
-+.It Cm TunnelDevice
-+Specifies the
-+.Xr tun 4
-+devices to open on the client
-+.Pq Ar local_tun
-+and the server
-+.Pq Ar remote_tun .
-+.Pp
-+The argument must be
-+.Sm off
-+.Ar local_tun Op : Ar remote_tun .
-+.Sm on
-+The devices may be specified by numerical ID or the keyword
-+.Dq any ,
-+which uses the next available tunnel device.
-+If
-+.Ar remote_tun
-+is not specified, it defaults to
-+.Dq any .
-+The default is
-+.Dq any:any .
-+.It Cm UpdateHostKeys
-+Specifies whether
-+.Xr ssh 1
-+should accept notifications of additional hostkeys from the server sent
-+after authentication has completed and add them to
-+.Cm UserKnownHostsFile .
-+The argument must be
-+.Dq yes ,
-+.Dq no
-+(the default) or
-+.Dq ask .
-+Enabling this option allows learning alternate hostkeys for a server
-+and supports graceful key rotation by allowing a server to send replacement
-+public keys before old ones are removed.
-+Additional hostkeys are only accepted if the key used to authenticate the
-+host was already trusted or explicity accepted by the user.
-+If
-+.Cm UpdateHostKeys
-+is set to
-+.Dq ask ,
-+then the user is asked to confirm the modifications to the known_hosts file.
-+Confirmation is currently incompatible with
-+.Cm ControlPersist ,
-+and will be disabled if it is enabled.
-+.Pp
-+Presently, only
-+.Xr sshd 8
-+from OpenSSH 6.8 and greater support the
-+.Dq hostkeys@openssh.com
-+protocol extension used to inform the client of all the server's hostkeys.
-+.It Cm UsePrivilegedPort
-+Specifies whether to use a privileged port for outgoing connections.
-+The argument must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is
-+.Dq no .
-+If set to
-+.Dq yes ,
-+.Xr ssh 1
-+must be setuid root.
-+Note that this option must be set to
-+.Dq yes
-+for
-+.Cm RhostsRSAAuthentication
-+with older servers.
-+.It Cm User
-+Specifies the user to log in as.
-+This can be useful when a different user name is used on different machines.
-+This saves the trouble of
-+having to remember to give the user name on the command line.
-+.It Cm UserKnownHostsFile
-+Specifies one or more files to use for the user
-+host key database, separated by whitespace.
-+The default is
-+.Pa ~/.ssh/known_hosts ,
-+.Pa ~/.ssh/known_hosts2 .
-+.It Cm VerifyHostKeyDNS
-+Specifies whether to verify the remote key using DNS and SSHFP resource
-+records.
-+If this option is set to
-+.Dq yes ,
-+the client will implicitly trust keys that match a secure fingerprint
-+from DNS.
-+Insecure fingerprints will be handled as if this option was set to
-+.Dq ask .
-+If this option is set to
-+.Dq ask ,
-+information on fingerprint match will be displayed, but the user will still
-+need to confirm new host keys according to the
-+.Cm StrictHostKeyChecking
-+option.
-+The argument must be
-+.Dq yes ,
-+.Dq no ,
-+or
-+.Dq ask .
-+The default is
-+.Dq no .
-+Note that this option applies to protocol version 2 only.
-+.Pp
-+See also VERIFYING HOST KEYS in
-+.Xr ssh 1 .
-+.It Cm VisualHostKey
-+If this flag is set to
-+.Dq yes ,
-+an ASCII art representation of the remote host key fingerprint is
-+printed in addition to the fingerprint string at login and
-+for unknown host keys.
-+If this flag is set to
-+.Dq no ,
-+no fingerprint strings are printed at login and
-+only the fingerprint string will be printed for unknown host keys.
-+The default is
-+.Dq no .
-+.It Cm XAuthLocation
-+Specifies the full pathname of the
-+.Xr xauth 1
-+program.
-+The default is
-+.Pa /usr/X11R6/bin/xauth .
-+.El
-+.Sh PATTERNS
-+A
-+.Em pattern
-+consists of zero or more non-whitespace characters,
-+.Sq *
-+(a wildcard that matches zero or more characters),
-+or
-+.Sq ?\&
-+(a wildcard that matches exactly one character).
-+For example, to specify a set of declarations for any host in the
-+.Dq .co.uk
-+set of domains,
-+the following pattern could be used:
-+.Pp
-+.Dl Host *.co.uk
-+.Pp
-+The following pattern
-+would match any host in the 192.168.0.[0-9] network range:
-+.Pp
-+.Dl Host 192.168.0.?
-+.Pp
-+A
-+.Em pattern-list
-+is a comma-separated list of patterns.
-+Patterns within pattern-lists may be negated
-+by preceding them with an exclamation mark
-+.Pq Sq !\& .
-+For example,
-+to allow a key to be used from anywhere within an organization
-+except from the
-+.Dq dialup
-+pool,
-+the following entry (in authorized_keys) could be used:
-+.Pp
-+.Dl from=\&"!*.dialup.example.com,*.example.com\&"
-+.Sh FILES
-+.Bl -tag -width Ds
-+.It Pa ~/.ssh/config
-+This is the per-user configuration file.
-+The format of this file is described above.
-+This file is used by the SSH client.
-+Because of the potential for abuse, this file must have strict permissions:
-+read/write for the user, and not accessible by others.
-+.It Pa /etc/ssh/ssh_config
-+Systemwide configuration file.
-+This file provides defaults for those
-+values that are not specified in the user's configuration file, and
-+for those users who do not have a configuration file.
-+This file must be world-readable.
-+.El
-+.Sh SEE ALSO
-+.Xr ssh 1
-+.Sh AUTHORS
-+OpenSSH is a derivative of the original and free
-+ssh 1.2.12 release by Tatu Ylonen.
-+Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
-+Theo de Raadt and Dug Song
-+removed many bugs, re-added newer features and
-+created OpenSSH.
-+Markus Friedl contributed the support for SSH
-+protocol versions 1.5 and 2.0.
-diff --git a/ssh_config.5 b/ssh_config.5
-deleted file mode 100644
-index a47f3ca..0000000
---- a/ssh_config.5
-+++ /dev/null
-@@ -1,1726 +0,0 @@
--.\"
--.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
--.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
--.\"                    All rights reserved
--.\"
--.\" As far as I am concerned, the code I have written for this software
--.\" can be used freely for any purpose.  Any derived versions of this
--.\" software must be clearly marked as such, and if the derived work is
--.\" incompatible with the protocol description in the RFC file, it must be
--.\" called by a name other than "ssh" or "Secure Shell".
--.\"
--.\" Copyright (c) 1999,2000 Markus Friedl.  All rights reserved.
--.\" Copyright (c) 1999 Aaron Campbell.  All rights reserved.
--.\" Copyright (c) 1999 Theo de Raadt.  All rights reserved.
--.\"
--.\" Redistribution and use in source and binary forms, with or without
--.\" modification, are permitted provided that the following conditions
--.\" are met:
--.\" 1. Redistributions of source code must retain the above copyright
--.\"    notice, this list of conditions and the following disclaimer.
--.\" 2. Redistributions in binary form must reproduce the above copyright
--.\"    notice, this list of conditions and the following disclaimer in the
--.\"    documentation and/or other materials provided with the distribution.
--.\"
--.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
--.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
--.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
--.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
--.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
--.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
--.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
--.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
--.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
--.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--.\"
--.\" $OpenBSD: ssh_config.5,v 1.215 2015/08/14 15:32:41 jmc Exp $
--.Dd $Mdocdate: August 14 2015 $
--.Dt SSH_CONFIG 5
--.Os
--.Sh NAME
--.Nm ssh_config
--.Nd OpenSSH SSH client configuration files
--.Sh SYNOPSIS
--.Nm ~/.ssh/config
--.Nm /etc/ssh/ssh_config
--.Sh DESCRIPTION
--.Xr ssh 1
--obtains configuration data from the following sources in
--the following order:
--.Pp
--.Bl -enum -offset indent -compact
--.It
--command-line options
--.It
--user's configuration file
--.Pq Pa ~/.ssh/config
--.It
--system-wide configuration file
--.Pq Pa /etc/ssh/ssh_config
--.El
--.Pp
--For each parameter, the first obtained value
--will be used.
--The configuration files contain sections separated by
--.Dq Host
--specifications, and that section is only applied for hosts that
--match one of the patterns given in the specification.
--The matched host name is usually the one given on the command line
--(see the
--.Cm CanonicalizeHostname
--option for exceptions.)
--.Pp
--Since the first obtained value for each parameter is used, more
--host-specific declarations should be given near the beginning of the
--file, and general defaults at the end.
--.Pp
--The configuration file has the following format:
--.Pp
--Empty lines and lines starting with
--.Ql #
--are comments.
--Otherwise a line is of the format
--.Dq keyword arguments .
--Configuration options may be separated by whitespace or
--optional whitespace and exactly one
--.Ql = ;
--the latter format is useful to avoid the need to quote whitespace
--when specifying configuration options using the
--.Nm ssh ,
--.Nm scp ,
--and
--.Nm sftp
--.Fl o
--option.
--Arguments may optionally be enclosed in double quotes
--.Pq \&"
--in order to represent arguments containing spaces.
--.Pp
--The possible
--keywords and their meanings are as follows (note that
--keywords are case-insensitive and arguments are case-sensitive):
--.Bl -tag -width Ds
--.It Cm Host
--Restricts the following declarations (up to the next
--.Cm Host
--or
--.Cm Match
--keyword) to be only for those hosts that match one of the patterns
--given after the keyword.
--If more than one pattern is provided, they should be separated by whitespace.
--A single
--.Ql *
--as a pattern can be used to provide global
--defaults for all hosts.
--The host is usually the
--.Ar hostname
--argument given on the command line
--(see the
--.Cm CanonicalizeHostname
--option for exceptions.)
--.Pp
--A pattern entry may be negated by prefixing it with an exclamation mark
--.Pq Sq !\& .
--If a negated entry is matched, then the
--.Cm Host
--entry is ignored, regardless of whether any other patterns on the line
--match.
--Negated matches are therefore useful to provide exceptions for wildcard
--matches.
--.Pp
--See
--.Sx PATTERNS
--for more information on patterns.
--.It Cm Match
--Restricts the following declarations (up to the next
--.Cm Host
--or
--.Cm Match
--keyword) to be used only when the conditions following the
--.Cm Match
--keyword are satisfied.
--Match conditions are specified using one or more critera
--or the single token
--.Cm all
--which always matches.
--The available criteria keywords are:
--.Cm canonical ,
--.Cm exec ,
--.Cm host ,
--.Cm originalhost ,
--.Cm user ,
--and
--.Cm localuser .
--The
--.Cm all
--criteria must appear alone or immediately after
--.Cm canonical .
--Other criteria may be combined arbitrarily.
--All criteria but
--.Cm all
--and
--.Cm canonical
--require an argument.
--Criteria may be negated by prepending an exclamation mark
--.Pq Sq !\& .
--.Pp
--The
--.Cm canonical
--keyword matches only when the configuration file is being re-parsed
--after hostname canonicalization (see the
--.Cm CanonicalizeHostname
--option.)
--This may be useful to specify conditions that work with canonical host
--names only.
--The
--.Cm exec
--keyword executes the specified command under the user's shell.
--If the command returns a zero exit status then the condition is considered true.
--Commands containing whitespace characters must be quoted.
--The following character sequences in the command will be expanded prior to
--execution:
--.Ql %L
--will be substituted by the first component of the local host name,
--.Ql %l
--will be substituted by the local host name (including any domain name),
--.Ql %h
--will be substituted by the target host name,
--.Ql %n
--will be substituted by the original target host name
--specified on the command-line,
--.Ql %p
--the destination port,
--.Ql %r
--by the remote login username, and
--.Ql %u
--by the username of the user running
--.Xr ssh 1 .
--.Pp
--The other keywords' criteria must be single entries or comma-separated
--lists and may use the wildcard and negation operators described in the
--.Sx PATTERNS
--section.
--The criteria for the
--.Cm host
--keyword are matched against the target hostname, after any substitution
--by the
--.Cm Hostname
--or
--.Cm CanonicalizeHostname
--options.
--The
--.Cm originalhost
--keyword matches against the hostname as it was specified on the command-line.
--The
--.Cm user
--keyword matches against the target username on the remote host.
--The
--.Cm localuser
--keyword matches against the name of the local user running
--.Xr ssh 1
--(this keyword may be useful in system-wide
--.Nm
--files).
--.It Cm AddressFamily
--Specifies which address family to use when connecting.
--Valid arguments are
--.Dq any ,
--.Dq inet
--(use IPv4 only), or
--.Dq inet6
--(use IPv6 only).
--.It Cm BatchMode
--If set to
--.Dq yes ,
--passphrase/password querying will be disabled.
--This option is useful in scripts and other batch jobs where no user
--is present to supply the password.
--The argument must be
--.Dq yes
--or
--.Dq no .
--The default is
--.Dq no .
--.It Cm BindAddress
--Use the specified address on the local machine as the source address of
--the connection.
--Only useful on systems with more than one address.
--Note that this option does not work if
--.Cm UsePrivilegedPort
--is set to
--.Dq yes .
--.It Cm CanonicalDomains
--When
--.Cm CanonicalizeHostname
--is enabled, this option specifies the list of domain suffixes in which to
--search for the specified destination host.
--.It Cm CanonicalizeFallbackLocal
--Specifies whether to fail with an error when hostname canonicalization fails.
--The default,
--.Dq yes ,
--will attempt to look up the unqualified hostname using the system resolver's
--search rules.
--A value of
--.Dq no
--will cause
--.Xr ssh 1
--to fail instantly if
--.Cm CanonicalizeHostname
--is enabled and the target hostname cannot be found in any of the domains
--specified by
--.Cm CanonicalDomains .
--.It Cm CanonicalizeHostname
--Controls whether explicit hostname canonicalization is performed.
--The default,
--.Dq no ,
--is not to perform any name rewriting and let the system resolver handle all
--hostname lookups.
--If set to
--.Dq yes
--then, for connections that do not use a
--.Cm ProxyCommand ,
--.Xr ssh 1
--will attempt to canonicalize the hostname specified on the command line
--using the
--.Cm CanonicalDomains
--suffixes and
--.Cm CanonicalizePermittedCNAMEs
--rules.
--If
--.Cm CanonicalizeHostname
--is set to
--.Dq always ,
--then canonicalization is applied to proxied connections too.
--.Pp
--If this option is enabled, then the configuration files are processed
--again using the new target name to pick up any new configuration in matching
--.Cm Host
--and
--.Cm Match
--stanzas.
--.It Cm CanonicalizeMaxDots
--Specifies the maximum number of dot characters in a hostname before
--canonicalization is disabled.
--The default,
--.Dq 1 ,
--allows a single dot (i.e. hostname.subdomain).
--.It Cm CanonicalizePermittedCNAMEs
--Specifies rules to determine whether CNAMEs should be followed when
--canonicalizing hostnames.
--The rules consist of one or more arguments of
--.Ar source_domain_list : Ns Ar target_domain_list ,
--where
--.Ar source_domain_list
--is a pattern-list of domains that may follow CNAMEs in canonicalization,
--and
--.Ar target_domain_list
--is a pattern-list of domains that they may resolve to.
--.Pp
--For example,
--.Dq *.a.example.com:*.b.example.com,*.c.example.com
--will allow hostnames matching
--.Dq *.a.example.com
--to be canonicalized to names in the
--.Dq *.b.example.com
--or
--.Dq *.c.example.com
--domains.
--.It Cm ChallengeResponseAuthentication
--Specifies whether to use challenge-response authentication.
--The argument to this keyword must be
--.Dq yes
--or
--.Dq no .
--The default is
--.Dq yes .
--.It Cm CheckHostIP
--If this flag is set to
--.Dq yes ,
--.Xr ssh 1
--will additionally check the host IP address in the
--.Pa known_hosts
--file.
--This allows ssh to detect if a host key changed due to DNS spoofing
--and will add addresses of destination hosts to
--.Pa ~/.ssh/known_hosts
--in the process, regardless of the setting of
--.Cm StrictHostKeyChecking .
--If the option is set to
--.Dq no ,
--the check will not be executed.
--The default is
--.Dq yes .
--.It Cm Cipher
--Specifies the cipher to use for encrypting the session
--in protocol version 1.
--Currently,
--.Dq blowfish ,
--.Dq 3des ,
--and
--.Dq des
--are supported.
--.Ar des
--is only supported in the
--.Xr ssh 1
--client for interoperability with legacy protocol 1 implementations
--that do not support the
--.Ar 3des
--cipher.
--Its use is strongly discouraged due to cryptographic weaknesses.
--The default is
--.Dq 3des .
--.It Cm Ciphers
--Specifies the ciphers allowed for protocol version 2
--in order of preference.
--Multiple ciphers must be comma-separated.
--If the specified value begins with a
--.Sq +
--character, then the specified ciphers will be appended to the default set
--instead of replacing them.
--.Pp
--The supported ciphers are:
--.Pp
--.Bl -item -compact -offset indent
--.It
--3des-cbc
--.It
--aes128-cbc
--.It
--aes192-cbc
--.It
--aes256-cbc
--.It
--aes128-ctr
--.It
--aes192-ctr
--.It
--aes256-ctr
--.It
--aes128-gcm@openssh.com
--.It
--aes256-gcm@openssh.com
--.It
--arcfour
--.It
--arcfour128
--.It
--arcfour256
--.It
--blowfish-cbc
--.It
--cast128-cbc
--.It
--chacha20-poly1305@openssh.com
--.El
--.Pp
--The default is:
--.Bd -literal -offset indent
--chacha20-poly1305@openssh.com,
--aes128-ctr,aes192-ctr,aes256-ctr,
--aes128-gcm@openssh.com,aes256-gcm@openssh.com,
--arcfour256,arcfour128,
--aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,
--aes192-cbc,aes256-cbc,arcfour
--.Ed
--.Pp
--The list of available ciphers may also be obtained using the
--.Fl Q
--option of
--.Xr ssh 1
--with an argument of
--.Dq cipher .
--.It Cm ClearAllForwardings
--Specifies that all local, remote, and dynamic port forwardings
--specified in the configuration files or on the command line be
--cleared.
--This option is primarily useful when used from the
--.Xr ssh 1
--command line to clear port forwardings set in
--configuration files, and is automatically set by
--.Xr scp 1
--and
--.Xr sftp 1 .
--The argument must be
--.Dq yes
--or
--.Dq no .
--The default is
--.Dq no .
--.It Cm Compression
--Specifies whether to use compression.
--The argument must be
--.Dq yes
--or
--.Dq no .
--The default is
--.Dq no .
--.It Cm CompressionLevel
--Specifies the compression level to use if compression is enabled.
--The argument must be an integer from 1 (fast) to 9 (slow, best).
--The default level is 6, which is good for most applications.
--The meaning of the values is the same as in
--.Xr gzip 1 .
--Note that this option applies to protocol version 1 only.
--.It Cm ConnectionAttempts
--Specifies the number of tries (one per second) to make before exiting.
--The argument must be an integer.
--This may be useful in scripts if the connection sometimes fails.
--The default is 1.
--.It Cm ConnectTimeout
--Specifies the timeout (in seconds) used when connecting to the
--SSH server, instead of using the default system TCP timeout.
--This value is used only when the target is down or really unreachable,
--not when it refuses the connection.
--.It Cm ControlMaster
--Enables the sharing of multiple sessions over a single network connection.
--When set to
--.Dq yes ,
--.Xr ssh 1
--will listen for connections on a control socket specified using the
--.Cm ControlPath
--argument.
--Additional sessions can connect to this socket using the same
--.Cm ControlPath
--with
--.Cm ControlMaster
--set to
--.Dq no
--(the default).
--These sessions will try to reuse the master instance's network connection
--rather than initiating new ones, but will fall back to connecting normally
--if the control socket does not exist, or is not listening.
--.Pp
--Setting this to
--.Dq ask
--will cause ssh
--to listen for control connections, but require confirmation using
--.Xr ssh-askpass 1 .
--If the
--.Cm ControlPath
--cannot be opened,
--ssh will continue without connecting to a master instance.
--.Pp
--X11 and
--.Xr ssh-agent 1
--forwarding is supported over these multiplexed connections, however the
--display and agent forwarded will be the one belonging to the master
--connection i.e. it is not possible to forward multiple displays or agents.
--.Pp
--Two additional options allow for opportunistic multiplexing: try to use a
--master connection but fall back to creating a new one if one does not already
--exist.
--These options are:
--.Dq auto
--and
--.Dq autoask .
--The latter requires confirmation like the
--.Dq ask
--option.
--.It Cm ControlPath
--Specify the path to the control socket used for connection sharing as described
--in the
--.Cm ControlMaster
--section above or the string
--.Dq none
--to disable connection sharing.
--In the path,
--.Ql %L
--will be substituted by the first component of the local host name,
--.Ql %l
--will be substituted by the local host name (including any domain name),
--.Ql %h
--will be substituted by the target host name,
--.Ql %n
--will be substituted by the original target host name
--specified on the command line,
--.Ql %p
--the destination port,
--.Ql %r
--by the remote login username,
--.Ql %u
--by the username of the user running
--.Xr ssh 1 , and
--.Ql \&%C
--by a hash of the concatenation: %l%h%p%r.
--It is recommended that any
--.Cm ControlPath
--used for opportunistic connection sharing include
--at least %h, %p, and %r (or alternatively %C) and be placed in a directory
--that is not writable by other users.
--This ensures that shared connections are uniquely identified.
--.It Cm ControlPersist
--When used in conjunction with
--.Cm ControlMaster ,
--specifies that the master connection should remain open
--in the background (waiting for future client connections)
--after the initial client connection has been closed.
--If set to
--.Dq no ,
--then the master connection will not be placed into the background,
--and will close as soon as the initial client connection is closed.
--If set to
--.Dq yes
--or
--.Dq 0 ,
--then the master connection will remain in the background indefinitely
--(until killed or closed via a mechanism such as the
--.Xr ssh 1
--.Dq Fl O No exit
--option).
--If set to a time in seconds, or a time in any of the formats documented in
--.Xr sshd_config 5 ,
--then the backgrounded master connection will automatically terminate
--after it has remained idle (with no client connections) for the
--specified time.
--.It Cm DynamicForward
--Specifies that a TCP port on the local machine be forwarded
--over the secure channel, and the application
--protocol is then used to determine where to connect to from the
--remote machine.
--.Pp
--The argument must be
--.Sm off
--.Oo Ar bind_address : Oc Ar port .
--.Sm on
--IPv6 addresses can be specified by enclosing addresses in square brackets.
--By default, the local port is bound in accordance with the
--.Cm GatewayPorts
--setting.
--However, an explicit
--.Ar bind_address
--may be used to bind the connection to a specific address.
--The
--.Ar bind_address
--of
--.Dq localhost
--indicates that the listening port be bound for local use only, while an
--empty address or
--.Sq *
--indicates that the port should be available from all interfaces.
--.Pp
--Currently the SOCKS4 and SOCKS5 protocols are supported, and
--.Xr ssh 1
--will act as a SOCKS server.
--Multiple forwardings may be specified, and
--additional forwardings can be given on the command line.
--Only the superuser can forward privileged ports.
--.It Cm EnableSSHKeysign
--Setting this option to
--.Dq yes
--in the global client configuration file
--.Pa /etc/ssh/ssh_config
--enables the use of the helper program
--.Xr ssh-keysign 8
--during
--.Cm HostbasedAuthentication .
--The argument must be
--.Dq yes
--or
--.Dq no .
--The default is
--.Dq no .
--This option should be placed in the non-hostspecific section.
--See
--.Xr ssh-keysign 8
--for more information.
--.It Cm EscapeChar
--Sets the escape character (default:
--.Ql ~ ) .
--The escape character can also
--be set on the command line.
--The argument should be a single character,
--.Ql ^
--followed by a letter, or
--.Dq none
--to disable the escape
--character entirely (making the connection transparent for binary
--data).
--.It Cm ExitOnForwardFailure
--Specifies whether
--.Xr ssh 1
--should terminate the connection if it cannot set up all requested
--dynamic, tunnel, local, and remote port forwardings.
--The argument must be
--.Dq yes
--or
--.Dq no .
--The default is
--.Dq no .
--.It Cm FingerprintHash
--Specifies the hash algorithm used when displaying key fingerprints.
--Valid options are:
--.Dq md5
--and
--.Dq sha256 .
--The default is
--.Dq sha256 .
--.It Cm ForwardAgent
--Specifies whether the connection to the authentication agent (if any)
--will be forwarded to the remote machine.
--The argument must be
--.Dq yes
--or
--.Dq no .
--The default is
--.Dq no .
--.Pp
--Agent forwarding should be enabled with caution.
--Users with the ability to bypass file permissions on the remote host
--(for the agent's Unix-domain socket)
--can access the local agent through the forwarded connection.
--An attacker cannot obtain key material from the agent,
--however they can perform operations on the keys that enable them to
--authenticate using the identities loaded into the agent.
--.It Cm ForwardX11
--Specifies whether X11 connections will be automatically redirected
--over the secure channel and
--.Ev DISPLAY
--set.
--The argument must be
--.Dq yes
--or
--.Dq no .
--The default is
--.Dq no .
--.Pp
--X11 forwarding should be enabled with caution.
--Users with the ability to bypass file permissions on the remote host
--(for the user's X11 authorization database)
--can access the local X11 display through the forwarded connection.
--An attacker may then be able to perform activities such as keystroke monitoring
--if the
--.Cm ForwardX11Trusted
--option is also enabled.
--.It Cm ForwardX11Timeout
--Specify a timeout for untrusted X11 forwarding
--using the format described in the
--TIME FORMATS section of
--.Xr sshd_config 5 .
--X11 connections received by
--.Xr ssh 1
--after this time will be refused.
--The default is to disable untrusted X11 forwarding after twenty minutes has
--elapsed.
--.It Cm ForwardX11Trusted
--If this option is set to
--.Dq yes ,
--remote X11 clients will have full access to the original X11 display.
--.Pp
--If this option is set to
--.Dq no ,
--remote X11 clients will be considered untrusted and prevented
--from stealing or tampering with data belonging to trusted X11
--clients.
--Furthermore, the
--.Xr xauth 1
--token used for the session will be set to expire after 20 minutes.
--Remote clients will be refused access after this time.
--.Pp
--The default is
--.Dq no .
--.Pp
--See the X11 SECURITY extension specification for full details on
--the restrictions imposed on untrusted clients.
--.It Cm GatewayPorts
--Specifies whether remote hosts are allowed to connect to local
--forwarded ports.
--By default,
--.Xr ssh 1
--binds local port forwardings to the loopback address.
--This prevents other remote hosts from connecting to forwarded ports.
--.Cm GatewayPorts
--can be used to specify that ssh
--should bind local port forwardings to the wildcard address,
--thus allowing remote hosts to connect to forwarded ports.
--The argument must be
--.Dq yes
--or
--.Dq no .
--The default is
--.Dq no .
--.It Cm GlobalKnownHostsFile
--Specifies one or more files to use for the global
--host key database, separated by whitespace.
--The default is
--.Pa /etc/ssh/ssh_known_hosts ,
--.Pa /etc/ssh/ssh_known_hosts2 .
--.It Cm GSSAPIAuthentication
--Specifies whether user authentication based on GSSAPI is allowed.
--The default is
--.Dq no .
--Note that this option applies to protocol version 2 only.
--.It Cm GSSAPIDelegateCredentials
--Forward (delegate) credentials to the server.
--The default is
--.Dq no .
--Note that this option applies to protocol version 2 only.
--.It Cm HashKnownHosts
--Indicates that
--.Xr ssh 1
--should hash host names and addresses when they are added to
--.Pa ~/.ssh/known_hosts .
--These hashed names may be used normally by
--.Xr ssh 1
--and
--.Xr sshd 8 ,
--but they do not reveal identifying information should the file's contents
--be disclosed.
--The default is
--.Dq no .
--Note that existing names and addresses in known hosts files
--will not be converted automatically,
--but may be manually hashed using
--.Xr ssh-keygen 1 .
--.It Cm HostbasedAuthentication
--Specifies whether to try rhosts based authentication with public key
--authentication.
--The argument must be
--.Dq yes
--or
--.Dq no .
--The default is
--.Dq no .
--This option applies to protocol version 2 only and
--is similar to
--.Cm RhostsRSAAuthentication .
--.It Cm HostbasedKeyTypes
--Specifies the key types that will be used for hostbased authentication
--as a comma-separated pattern list.
--Alternately if the specified value begins with a
--.Sq +
--character, then the specified key types will be appended to the default set
--instead of replacing them.
--The default for this option is:
--.Bd -literal -offset 3n
--ecdsa-sha2-nistp256-cert-v01@openssh.com,
--ecdsa-sha2-nistp384-cert-v01@openssh.com,
--ecdsa-sha2-nistp521-cert-v01@openssh.com,
--ssh-ed25519-cert-v01@openssh.com,
--ssh-rsa-cert-v01@openssh.com,
--ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
--ssh-ed25519,ssh-rsa
--.Ed
--.Pp
--The
--.Fl Q
--option of
--.Xr ssh 1
--may be used to list supported key types.
--.It Cm HostKeyAlgorithms
--Specifies the protocol version 2 host key algorithms
--that the client wants to use in order of preference.
--Alternately if the specified value begins with a
--.Sq +
--character, then the specified key types will be appended to the default set
--instead of replacing them.
--The default for this option is:
--.Bd -literal -offset 3n
--ecdsa-sha2-nistp256-cert-v01@openssh.com,
--ecdsa-sha2-nistp384-cert-v01@openssh.com,
--ecdsa-sha2-nistp521-cert-v01@openssh.com,
--ssh-ed25519-cert-v01@openssh.com,
--ssh-rsa-cert-v01@openssh.com,
--ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
--ssh-ed25519,ssh-rsa
--.Ed
--.Pp
--If hostkeys are known for the destination host then this default is modified
--to prefer their algorithms.
--.Pp
--The list of available key types may also be obtained using the
--.Fl Q
--option of
--.Xr ssh 1
--with an argument of
--.Dq key .
--.It Cm HostKeyAlias
--Specifies an alias that should be used instead of the
--real host name when looking up or saving the host key
--in the host key database files.
--This option is useful for tunneling SSH connections
--or for multiple servers running on a single host.
--.It Cm HostName
--Specifies the real host name to log into.
--This can be used to specify nicknames or abbreviations for hosts.
--If the hostname contains the character sequence
--.Ql %h ,
--then this will be replaced with the host name specified on the command line
--(this is useful for manipulating unqualified names).
--The character sequence
--.Ql %%
--will be replaced by a single
--.Ql %
--character, which may be used when specifying IPv6 link-local addresses.
--.Pp
--The default is the name given on the command line.
--Numeric IP addresses are also permitted (both on the command line and in
--.Cm HostName
--specifications).
--.It Cm IdentitiesOnly
--Specifies that
--.Xr ssh 1
--should only use the authentication identity files configured in the
--.Nm
--files,
--even if
--.Xr ssh-agent 1
--or a
--.Cm PKCS11Provider
--offers more identities.
--The argument to this keyword must be
--.Dq yes
--or
--.Dq no .
--This option is intended for situations where ssh-agent
--offers many different identities.
--The default is
--.Dq no .
--.It Cm IdentityFile
--Specifies a file from which the user's DSA, ECDSA, Ed25519 or RSA authentication
--identity is read.
--The default is
--.Pa ~/.ssh/identity
--for protocol version 1, and
--.Pa ~/.ssh/id_dsa ,
--.Pa ~/.ssh/id_ecdsa ,
--.Pa ~/.ssh/id_ed25519
--and
--.Pa ~/.ssh/id_rsa
--for protocol version 2.
--Additionally, any identities represented by the authentication agent
--will be used for authentication unless
--.Cm IdentitiesOnly
--is set.
--.Xr ssh 1
--will try to load certificate information from the filename obtained by
--appending
--.Pa -cert.pub
--to the path of a specified
--.Cm IdentityFile .
--.Pp
--The file name may use the tilde
--syntax to refer to a user's home directory or one of the following
--escape characters:
--.Ql %d
--(local user's home directory),
--.Ql %u
--(local user name),
--.Ql %l
--(local host name),
--.Ql %h
--(remote host name) or
--.Ql %r
--(remote user name).
--.Pp
--It is possible to have
--multiple identity files specified in configuration files; all these
--identities will be tried in sequence.
--Multiple
--.Cm IdentityFile
--directives will add to the list of identities tried (this behaviour
--differs from that of other configuration directives).
--.Pp
--.Cm IdentityFile
--may be used in conjunction with
--.Cm IdentitiesOnly
--to select which identities in an agent are offered during authentication.
--.It Cm IgnoreUnknown
--Specifies a pattern-list of unknown options to be ignored if they are
--encountered in configuration parsing.
--This may be used to suppress errors if
--.Nm
--contains options that are unrecognised by
--.Xr ssh 1 .
--It is recommended that
--.Cm IgnoreUnknown
--be listed early in the configuration file as it will not be applied
--to unknown options that appear before it.
--.It Cm IPQoS
--Specifies the IPv4 type-of-service or DSCP class for connections.
--Accepted values are
--.Dq af11 ,
--.Dq af12 ,
--.Dq af13 ,
--.Dq af21 ,
--.Dq af22 ,
--.Dq af23 ,
--.Dq af31 ,
--.Dq af32 ,
--.Dq af33 ,
--.Dq af41 ,
--.Dq af42 ,
--.Dq af43 ,
--.Dq cs0 ,
--.Dq cs1 ,
--.Dq cs2 ,
--.Dq cs3 ,
--.Dq cs4 ,
--.Dq cs5 ,
--.Dq cs6 ,
--.Dq cs7 ,
--.Dq ef ,
--.Dq lowdelay ,
--.Dq throughput ,
--.Dq reliability ,
--or a numeric value.
--This option may take one or two arguments, separated by whitespace.
--If one argument is specified, it is used as the packet class unconditionally.
--If two values are specified, the first is automatically selected for
--interactive sessions and the second for non-interactive sessions.
--The default is
--.Dq lowdelay
--for interactive sessions and
--.Dq throughput
--for non-interactive sessions.
--.It Cm KbdInteractiveAuthentication
--Specifies whether to use keyboard-interactive authentication.
--The argument to this keyword must be
--.Dq yes
--or
--.Dq no .
--The default is
--.Dq yes .
--.It Cm KbdInteractiveDevices
--Specifies the list of methods to use in keyboard-interactive authentication.
--Multiple method names must be comma-separated.
--The default is to use the server specified list.
--The methods available vary depending on what the server supports.
--For an OpenSSH server,
--it may be zero or more of:
--.Dq bsdauth ,
--.Dq pam ,
--and
--.Dq skey .
--.It Cm KexAlgorithms
--Specifies the available KEX (Key Exchange) algorithms.
--Multiple algorithms must be comma-separated.
--Alternately if the specified value begins with a
--.Sq +
--character, then the specified methods will be appended to the default set
--instead of replacing them.
--The default is:
--.Bd -literal -offset indent
--curve25519-sha256@libssh.org,
--ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,
--diffie-hellman-group-exchange-sha256,
--diffie-hellman-group-exchange-sha1,
--diffie-hellman-group14-sha1
--.Ed
--.Pp
--The list of available key exchange algorithms may also be obtained using the
--.Fl Q
--option of
--.Xr ssh 1
--with an argument of
--.Dq kex .
--.It Cm LocalCommand
--Specifies a command to execute on the local machine after successfully
--connecting to the server.
--The command string extends to the end of the line, and is executed with
--the user's shell.
--The following escape character substitutions will be performed:
--.Ql %d
--(local user's home directory),
--.Ql %h
--(remote host name),
--.Ql %l
--(local host name),
--.Ql %n
--(host name as provided on the command line),
--.Ql %p
--(remote port),
--.Ql %r
--(remote user name) or
--.Ql %u
--(local user name) or
--.Ql \&%C
--by a hash of the concatenation: %l%h%p%r.
--.Pp
--The command is run synchronously and does not have access to the
--session of the
--.Xr ssh 1
--that spawned it.
--It should not be used for interactive commands.
--.Pp
--This directive is ignored unless
--.Cm PermitLocalCommand
--has been enabled.
--.It Cm LocalForward
--Specifies that a TCP port on the local machine be forwarded over
--the secure channel to the specified host and port from the remote machine.
--The first argument must be
--.Sm off
--.Oo Ar bind_address : Oc Ar port
--.Sm on
--and the second argument must be
--.Ar host : Ns Ar hostport .
--IPv6 addresses can be specified by enclosing addresses in square brackets.
--Multiple forwardings may be specified, and additional forwardings can be
--given on the command line.
--Only the superuser can forward privileged ports.
--By default, the local port is bound in accordance with the
--.Cm GatewayPorts
--setting.
--However, an explicit
--.Ar bind_address
--may be used to bind the connection to a specific address.
--The
--.Ar bind_address
--of
--.Dq localhost
--indicates that the listening port be bound for local use only, while an
--empty address or
--.Sq *
--indicates that the port should be available from all interfaces.
--.It Cm LogLevel
--Gives the verbosity level that is used when logging messages from
--.Xr ssh 1 .
--The possible values are:
--QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3.
--The default is INFO.
--DEBUG and DEBUG1 are equivalent.
--DEBUG2 and DEBUG3 each specify higher levels of verbose output.
--.It Cm MACs
--Specifies the MAC (message authentication code) algorithms
--in order of preference.
--The MAC algorithm is used in protocol version 2
--for data integrity protection.
--Multiple algorithms must be comma-separated.
--If the specified value begins with a
--.Sq +
--character, then the specified algorithms will be appended to the default set
--instead of replacing them.
--.Pp
--The algorithms that contain
--.Dq -etm
--calculate the MAC after encryption (encrypt-then-mac).
--These are considered safer and their use recommended.
--.Pp
--The default is:
--.Bd -literal -offset indent
--umac-64-etm@openssh.com,umac-128-etm@openssh.com,
--hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,
--umac-64@openssh.com,umac-128@openssh.com,
--hmac-sha2-256,hmac-sha2-512,
--hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,
--hmac-ripemd160-etm@openssh.com,
--hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,
--hmac-md5,hmac-sha1,hmac-ripemd160,
--hmac-sha1-96,hmac-md5-96
--.Ed
--.Pp
--The list of available MAC algorithms may also be obtained using the
--.Fl Q
--option of
--.Xr ssh 1
--with an argument of
--.Dq mac .
--.It Cm NoHostAuthenticationForLocalhost
--This option can be used if the home directory is shared across machines.
--In this case localhost will refer to a different machine on each of
--the machines and the user will get many warnings about changed host keys.
--However, this option disables host authentication for localhost.
--The argument to this keyword must be
--.Dq yes
--or
--.Dq no .
--The default is to check the host key for localhost.
--.It Cm NumberOfPasswordPrompts
--Specifies the number of password prompts before giving up.
--The argument to this keyword must be an integer.
--The default is 3.
--.It Cm PasswordAuthentication
--Specifies whether to use password authentication.
--The argument to this keyword must be
--.Dq yes
--or
--.Dq no .
--The default is
--.Dq yes .
--.It Cm PermitLocalCommand
--Allow local command execution via the
--.Ic LocalCommand
--option or using the
--.Ic !\& Ns Ar command
--escape sequence in
--.Xr ssh 1 .
--The argument must be
--.Dq yes
--or
--.Dq no .
--The default is
--.Dq no .
--.It Cm PKCS11Provider
--Specifies which PKCS#11 provider to use.
--The argument to this keyword is the PKCS#11 shared library
--.Xr ssh 1
--should use to communicate with a PKCS#11 token providing the user's
--private RSA key.
--.It Cm Port
--Specifies the port number to connect on the remote host.
--The default is 22.
--.It Cm PreferredAuthentications
--Specifies the order in which the client should try protocol 2
--authentication methods.
--This allows a client to prefer one method (e.g.\&
--.Cm keyboard-interactive )
--over another method (e.g.\&
--.Cm password ) .
--The default is:
--.Bd -literal -offset indent
--gssapi-with-mic,hostbased,publickey,
--keyboard-interactive,password
--.Ed
--.It Cm Protocol
--Specifies the protocol versions
--.Xr ssh 1
--should support in order of preference.
--The possible values are
--.Sq 1
--and
--.Sq 2 .
--Multiple versions must be comma-separated.
--When this option is set to
--.Dq 2,1
--.Nm ssh
--will try version 2 and fall back to version 1
--if version 2 is not available.
--The default is
--.Sq 2 .
--.It Cm ProxyCommand
--Specifies the command to use to connect to the server.
--The command
--string extends to the end of the line, and is executed
--using the user's shell
--.Ql exec
--directive to avoid a lingering shell process.
--.Pp
--In the command string, any occurrence of
--.Ql %h
--will be substituted by the host name to
--connect,
--.Ql %p
--by the port, and
--.Ql %r
--by the remote user name.
--The command can be basically anything,
--and should read from its standard input and write to its standard output.
--It should eventually connect an
--.Xr sshd 8
--server running on some machine, or execute
--.Ic sshd -i
--somewhere.
--Host key management will be done using the
--HostName of the host being connected (defaulting to the name typed by
--the user).
--Setting the command to
--.Dq none
--disables this option entirely.
--Note that
--.Cm CheckHostIP
--is not available for connects with a proxy command.
--.Pp
--This directive is useful in conjunction with
--.Xr nc 1
--and its proxy support.
--For example, the following directive would connect via an HTTP proxy at
--192.0.2.0:
--.Bd -literal -offset 3n
--ProxyCommand /usr/bin/nc -X connect -x 192.0.2.0:8080 %h %p
--.Ed
--.It Cm ProxyUseFdpass
--Specifies that
--.Cm ProxyCommand
--will pass a connected file descriptor back to
--.Xr ssh 1
--instead of continuing to execute and pass data.
--The default is
--.Dq no .
--.It Cm PubkeyAcceptedKeyTypes
--Specifies the key types that will be used for public key authentication
--as a comma-separated pattern list.
--Alternately if the specified value begins with a
--.Sq +
--character, then the key types after it will be appended to the default
--instead of replacing it.
--The default for this option is:
--.Bd -literal -offset 3n
--ecdsa-sha2-nistp256-cert-v01@openssh.com,
--ecdsa-sha2-nistp384-cert-v01@openssh.com,
--ecdsa-sha2-nistp521-cert-v01@openssh.com,
--ssh-ed25519-cert-v01@openssh.com,
--ssh-rsa-cert-v01@openssh.com,
--ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
--ssh-ed25519,ssh-rsa
--.Ed
--.Pp
--The
--.Fl Q
--option of
--.Xr ssh 1
--may be used to list supported key types.
--.It Cm PubkeyAuthentication
--Specifies whether to try public key authentication.
--The argument to this keyword must be
--.Dq yes
--or
--.Dq no .
--The default is
--.Dq yes .
--This option applies to protocol version 2 only.
--.It Cm RekeyLimit
--Specifies the maximum amount of data that may be transmitted before the
--session key is renegotiated, optionally followed a maximum amount of
--time that may pass before the session key is renegotiated.
--The first argument is specified in bytes and may have a suffix of
--.Sq K ,
--.Sq M ,
--or
--.Sq G
--to indicate Kilobytes, Megabytes, or Gigabytes, respectively.
--The default is between
--.Sq 1G
--and
--.Sq 4G ,
--depending on the cipher.
--The optional second value is specified in seconds and may use any of the
--units documented in the
--TIME FORMATS section of
--.Xr sshd_config 5 .
--The default value for
--.Cm RekeyLimit
--is
--.Dq default none ,
--which means that rekeying is performed after the cipher's default amount
--of data has been sent or received and no time based rekeying is done.
--This option applies to protocol version 2 only.
--.It Cm RemoteForward
--Specifies that a TCP port on the remote machine be forwarded over
--the secure channel to the specified host and port from the local machine.
--The first argument must be
--.Sm off
--.Oo Ar bind_address : Oc Ar port
--.Sm on
--and the second argument must be
--.Ar host : Ns Ar hostport .
--IPv6 addresses can be specified by enclosing addresses in square brackets.
--Multiple forwardings may be specified, and additional
--forwardings can be given on the command line.
--Privileged ports can be forwarded only when
--logging in as root on the remote machine.
--.Pp
--If the
--.Ar port
--argument is
--.Ql 0 ,
--the listen port will be dynamically allocated on the server and reported
--to the client at run time.
--.Pp
--If the
--.Ar bind_address
--is not specified, the default is to only bind to loopback addresses.
--If the
--.Ar bind_address
--is
--.Ql *
--or an empty string, then the forwarding is requested to listen on all
--interfaces.
--Specifying a remote
--.Ar bind_address
--will only succeed if the server's
--.Cm GatewayPorts
--option is enabled (see
--.Xr sshd_config 5 ) .
--.It Cm RequestTTY
--Specifies whether to request a pseudo-tty for the session.
--The argument may be one of:
--.Dq no
--(never request a TTY),
--.Dq yes
--(always request a TTY when standard input is a TTY),
--.Dq force
--(always request a TTY) or
--.Dq auto
--(request a TTY when opening a login session).
--This option mirrors the
--.Fl t
--and
--.Fl T
--flags for
--.Xr ssh 1 .
--.It Cm RevokedHostKeys
--Specifies revoked host public keys.
--Keys listed in this file will be refused for host authentication.
--Note that if this file does not exist or is not readable,
--then host authentication will be refused for all hosts.
--Keys may be specified as a text file, listing one public key per line, or as
--an OpenSSH Key Revocation List (KRL) as generated by
--.Xr ssh-keygen 1 .
--For more information on KRLs, see the KEY REVOCATION LISTS section in
--.Xr ssh-keygen 1 .
--.It Cm RhostsRSAAuthentication
--Specifies whether to try rhosts based authentication with RSA host
--authentication.
--The argument must be
--.Dq yes
--or
--.Dq no .
--The default is
--.Dq no .
--This option applies to protocol version 1 only and requires
--.Xr ssh 1
--to be setuid root.
--.It Cm RSAAuthentication
--Specifies whether to try RSA authentication.
--The argument to this keyword must be
--.Dq yes
--or
--.Dq no .
--RSA authentication will only be
--attempted if the identity file exists, or an authentication agent is
--running.
--The default is
--.Dq yes .
--Note that this option applies to protocol version 1 only.
--.It Cm SendEnv
--Specifies what variables from the local
--.Xr environ 7
--should be sent to the server.
--Note that environment passing is only supported for protocol 2.
--The server must also support it, and the server must be configured to
--accept these environment variables.
--Note that the
--.Ev TERM
--environment variable is always sent whenever a
--pseudo-terminal is requested as it is required by the protocol.
--Refer to
--.Cm AcceptEnv
--in
--.Xr sshd_config 5
--for how to configure the server.
--Variables are specified by name, which may contain wildcard characters.
--Multiple environment variables may be separated by whitespace or spread
--across multiple
--.Cm SendEnv
--directives.
--The default is not to send any environment variables.
--.Pp
--See
--.Sx PATTERNS
--for more information on patterns.
--.It Cm ServerAliveCountMax
--Sets the number of server alive messages (see below) which may be
--sent without
--.Xr ssh 1
--receiving any messages back from the server.
--If this threshold is reached while server alive messages are being sent,
--ssh will disconnect from the server, terminating the session.
--It is important to note that the use of server alive messages is very
--different from
--.Cm TCPKeepAlive
--(below).
--The server alive messages are sent through the encrypted channel
--and therefore will not be spoofable.
--The TCP keepalive option enabled by
--.Cm TCPKeepAlive
--is spoofable.
--The server alive mechanism is valuable when the client or
--server depend on knowing when a connection has become inactive.
--.Pp
--The default value is 3.
--If, for example,
--.Cm ServerAliveInterval
--(see below) is set to 15 and
--.Cm ServerAliveCountMax
--is left at the default, if the server becomes unresponsive,
--ssh will disconnect after approximately 45 seconds.
--This option applies to protocol version 2 only.
--.It Cm ServerAliveInterval
--Sets a timeout interval in seconds after which if no data has been received
--from the server,
--.Xr ssh 1
--will send a message through the encrypted
--channel to request a response from the server.
--The default
--is 0, indicating that these messages will not be sent to the server.
--This option applies to protocol version 2 only.
--.It Cm StreamLocalBindMask
--Sets the octal file creation mode mask
--.Pq umask
--used when creating a Unix-domain socket file for local or remote
--port forwarding.
--This option is only used for port forwarding to a Unix-domain socket file.
--.Pp
--The default value is 0177, which creates a Unix-domain socket file that is
--readable and writable only by the owner.
--Note that not all operating systems honor the file mode on Unix-domain
--socket files.
--.It Cm StreamLocalBindUnlink
--Specifies whether to remove an existing Unix-domain socket file for local
--or remote port forwarding before creating a new one.
--If the socket file already exists and
--.Cm StreamLocalBindUnlink
--is not enabled,
--.Nm ssh
--will be unable to forward the port to the Unix-domain socket file.
--This option is only used for port forwarding to a Unix-domain socket file.
--.Pp
--The argument must be
--.Dq yes
--or
--.Dq no .
--The default is
--.Dq no .
--.It Cm StrictHostKeyChecking
--If this flag is set to
--.Dq yes ,
--.Xr ssh 1
--will never automatically add host keys to the
--.Pa ~/.ssh/known_hosts
--file, and refuses to connect to hosts whose host key has changed.
--This provides maximum protection against trojan horse attacks,
--though it can be annoying when the
--.Pa /etc/ssh/ssh_known_hosts
--file is poorly maintained or when connections to new hosts are
--frequently made.
--This option forces the user to manually
--add all new hosts.
--If this flag is set to
--.Dq no ,
--ssh will automatically add new host keys to the
--user known hosts files.
--If this flag is set to
--.Dq ask ,
--new host keys
--will be added to the user known host files only after the user
--has confirmed that is what they really want to do, and
--ssh will refuse to connect to hosts whose host key has changed.
--The host keys of
--known hosts will be verified automatically in all cases.
--The argument must be
--.Dq yes ,
--.Dq no ,
--or
--.Dq ask .
--The default is
--.Dq ask .
--.It Cm TCPKeepAlive
--Specifies whether the system should send TCP keepalive messages to the
--other side.
--If they are sent, death of the connection or crash of one
--of the machines will be properly noticed.
--However, this means that
--connections will die if the route is down temporarily, and some people
--find it annoying.
--.Pp
--The default is
--.Dq yes
--(to send TCP keepalive messages), and the client will notice
--if the network goes down or the remote host dies.
--This is important in scripts, and many users want it too.
--.Pp
--To disable TCP keepalive messages, the value should be set to
--.Dq no .
--.It Cm Tunnel
--Request
--.Xr tun 4
--device forwarding between the client and the server.
--The argument must be
--.Dq yes ,
--.Dq point-to-point
--(layer 3),
--.Dq ethernet
--(layer 2),
--or
--.Dq no .
--Specifying
--.Dq yes
--requests the default tunnel mode, which is
--.Dq point-to-point .
--The default is
--.Dq no .
--.It Cm TunnelDevice
--Specifies the
--.Xr tun 4
--devices to open on the client
--.Pq Ar local_tun
--and the server
--.Pq Ar remote_tun .
--.Pp
--The argument must be
--.Sm off
--.Ar local_tun Op : Ar remote_tun .
--.Sm on
--The devices may be specified by numerical ID or the keyword
--.Dq any ,
--which uses the next available tunnel device.
--If
--.Ar remote_tun
--is not specified, it defaults to
--.Dq any .
--The default is
--.Dq any:any .
--.It Cm UpdateHostKeys
--Specifies whether
--.Xr ssh 1
--should accept notifications of additional hostkeys from the server sent
--after authentication has completed and add them to
--.Cm UserKnownHostsFile .
--The argument must be
--.Dq yes ,
--.Dq no
--(the default) or
--.Dq ask .
--Enabling this option allows learning alternate hostkeys for a server
--and supports graceful key rotation by allowing a server to send replacement
--public keys before old ones are removed.
--Additional hostkeys are only accepted if the key used to authenticate the
--host was already trusted or explicity accepted by the user.
--If
--.Cm UpdateHostKeys
--is set to
--.Dq ask ,
--then the user is asked to confirm the modifications to the known_hosts file.
--Confirmation is currently incompatible with
--.Cm ControlPersist ,
--and will be disabled if it is enabled.
--.Pp
--Presently, only
--.Xr sshd 8
--from OpenSSH 6.8 and greater support the
--.Dq hostkeys@openssh.com
--protocol extension used to inform the client of all the server's hostkeys.
--.It Cm UsePrivilegedPort
--Specifies whether to use a privileged port for outgoing connections.
--The argument must be
--.Dq yes
--or
--.Dq no .
--The default is
--.Dq no .
--If set to
--.Dq yes ,
--.Xr ssh 1
--must be setuid root.
--Note that this option must be set to
--.Dq yes
--for
--.Cm RhostsRSAAuthentication
--with older servers.
--.It Cm User
--Specifies the user to log in as.
--This can be useful when a different user name is used on different machines.
--This saves the trouble of
--having to remember to give the user name on the command line.
--.It Cm UserKnownHostsFile
--Specifies one or more files to use for the user
--host key database, separated by whitespace.
--The default is
--.Pa ~/.ssh/known_hosts ,
--.Pa ~/.ssh/known_hosts2 .
--.It Cm VerifyHostKeyDNS
--Specifies whether to verify the remote key using DNS and SSHFP resource
--records.
--If this option is set to
--.Dq yes ,
--the client will implicitly trust keys that match a secure fingerprint
--from DNS.
--Insecure fingerprints will be handled as if this option was set to
--.Dq ask .
--If this option is set to
--.Dq ask ,
--information on fingerprint match will be displayed, but the user will still
--need to confirm new host keys according to the
--.Cm StrictHostKeyChecking
--option.
--The argument must be
--.Dq yes ,
--.Dq no ,
--or
--.Dq ask .
--The default is
--.Dq no .
--Note that this option applies to protocol version 2 only.
--.Pp
--See also VERIFYING HOST KEYS in
--.Xr ssh 1 .
--.It Cm VisualHostKey
--If this flag is set to
--.Dq yes ,
--an ASCII art representation of the remote host key fingerprint is
--printed in addition to the fingerprint string at login and
--for unknown host keys.
--If this flag is set to
--.Dq no ,
--no fingerprint strings are printed at login and
--only the fingerprint string will be printed for unknown host keys.
--The default is
--.Dq no .
--.It Cm XAuthLocation
--Specifies the full pathname of the
--.Xr xauth 1
--program.
--The default is
--.Pa /usr/X11R6/bin/xauth .
--.El
--.Sh PATTERNS
--A
--.Em pattern
--consists of zero or more non-whitespace characters,
--.Sq *
--(a wildcard that matches zero or more characters),
--or
--.Sq ?\&
--(a wildcard that matches exactly one character).
--For example, to specify a set of declarations for any host in the
--.Dq .co.uk
--set of domains,
--the following pattern could be used:
--.Pp
--.Dl Host *.co.uk
--.Pp
--The following pattern
--would match any host in the 192.168.0.[0-9] network range:
--.Pp
--.Dl Host 192.168.0.?
--.Pp
--A
--.Em pattern-list
--is a comma-separated list of patterns.
--Patterns within pattern-lists may be negated
--by preceding them with an exclamation mark
--.Pq Sq !\& .
--For example,
--to allow a key to be used from anywhere within an organization
--except from the
--.Dq dialup
--pool,
--the following entry (in authorized_keys) could be used:
--.Pp
--.Dl from=\&"!*.dialup.example.com,*.example.com\&"
--.Sh FILES
--.Bl -tag -width Ds
--.It Pa ~/.ssh/config
--This is the per-user configuration file.
--The format of this file is described above.
--This file is used by the SSH client.
--Because of the potential for abuse, this file must have strict permissions:
--read/write for the user, and not accessible by others.
--.It Pa /etc/ssh/ssh_config
--Systemwide configuration file.
--This file provides defaults for those
--values that are not specified in the user's configuration file, and
--for those users who do not have a configuration file.
--This file must be world-readable.
--.El
--.Sh SEE ALSO
--.Xr ssh 1
--.Sh AUTHORS
--OpenSSH is a derivative of the original and free
--ssh 1.2.12 release by Tatu Ylonen.
--Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
--Theo de Raadt and Dug Song
--removed many bugs, re-added newer features and
--created OpenSSH.
--Markus Friedl contributed the support for SSH
--protocol versions 1.5 and 2.0.
-diff --git a/sshd.1m b/sshd.1m
-new file mode 100644
-index 0000000..967a753
---- /dev/null
-+++ b/sshd.1m
-@@ -0,0 +1,971 @@
-+.\"
-+.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
-+.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
-+.\"                    All rights reserved
-+.\"
-+.\" As far as I am concerned, the code I have written for this software
-+.\" can be used freely for any purpose.  Any derived versions of this
-+.\" software must be clearly marked as such, and if the derived work is
-+.\" incompatible with the protocol description in the RFC file, it must be
-+.\" called by a name other than "ssh" or "Secure Shell".
-+.\"
-+.\" Copyright (c) 1999,2000 Markus Friedl.  All rights reserved.
-+.\" Copyright (c) 1999 Aaron Campbell.  All rights reserved.
-+.\" Copyright (c) 1999 Theo de Raadt.  All rights reserved.
-+.\"
-+.\" Redistribution and use in source and binary forms, with or without
-+.\" modification, are permitted provided that the following conditions
-+.\" are met:
-+.\" 1. Redistributions of source code must retain the above copyright
-+.\"    notice, this list of conditions and the following disclaimer.
-+.\" 2. Redistributions in binary form must reproduce the above copyright
-+.\"    notice, this list of conditions and the following disclaimer in the
-+.\"    documentation and/or other materials provided with the distribution.
-+.\"
-+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-+.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-+.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-+.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-+.\"
-+.\" $OpenBSD: sshd.8,v 1.280 2015/07/03 03:49:45 djm Exp $
-+.Dd $Mdocdate: July 3 2015 $
-+.Dt SSHD 1M
-+.Os
-+.Sh NAME
-+.Nm sshd
-+.Nd OpenSSH SSH daemon
-+.Sh SYNOPSIS
-+.Nm sshd
-+.Bk -words
-+.Op Fl 46DdeiqTt
-+.Op Fl b Ar bits
-+.Op Fl C Ar connection_spec
-+.Op Fl c Ar host_certificate_file
-+.Op Fl E Ar log_file
-+.Op Fl f Ar config_file
-+.Op Fl g Ar login_grace_time
-+.Op Fl h Ar host_key_file
-+.Op Fl k Ar key_gen_time
-+.Op Fl o Ar option
-+.Op Fl p Ar port
-+.Op Fl u Ar len
-+.Ek
-+.Sh DESCRIPTION
-+.Nm
-+(OpenSSH Daemon) is the daemon program for
-+.Xr ssh 1 .
-+Together these programs replace rlogin and rsh,
-+and provide secure encrypted communications between two untrusted hosts
-+over an insecure network.
-+.Pp
-+.Nm
-+listens for connections from clients.
-+It is normally started at boot from
-+.Pa /etc/rc .
-+It forks a new
-+daemon for each incoming connection.
-+The forked daemons handle
-+key exchange, encryption, authentication, command execution,
-+and data exchange.
-+.Pp
-+.Nm
-+can be configured using command-line options or a configuration file
-+(by default
-+.Xr sshd_config 4 ) ;
-+command-line options override values specified in the
-+configuration file.
-+.Nm
-+rereads its configuration file when it receives a hangup signal,
-+.Dv SIGHUP ,
-+by executing itself with the name and options it was started with, e.g.\&
-+.Pa /usr/sbin/sshd .
-+.Pp
-+The options are as follows:
-+.Bl -tag -width Ds
-+.It Fl 4
-+Forces
-+.Nm
-+to use IPv4 addresses only.
-+.It Fl 6
-+Forces
-+.Nm
-+to use IPv6 addresses only.
-+.It Fl b Ar bits
-+Specifies the number of bits in the ephemeral protocol version 1
-+server key (default 1024).
-+.It Fl C Ar connection_spec
-+Specify the connection parameters to use for the
-+.Fl T
-+extended test mode.
-+If provided, any
-+.Cm Match
-+directives in the configuration file
-+that would apply to the specified user, host, and address will be set before
-+the configuration is written to standard output.
-+The connection parameters are supplied as keyword=value pairs.
-+The keywords are
-+.Dq user ,
-+.Dq host ,
-+.Dq laddr ,
-+.Dq lport ,
-+and
-+.Dq addr .
-+All are required and may be supplied in any order, either with multiple
-+.Fl C
-+options or as a comma-separated list.
-+.It Fl c Ar host_certificate_file
-+Specifies a path to a certificate file to identify
-+.Nm
-+during key exchange.
-+The certificate file must match a host key file specified using the
-+.Fl h
-+option or the
-+.Cm HostKey
-+configuration directive.
-+.It Fl D
-+When this option is specified,
-+.Nm
-+will not detach and does not become a daemon.
-+This allows easy monitoring of
-+.Nm sshd .
-+.It Fl d
-+Debug mode.
-+The server sends verbose debug output to standard error,
-+and does not put itself in the background.
-+The server also will not fork and will only process one connection.
-+This option is only intended for debugging for the server.
-+Multiple
-+.Fl d
-+options increase the debugging level.
-+Maximum is 3.
-+.It Fl E Ar log_file
-+Append debug logs to
-+.Ar log_file
-+instead of the system log.
-+.It Fl e
-+Write debug logs to standard error instead of the system log.
-+.It Fl f Ar config_file
-+Specifies the name of the configuration file.
-+The default is
-+.Pa /etc/ssh/sshd_config .
-+.Nm
-+refuses to start if there is no configuration file.
-+.It Fl g Ar login_grace_time
-+Gives the grace time for clients to authenticate themselves (default
-+120 seconds).
-+If the client fails to authenticate the user within
-+this many seconds, the server disconnects and exits.
-+A value of zero indicates no limit.
-+.It Fl h Ar host_key_file
-+Specifies a file from which a host key is read.
-+This option must be given if
-+.Nm
-+is not run as root (as the normal
-+host key files are normally not readable by anyone but root).
-+The default is
-+.Pa /etc/ssh/ssh_host_key
-+for protocol version 1, and
-+.Pa /etc/ssh/ssh_host_dsa_key ,
-+.Pa /etc/ssh/ssh_host_ecdsa_key .
-+.Pa /etc/ssh/ssh_host_ed25519_key
-+and
-+.Pa /etc/ssh/ssh_host_rsa_key
-+for protocol version 2.
-+It is possible to have multiple host key files for
-+the different protocol versions and host key algorithms.
-+.It Fl i
-+Specifies that
-+.Nm
-+is being run from
-+.Xr inetd 8 .
-+If SSH protocol 1 is enabled,
-+.Nm
-+should not  normally be run
-+from inetd because it needs to generate the server key before it can
-+respond to the client, and this may take some time.
-+Clients may have to wait too long if the key was regenerated every time.
-+.It Fl k Ar key_gen_time
-+Specifies how often the ephemeral protocol version 1 server key is
-+regenerated (default 3600 seconds, or one hour).
-+The motivation for regenerating the key fairly
-+often is that the key is not stored anywhere, and after about an hour
-+it becomes impossible to recover the key for decrypting intercepted
-+communications even if the machine is cracked into or physically
-+seized.
-+A value of zero indicates that the key will never be regenerated.
-+.It Fl o Ar option
-+Can be used to give options in the format used in the configuration file.
-+This is useful for specifying options for which there is no separate
-+command-line flag.
-+For full details of the options, and their values, see
-+.Xr sshd_config 4 .
-+.It Fl p Ar port
-+Specifies the port on which the server listens for connections
-+(default 22).
-+Multiple port options are permitted.
-+Ports specified in the configuration file with the
-+.Cm Port
-+option are ignored when a command-line port is specified.
-+Ports specified using the
-+.Cm ListenAddress
-+option override command-line ports.
-+.It Fl q
-+Quiet mode.
-+Nothing is sent to the system log.
-+Normally the beginning,
-+authentication, and termination of each connection is logged.
-+.It Fl T
-+Extended test mode.
-+Check the validity of the configuration file, output the effective configuration
-+to stdout and then exit.
-+Optionally,
-+.Cm Match
-+rules may be applied by specifying the connection parameters using one or more
-+.Fl C
-+options.
-+.It Fl t
-+Test mode.
-+Only check the validity of the configuration file and sanity of the keys.
-+This is useful for updating
-+.Nm
-+reliably as configuration options may change.
-+.It Fl u Ar len
-+This option is used to specify the size of the field
-+in the
-+.Li utmp
-+structure that holds the remote host name.
-+If the resolved host name is longer than
-+.Ar len ,
-+the dotted decimal value will be used instead.
-+This allows hosts with very long host names that
-+overflow this field to still be uniquely identified.
-+Specifying
-+.Fl u0
-+indicates that only dotted decimal addresses
-+should be put into the
-+.Pa utmp
-+file.
-+.Fl u0
-+may also be used to prevent
-+.Nm
-+from making DNS requests unless the authentication
-+mechanism or configuration requires it.
-+Authentication mechanisms that may require DNS include
-+.Cm RhostsRSAAuthentication ,
-+.Cm HostbasedAuthentication ,
-+and using a
-+.Cm from="pattern-list"
-+option in a key file.
-+Configuration options that require DNS include using a
-+USER@HOST pattern in
-+.Cm AllowUsers
-+or
-+.Cm DenyUsers .
-+.El
-+.Sh AUTHENTICATION
-+The OpenSSH SSH daemon supports SSH protocols 1 and 2.
-+The default is to use protocol 2 only,
-+though this can be changed via the
-+.Cm Protocol
-+option in
-+.Xr sshd_config 4 .
-+Protocol 2 supports DSA, ECDSA, Ed25519 and RSA keys;
-+protocol 1 only supports RSA keys.
-+For both protocols,
-+each host has a host-specific key,
-+normally 2048 bits,
-+used to identify the host.
-+.Pp
-+Forward security for protocol 1 is provided through
-+an additional server key,
-+normally 1024 bits,
-+generated when the server starts.
-+This key is normally regenerated every hour if it has been used, and
-+is never stored on disk.
-+Whenever a client connects, the daemon responds with its public
-+host and server keys.
-+The client compares the
-+RSA host key against its own database to verify that it has not changed.
-+The client then generates a 256-bit random number.
-+It encrypts this
-+random number using both the host key and the server key, and sends
-+the encrypted number to the server.
-+Both sides then use this
-+random number as a session key which is used to encrypt all further
-+communications in the session.
-+The rest of the session is encrypted
-+using a conventional cipher, currently Blowfish or 3DES, with 3DES
-+being used by default.
-+The client selects the encryption algorithm
-+to use from those offered by the server.
-+.Pp
-+For protocol 2,
-+forward security is provided through a Diffie-Hellman key agreement.
-+This key agreement results in a shared session key.
-+The rest of the session is encrypted using a symmetric cipher, currently
-+128-bit AES, Blowfish, 3DES, CAST128, Arcfour, 192-bit AES, or 256-bit AES.
-+The client selects the encryption algorithm
-+to use from those offered by the server.
-+Additionally, session integrity is provided
-+through a cryptographic message authentication code
-+(hmac-md5, hmac-sha1, umac-64, umac-128, hmac-ripemd160,
-+hmac-sha2-256 or hmac-sha2-512).
-+.Pp
-+Finally, the server and the client enter an authentication dialog.
-+The client tries to authenticate itself using
-+host-based authentication,
-+public key authentication,
-+challenge-response authentication,
-+or password authentication.
-+.Pp
-+Regardless of the authentication type, the account is checked to
-+ensure that it is accessible.  An account is not accessible if it is
-+locked, listed in
-+.Cm DenyUsers
-+or its group is listed in
-+.Cm DenyGroups
-+\&.  The definition of a locked account is system dependant. Some platforms
-+have their own account database (eg AIX) and some modify the passwd field (
-+.Ql \&*LK\&*
-+on Solaris and UnixWare,
-+.Ql \&*
-+on HP-UX, containing
-+.Ql Nologin
-+on Tru64,
-+a leading
-+.Ql \&*LOCKED\&*
-+on FreeBSD and a leading
-+.Ql \&!
-+on most Linuxes).
-+If there is a requirement to disable password authentication
-+for the account while allowing still public-key, then the passwd field
-+should be set to something other than these values (eg
-+.Ql NP
-+or
-+.Ql \&*NP\&*
-+).
-+.Pp
-+If the client successfully authenticates itself, a dialog for
-+preparing the session is entered.
-+At this time the client may request
-+things like allocating a pseudo-tty, forwarding X11 connections,
-+forwarding TCP connections, or forwarding the authentication agent
-+connection over the secure channel.
-+.Pp
-+After this, the client either requests a shell or execution of a command.
-+The sides then enter session mode.
-+In this mode, either side may send
-+data at any time, and such data is forwarded to/from the shell or
-+command on the server side, and the user terminal in the client side.
-+.Pp
-+When the user program terminates and all forwarded X11 and other
-+connections have been closed, the server sends command exit status to
-+the client, and both sides exit.
-+.Sh LOGIN PROCESS
-+When a user successfully logs in,
-+.Nm
-+does the following:
-+.Bl -enum -offset indent
-+.It
-+If the login is on a tty, and no command has been specified,
-+prints last login time and
-+.Pa /etc/motd
-+(unless prevented in the configuration file or by
-+.Pa ~/.hushlogin ;
-+see the
-+.Sx FILES
-+section).
-+.It
-+If the login is on a tty, records login time.
-+.It
-+Checks
-+.Pa /etc/nologin ;
-+if it exists, prints contents and quits
-+(unless root).
-+.It
-+Changes to run with normal user privileges.
-+.It
-+Sets up basic environment.
-+.It
-+Reads the file
-+.Pa ~/.ssh/environment ,
-+if it exists, and users are allowed to change their environment.
-+See the
-+.Cm PermitUserEnvironment
-+option in
-+.Xr sshd_config 4 .
-+.It
-+Changes to user's home directory.
-+.It
-+If
-+.Pa ~/.ssh/rc
-+exists and the
-+.Xr sshd_config 5
-+.Cm PermitUserRC
-+option is set, runs it; else if
-+.Pa /etc/ssh/sshrc
-+exists, runs
-+it; otherwise runs xauth.
-+The
-+.Dq rc
-+files are given the X11
-+authentication protocol and cookie in standard input.
-+See
-+.Sx SSHRC ,
-+below.
-+.It
-+Runs user's shell or command.
-+All commands are run under the user's login shell as specified in the
-+system password database.
-+.El
-+.Sh SSHRC
-+If the file
-+.Pa ~/.ssh/rc
-+exists,
-+.Xr sh 1
-+runs it after reading the
-+environment files but before starting the user's shell or command.
-+It must not produce any output on stdout; stderr must be used
-+instead.
-+If X11 forwarding is in use, it will receive the "proto cookie" pair in
-+its standard input (and
-+.Ev DISPLAY
-+in its environment).
-+The script must call
-+.Xr xauth 1
-+because
-+.Nm
-+will not run xauth automatically to add X11 cookies.
-+.Pp
-+The primary purpose of this file is to run any initialization routines
-+which may be needed before the user's home directory becomes
-+accessible; AFS is a particular example of such an environment.
-+.Pp
-+This file will probably contain some initialization code followed by
-+something similar to:
-+.Bd -literal -offset 3n
-+if read proto cookie && [ -n "$DISPLAY" ]; then
-+	if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then
-+		# X11UseLocalhost=yes
-+		echo add unix:`echo $DISPLAY |
-+		    cut -c11-` $proto $cookie
-+	else
-+		# X11UseLocalhost=no
-+		echo add $DISPLAY $proto $cookie
-+	fi | xauth -q -
-+fi
-+.Ed
-+.Pp
-+If this file does not exist,
-+.Pa /etc/ssh/sshrc
-+is run, and if that
-+does not exist either, xauth is used to add the cookie.
-+.Sh AUTHORIZED_KEYS FILE FORMAT
-+.Cm AuthorizedKeysFile
-+specifies the files containing public keys for
-+public key authentication;
-+if none is specified, the default is
-+.Pa ~/.ssh/authorized_keys
-+and
-+.Pa ~/.ssh/authorized_keys2 .
-+Each line of the file contains one
-+key (empty lines and lines starting with a
-+.Ql #
-+are ignored as
-+comments).
-+Protocol 1 public keys consist of the following space-separated fields:
-+options, bits, exponent, modulus, comment.
-+Protocol 2 public key consist of:
-+options, keytype, base64-encoded key, comment.
-+The options field is optional;
-+its presence is determined by whether the line starts
-+with a number or not (the options field never starts with a number).
-+The bits, exponent, modulus, and comment fields give the RSA key for
-+protocol version 1; the
-+comment field is not used for anything (but may be convenient for the
-+user to identify the key).
-+For protocol version 2 the keytype is
-+.Dq ecdsa-sha2-nistp256 ,
-+.Dq ecdsa-sha2-nistp384 ,
-+.Dq ecdsa-sha2-nistp521 ,
-+.Dq ssh-ed25519 ,
-+.Dq ssh-dss
-+or
-+.Dq ssh-rsa .
-+.Pp
-+Note that lines in this file are usually several hundred bytes long
-+(because of the size of the public key encoding) up to a limit of
-+8 kilobytes, which permits DSA keys up to 8 kilobits and RSA
-+keys up to 16 kilobits.
-+You don't want to type them in; instead, copy the
-+.Pa identity.pub ,
-+.Pa id_dsa.pub ,
-+.Pa id_ecdsa.pub ,
-+.Pa id_ed25519.pub ,
-+or the
-+.Pa id_rsa.pub
-+file and edit it.
-+.Pp
-+.Nm
-+enforces a minimum RSA key modulus size for protocol 1
-+and protocol 2 keys of 768 bits.
-+.Pp
-+The options (if present) consist of comma-separated option
-+specifications.
-+No spaces are permitted, except within double quotes.
-+The following option specifications are supported (note
-+that option keywords are case-insensitive):
-+.Bl -tag -width Ds
-+.It Cm cert-authority
-+Specifies that the listed key is a certification authority (CA) that is
-+trusted to validate signed certificates for user authentication.
-+.Pp
-+Certificates may encode access restrictions similar to these key options.
-+If both certificate restrictions and key options are present, the most
-+restrictive union of the two is applied.
-+.It Cm command="command"
-+Specifies that the command is executed whenever this key is used for
-+authentication.
-+The command supplied by the user (if any) is ignored.
-+The command is run on a pty if the client requests a pty;
-+otherwise it is run without a tty.
-+If an 8-bit clean channel is required,
-+one must not request a pty or should specify
-+.Cm no-pty .
-+A quote may be included in the command by quoting it with a backslash.
-+This option might be useful
-+to restrict certain public keys to perform just a specific operation.
-+An example might be a key that permits remote backups but nothing else.
-+Note that the client may specify TCP and/or X11
-+forwarding unless they are explicitly prohibited.
-+The command originally supplied by the client is available in the
-+.Ev SSH_ORIGINAL_COMMAND
-+environment variable.
-+Note that this option applies to shell, command or subsystem execution.
-+Also note that this command may be superseded by either a
-+.Xr sshd_config 4
-+.Cm ForceCommand
-+directive or a command embedded in a certificate.
-+.It Cm environment="NAME=value"
-+Specifies that the string is to be added to the environment when
-+logging in using this key.
-+Environment variables set this way
-+override other default environment values.
-+Multiple options of this type are permitted.
-+Environment processing is disabled by default and is
-+controlled via the
-+.Cm PermitUserEnvironment
-+option.
-+This option is automatically disabled if
-+.Cm UseLogin
-+is enabled.
-+.It Cm from="pattern-list"
-+Specifies that in addition to public key authentication, either the canonical
-+name of the remote host or its IP address must be present in the
-+comma-separated list of patterns.
-+See PATTERNS in
-+.Xr ssh_config 4
-+for more information on patterns.
-+.Pp
-+In addition to the wildcard matching that may be applied to hostnames or
-+addresses, a
-+.Cm from
-+stanza may match IP addresses using CIDR address/masklen notation.
-+.Pp
-+The purpose of this option is to optionally increase security: public key
-+authentication by itself does not trust the network or name servers or
-+anything (but the key); however, if somebody somehow steals the key, the key
-+permits an intruder to log in from anywhere in the world.
-+This additional option makes using a stolen key more difficult (name
-+servers and/or routers would have to be compromised in addition to
-+just the key).
-+.It Cm no-agent-forwarding
-+Forbids authentication agent forwarding when this key is used for
-+authentication.
-+.It Cm no-port-forwarding
-+Forbids TCP forwarding when this key is used for authentication.
-+Any port forward requests by the client will return an error.
-+This might be used, e.g. in connection with the
-+.Cm command
-+option.
-+.It Cm no-pty
-+Prevents tty allocation (a request to allocate a pty will fail).
-+.It Cm no-user-rc
-+Disables execution of
-+.Pa ~/.ssh/rc .
-+.It Cm no-X11-forwarding
-+Forbids X11 forwarding when this key is used for authentication.
-+Any X11 forward requests by the client will return an error.
-+.It Cm permitopen="host:port"
-+Limit local port forwarding with
-+.Xr ssh 1
-+.Fl L
-+such that it may only connect to the specified host and port.
-+IPv6 addresses can be specified by enclosing the address in square brackets.
-+Multiple
-+.Cm permitopen
-+options may be applied separated by commas.
-+No pattern matching is performed on the specified hostnames,
-+they must be literal domains or addresses.
-+A port specification of
-+.Cm *
-+matches any port.
-+.It Cm principals="principals"
-+On a
-+.Cm cert-authority
-+line, specifies allowed principals for certificate authentication as a
-+comma-separated list.
-+At least one name from the list must appear in the certificate's
-+list of principals for the certificate to be accepted.
-+This option is ignored for keys that are not marked as trusted certificate
-+signers using the
-+.Cm cert-authority
-+option.
-+.It Cm tunnel="n"
-+Force a
-+.Xr tun 4
-+device on the server.
-+Without this option, the next available device will be used if
-+the client requests a tunnel.
-+.El
-+.Pp
-+An example authorized_keys file:
-+.Bd -literal -offset 3n
-+# Comments allowed at start of line
-+ssh-rsa AAAAB3Nza...LiPk== user@example.net
-+from="*.sales.example.net,!pc.sales.example.net" ssh-rsa
-+AAAAB2...19Q== john@example.net
-+command="dump /home",no-pty,no-port-forwarding ssh-dss
-+AAAAC3...51R== example.net
-+permitopen="192.0.2.1:80",permitopen="192.0.2.2:25" ssh-dss
-+AAAAB5...21S==
-+tunnel="0",command="sh /etc/netstart tun0" ssh-rsa AAAA...==
-+jane@example.net
-+.Ed
-+.Sh SSH_KNOWN_HOSTS FILE FORMAT
-+The
-+.Pa /etc/ssh/ssh_known_hosts
-+and
-+.Pa ~/.ssh/known_hosts
-+files contain host public keys for all known hosts.
-+The global file should
-+be prepared by the administrator (optional), and the per-user file is
-+maintained automatically: whenever the user connects from an unknown host,
-+its key is added to the per-user file.
-+.Pp
-+Each line in these files contains the following fields: markers (optional),
-+hostnames, bits, exponent, modulus, comment.
-+The fields are separated by spaces.
-+.Pp
-+The marker is optional, but if it is present then it must be one of
-+.Dq @cert-authority ,
-+to indicate that the line contains a certification authority (CA) key,
-+or
-+.Dq @revoked ,
-+to indicate that the key contained on the line is revoked and must not ever
-+be accepted.
-+Only one marker should be used on a key line.
-+.Pp
-+Hostnames is a comma-separated list of patterns
-+.Pf ( Ql *
-+and
-+.Ql \&?
-+act as
-+wildcards); each pattern in turn is matched against the canonical host
-+name (when authenticating a client) or against the user-supplied
-+name (when authenticating a server).
-+A pattern may also be preceded by
-+.Ql \&!
-+to indicate negation: if the host name matches a negated
-+pattern, it is not accepted (by that line) even if it matched another
-+pattern on the line.
-+A hostname or address may optionally be enclosed within
-+.Ql \&[
-+and
-+.Ql \&]
-+brackets then followed by
-+.Ql \&:
-+and a non-standard port number.
-+.Pp
-+Alternately, hostnames may be stored in a hashed form which hides host names
-+and addresses should the file's contents be disclosed.
-+Hashed hostnames start with a
-+.Ql |
-+character.
-+Only one hashed hostname may appear on a single line and none of the above
-+negation or wildcard operators may be applied.
-+.Pp
-+Bits, exponent, and modulus are taken directly from the RSA host key; they
-+can be obtained, for example, from
-+.Pa /etc/ssh/ssh_host_key.pub .
-+The optional comment field continues to the end of the line, and is not used.
-+.Pp
-+Lines starting with
-+.Ql #
-+and empty lines are ignored as comments.
-+.Pp
-+When performing host authentication, authentication is accepted if any
-+matching line has the proper key; either one that matches exactly or,
-+if the server has presented a certificate for authentication, the key
-+of the certification authority that signed the certificate.
-+For a key to be trusted as a certification authority, it must use the
-+.Dq @cert-authority
-+marker described above.
-+.Pp
-+The known hosts file also provides a facility to mark keys as revoked,
-+for example when it is known that the associated private key has been
-+stolen.
-+Revoked keys are specified by including the
-+.Dq @revoked
-+marker at the beginning of the key line, and are never accepted for
-+authentication or as certification authorities, but instead will
-+produce a warning from
-+.Xr ssh 1
-+when they are encountered.
-+.Pp
-+It is permissible (but not
-+recommended) to have several lines or different host keys for the same
-+names.
-+This will inevitably happen when short forms of host names
-+from different domains are put in the file.
-+It is possible
-+that the files contain conflicting information; authentication is
-+accepted if valid information can be found from either file.
-+.Pp
-+Note that the lines in these files are typically hundreds of characters
-+long, and you definitely don't want to type in the host keys by hand.
-+Rather, generate them by a script,
-+.Xr ssh-keyscan 1
-+or by taking
-+.Pa /etc/ssh/ssh_host_key.pub
-+and adding the host names at the front.
-+.Xr ssh-keygen 1
-+also offers some basic automated editing for
-+.Pa ~/.ssh/known_hosts
-+including removing hosts matching a host name and converting all host
-+names to their hashed representations.
-+.Pp
-+An example ssh_known_hosts file:
-+.Bd -literal -offset 3n
-+# Comments allowed at start of line
-+closenet,...,192.0.2.53 1024 37 159...93 closenet.example.net
-+cvs.example.net,192.0.2.10 ssh-rsa AAAA1234.....=
-+# A hashed hostname
-+|1|JfKTdBh7rNbXkVAQCRp4OQoPfmI=|USECr3SWf1JUPsms5AqfD5QfxkM= ssh-rsa
-+AAAA1234.....=
-+# A revoked key
-+@revoked * ssh-rsa AAAAB5W...
-+# A CA key, accepted for any host in *.mydomain.com or *.mydomain.org
-+@cert-authority *.mydomain.org,*.mydomain.com ssh-rsa AAAAB5W...
-+.Ed
-+.Sh FILES
-+.Bl -tag -width Ds -compact
-+.It Pa ~/.hushlogin
-+This file is used to suppress printing the last login time and
-+.Pa /etc/motd ,
-+if
-+.Cm PrintLastLog
-+and
-+.Cm PrintMotd ,
-+respectively,
-+are enabled.
-+It does not suppress printing of the banner specified by
-+.Cm Banner .
-+.Pp
-+.It Pa ~/.rhosts
-+This file is used for host-based authentication (see
-+.Xr ssh 1
-+for more information).
-+On some machines this file may need to be
-+world-readable if the user's home directory is on an NFS partition,
-+because
-+.Nm
-+reads it as root.
-+Additionally, this file must be owned by the user,
-+and must not have write permissions for anyone else.
-+The recommended
-+permission for most machines is read/write for the user, and not
-+accessible by others.
-+.Pp
-+.It Pa ~/.shosts
-+This file is used in exactly the same way as
-+.Pa .rhosts ,
-+but allows host-based authentication without permitting login with
-+rlogin/rsh.
-+.Pp
-+.It Pa ~/.ssh/
-+This directory is the default location for all user-specific configuration
-+and authentication information.
-+There is no general requirement to keep the entire contents of this directory
-+secret, but the recommended permissions are read/write/execute for the user,
-+and not accessible by others.
-+.Pp
-+.It Pa ~/.ssh/authorized_keys
-+Lists the public keys (DSA, ECDSA, Ed25519, RSA)
-+that can be used for logging in as this user.
-+The format of this file is described above.
-+The content of the file is not highly sensitive, but the recommended
-+permissions are read/write for the user, and not accessible by others.
-+.Pp
-+If this file, the
-+.Pa ~/.ssh
-+directory, or the user's home directory are writable
-+by other users, then the file could be modified or replaced by unauthorized
-+users.
-+In this case,
-+.Nm
-+will not allow it to be used unless the
-+.Cm StrictModes
-+option has been set to
-+.Dq no .
-+.Pp
-+.It Pa ~/.ssh/environment
-+This file is read into the environment at login (if it exists).
-+It can only contain empty lines, comment lines (that start with
-+.Ql # ) ,
-+and assignment lines of the form name=value.
-+The file should be writable
-+only by the user; it need not be readable by anyone else.
-+Environment processing is disabled by default and is
-+controlled via the
-+.Cm PermitUserEnvironment
-+option.
-+.Pp
-+.It Pa ~/.ssh/known_hosts
-+Contains a list of host keys for all hosts the user has logged into
-+that are not already in the systemwide list of known host keys.
-+The format of this file is described above.
-+This file should be writable only by root/the owner and
-+can, but need not be, world-readable.
-+.Pp
-+.It Pa ~/.ssh/rc
-+Contains initialization routines to be run before
-+the user's home directory becomes accessible.
-+This file should be writable only by the user, and need not be
-+readable by anyone else.
-+.Pp
-+.It Pa /etc/hosts.equiv
-+This file is for host-based authentication (see
-+.Xr ssh 1 ) .
-+It should only be writable by root.
-+.Pp
-+.It Pa /etc/moduli
-+Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange".
-+The file format is described in
-+.Xr moduli 4 .
-+.Pp
-+.It Pa /etc/motd
-+See
-+.Xr motd 5 .
-+.Pp
-+.It Pa /etc/nologin
-+If this file exists,
-+.Nm
-+refuses to let anyone except root log in.
-+The contents of the file
-+are displayed to anyone trying to log in, and non-root connections are
-+refused.
-+The file should be world-readable.
-+.Pp
-+.It Pa /etc/shosts.equiv
-+This file is used in exactly the same way as
-+.Pa hosts.equiv ,
-+but allows host-based authentication without permitting login with
-+rlogin/rsh.
-+.Pp
-+.It Pa /etc/ssh/ssh_host_key
-+.It Pa /etc/ssh/ssh_host_dsa_key
-+.It Pa /etc/ssh/ssh_host_ecdsa_key
-+.It Pa /etc/ssh/ssh_host_ed25519_key
-+.It Pa /etc/ssh/ssh_host_rsa_key
-+These files contain the private parts of the host keys.
-+These files should only be owned by root, readable only by root, and not
-+accessible to others.
-+Note that
-+.Nm
-+does not start if these files are group/world-accessible.
-+.Pp
-+.It Pa /etc/ssh/ssh_host_key.pub
-+.It Pa /etc/ssh/ssh_host_dsa_key.pub
-+.It Pa /etc/ssh/ssh_host_ecdsa_key.pub
-+.It Pa /etc/ssh/ssh_host_ed25519_key.pub
-+.It Pa /etc/ssh/ssh_host_rsa_key.pub
-+These files contain the public parts of the host keys.
-+These files should be world-readable but writable only by
-+root.
-+Their contents should match the respective private parts.
-+These files are not
-+really used for anything; they are provided for the convenience of
-+the user so their contents can be copied to known hosts files.
-+These files are created using
-+.Xr ssh-keygen 1 .
-+.Pp
-+.It Pa /etc/ssh/ssh_known_hosts
-+Systemwide list of known host keys.
-+This file should be prepared by the
-+system administrator to contain the public host keys of all machines in the
-+organization.
-+The format of this file is described above.
-+This file should be writable only by root/the owner and
-+should be world-readable.
-+.Pp
-+.It Pa /etc/ssh/sshd_config
-+Contains configuration data for
-+.Nm sshd .
-+The file format and configuration options are described in
-+.Xr sshd_config 4 .
-+.Pp
-+.It Pa /etc/ssh/sshrc
-+Similar to
-+.Pa ~/.ssh/rc ,
-+it can be used to specify
-+machine-specific login-time initializations globally.
-+This file should be writable only by root, and should be world-readable.
-+.Pp
-+.It Pa /var/empty
-+.Xr chroot 2
-+directory used by
-+.Nm
-+during privilege separation in the pre-authentication phase.
-+The directory should not contain any files and must be owned by root
-+and not group or world-writable.
-+.Pp
-+.It Pa /var/run/sshd.pid
-+Contains the process ID of the
-+.Nm
-+listening for connections (if there are several daemons running
-+concurrently for different ports, this contains the process ID of the one
-+started last).
-+The content of this file is not sensitive; it can be world-readable.
-+.El
-+.Sh SEE ALSO
-+.Xr scp 1 ,
-+.Xr sftp 1 ,
-+.Xr ssh 1 ,
-+.Xr ssh-add 1 ,
-+.Xr ssh-agent 1 ,
-+.Xr ssh-keygen 1 ,
-+.Xr ssh-keyscan 1 ,
-+.Xr chroot 2 ,
-+.Xr login.conf 5 ,
-+.Xr moduli 4 ,
-+.Xr sshd_config 4 ,
-+.Xr inetd 1M ,
-+.Xr sftp-server 1M
-+.Sh AUTHORS
-+OpenSSH is a derivative of the original and free
-+ssh 1.2.12 release by Tatu Ylonen.
-+Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
-+Theo de Raadt and Dug Song
-+removed many bugs, re-added newer features and
-+created OpenSSH.
-+Markus Friedl contributed the support for SSH
-+protocol versions 1.5 and 2.0.
-+Niels Provos and Markus Friedl contributed support
-+for privilege separation.
-diff --git a/sshd.8 b/sshd.8
-deleted file mode 100644
-index 213b5fc..0000000
---- a/sshd.8
-+++ /dev/null
-@@ -1,971 +0,0 @@
--.\"
--.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
--.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
--.\"                    All rights reserved
--.\"
--.\" As far as I am concerned, the code I have written for this software
--.\" can be used freely for any purpose.  Any derived versions of this
--.\" software must be clearly marked as such, and if the derived work is
--.\" incompatible with the protocol description in the RFC file, it must be
--.\" called by a name other than "ssh" or "Secure Shell".
--.\"
--.\" Copyright (c) 1999,2000 Markus Friedl.  All rights reserved.
--.\" Copyright (c) 1999 Aaron Campbell.  All rights reserved.
--.\" Copyright (c) 1999 Theo de Raadt.  All rights reserved.
--.\"
--.\" Redistribution and use in source and binary forms, with or without
--.\" modification, are permitted provided that the following conditions
--.\" are met:
--.\" 1. Redistributions of source code must retain the above copyright
--.\"    notice, this list of conditions and the following disclaimer.
--.\" 2. Redistributions in binary form must reproduce the above copyright
--.\"    notice, this list of conditions and the following disclaimer in the
--.\"    documentation and/or other materials provided with the distribution.
--.\"
--.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
--.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
--.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
--.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
--.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
--.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
--.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
--.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
--.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
--.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--.\"
--.\" $OpenBSD: sshd.8,v 1.280 2015/07/03 03:49:45 djm Exp $
--.Dd $Mdocdate: July 3 2015 $
--.Dt SSHD 8
--.Os
--.Sh NAME
--.Nm sshd
--.Nd OpenSSH SSH daemon
--.Sh SYNOPSIS
--.Nm sshd
--.Bk -words
--.Op Fl 46DdeiqTt
--.Op Fl b Ar bits
--.Op Fl C Ar connection_spec
--.Op Fl c Ar host_certificate_file
--.Op Fl E Ar log_file
--.Op Fl f Ar config_file
--.Op Fl g Ar login_grace_time
--.Op Fl h Ar host_key_file
--.Op Fl k Ar key_gen_time
--.Op Fl o Ar option
--.Op Fl p Ar port
--.Op Fl u Ar len
--.Ek
--.Sh DESCRIPTION
--.Nm
--(OpenSSH Daemon) is the daemon program for
--.Xr ssh 1 .
--Together these programs replace rlogin and rsh,
--and provide secure encrypted communications between two untrusted hosts
--over an insecure network.
--.Pp
--.Nm
--listens for connections from clients.
--It is normally started at boot from
--.Pa /etc/rc .
--It forks a new
--daemon for each incoming connection.
--The forked daemons handle
--key exchange, encryption, authentication, command execution,
--and data exchange.
--.Pp
--.Nm
--can be configured using command-line options or a configuration file
--(by default
--.Xr sshd_config 5 ) ;
--command-line options override values specified in the
--configuration file.
--.Nm
--rereads its configuration file when it receives a hangup signal,
--.Dv SIGHUP ,
--by executing itself with the name and options it was started with, e.g.\&
--.Pa /usr/sbin/sshd .
--.Pp
--The options are as follows:
--.Bl -tag -width Ds
--.It Fl 4
--Forces
--.Nm
--to use IPv4 addresses only.
--.It Fl 6
--Forces
--.Nm
--to use IPv6 addresses only.
--.It Fl b Ar bits
--Specifies the number of bits in the ephemeral protocol version 1
--server key (default 1024).
--.It Fl C Ar connection_spec
--Specify the connection parameters to use for the
--.Fl T
--extended test mode.
--If provided, any
--.Cm Match
--directives in the configuration file
--that would apply to the specified user, host, and address will be set before
--the configuration is written to standard output.
--The connection parameters are supplied as keyword=value pairs.
--The keywords are
--.Dq user ,
--.Dq host ,
--.Dq laddr ,
--.Dq lport ,
--and
--.Dq addr .
--All are required and may be supplied in any order, either with multiple
--.Fl C
--options or as a comma-separated list.
--.It Fl c Ar host_certificate_file
--Specifies a path to a certificate file to identify
--.Nm
--during key exchange.
--The certificate file must match a host key file specified using the
--.Fl h
--option or the
--.Cm HostKey
--configuration directive.
--.It Fl D
--When this option is specified,
--.Nm
--will not detach and does not become a daemon.
--This allows easy monitoring of
--.Nm sshd .
--.It Fl d
--Debug mode.
--The server sends verbose debug output to standard error,
--and does not put itself in the background.
--The server also will not fork and will only process one connection.
--This option is only intended for debugging for the server.
--Multiple
--.Fl d
--options increase the debugging level.
--Maximum is 3.
--.It Fl E Ar log_file
--Append debug logs to
--.Ar log_file
--instead of the system log.
--.It Fl e
--Write debug logs to standard error instead of the system log.
--.It Fl f Ar config_file
--Specifies the name of the configuration file.
--The default is
--.Pa /etc/ssh/sshd_config .
--.Nm
--refuses to start if there is no configuration file.
--.It Fl g Ar login_grace_time
--Gives the grace time for clients to authenticate themselves (default
--120 seconds).
--If the client fails to authenticate the user within
--this many seconds, the server disconnects and exits.
--A value of zero indicates no limit.
--.It Fl h Ar host_key_file
--Specifies a file from which a host key is read.
--This option must be given if
--.Nm
--is not run as root (as the normal
--host key files are normally not readable by anyone but root).
--The default is
--.Pa /etc/ssh/ssh_host_key
--for protocol version 1, and
--.Pa /etc/ssh/ssh_host_dsa_key ,
--.Pa /etc/ssh/ssh_host_ecdsa_key .
--.Pa /etc/ssh/ssh_host_ed25519_key
--and
--.Pa /etc/ssh/ssh_host_rsa_key
--for protocol version 2.
--It is possible to have multiple host key files for
--the different protocol versions and host key algorithms.
--.It Fl i
--Specifies that
--.Nm
--is being run from
--.Xr inetd 8 .
--If SSH protocol 1 is enabled,
--.Nm
--should not  normally be run
--from inetd because it needs to generate the server key before it can
--respond to the client, and this may take some time.
--Clients may have to wait too long if the key was regenerated every time.
--.It Fl k Ar key_gen_time
--Specifies how often the ephemeral protocol version 1 server key is
--regenerated (default 3600 seconds, or one hour).
--The motivation for regenerating the key fairly
--often is that the key is not stored anywhere, and after about an hour
--it becomes impossible to recover the key for decrypting intercepted
--communications even if the machine is cracked into or physically
--seized.
--A value of zero indicates that the key will never be regenerated.
--.It Fl o Ar option
--Can be used to give options in the format used in the configuration file.
--This is useful for specifying options for which there is no separate
--command-line flag.
--For full details of the options, and their values, see
--.Xr sshd_config 5 .
--.It Fl p Ar port
--Specifies the port on which the server listens for connections
--(default 22).
--Multiple port options are permitted.
--Ports specified in the configuration file with the
--.Cm Port
--option are ignored when a command-line port is specified.
--Ports specified using the
--.Cm ListenAddress
--option override command-line ports.
--.It Fl q
--Quiet mode.
--Nothing is sent to the system log.
--Normally the beginning,
--authentication, and termination of each connection is logged.
--.It Fl T
--Extended test mode.
--Check the validity of the configuration file, output the effective configuration
--to stdout and then exit.
--Optionally,
--.Cm Match
--rules may be applied by specifying the connection parameters using one or more
--.Fl C
--options.
--.It Fl t
--Test mode.
--Only check the validity of the configuration file and sanity of the keys.
--This is useful for updating
--.Nm
--reliably as configuration options may change.
--.It Fl u Ar len
--This option is used to specify the size of the field
--in the
--.Li utmp
--structure that holds the remote host name.
--If the resolved host name is longer than
--.Ar len ,
--the dotted decimal value will be used instead.
--This allows hosts with very long host names that
--overflow this field to still be uniquely identified.
--Specifying
--.Fl u0
--indicates that only dotted decimal addresses
--should be put into the
--.Pa utmp
--file.
--.Fl u0
--may also be used to prevent
--.Nm
--from making DNS requests unless the authentication
--mechanism or configuration requires it.
--Authentication mechanisms that may require DNS include
--.Cm RhostsRSAAuthentication ,
--.Cm HostbasedAuthentication ,
--and using a
--.Cm from="pattern-list"
--option in a key file.
--Configuration options that require DNS include using a
--USER@HOST pattern in
--.Cm AllowUsers
--or
--.Cm DenyUsers .
--.El
--.Sh AUTHENTICATION
--The OpenSSH SSH daemon supports SSH protocols 1 and 2.
--The default is to use protocol 2 only,
--though this can be changed via the
--.Cm Protocol
--option in
--.Xr sshd_config 5 .
--Protocol 2 supports DSA, ECDSA, Ed25519 and RSA keys;
--protocol 1 only supports RSA keys.
--For both protocols,
--each host has a host-specific key,
--normally 2048 bits,
--used to identify the host.
--.Pp
--Forward security for protocol 1 is provided through
--an additional server key,
--normally 1024 bits,
--generated when the server starts.
--This key is normally regenerated every hour if it has been used, and
--is never stored on disk.
--Whenever a client connects, the daemon responds with its public
--host and server keys.
--The client compares the
--RSA host key against its own database to verify that it has not changed.
--The client then generates a 256-bit random number.
--It encrypts this
--random number using both the host key and the server key, and sends
--the encrypted number to the server.
--Both sides then use this
--random number as a session key which is used to encrypt all further
--communications in the session.
--The rest of the session is encrypted
--using a conventional cipher, currently Blowfish or 3DES, with 3DES
--being used by default.
--The client selects the encryption algorithm
--to use from those offered by the server.
--.Pp
--For protocol 2,
--forward security is provided through a Diffie-Hellman key agreement.
--This key agreement results in a shared session key.
--The rest of the session is encrypted using a symmetric cipher, currently
--128-bit AES, Blowfish, 3DES, CAST128, Arcfour, 192-bit AES, or 256-bit AES.
--The client selects the encryption algorithm
--to use from those offered by the server.
--Additionally, session integrity is provided
--through a cryptographic message authentication code
--(hmac-md5, hmac-sha1, umac-64, umac-128, hmac-ripemd160,
--hmac-sha2-256 or hmac-sha2-512).
--.Pp
--Finally, the server and the client enter an authentication dialog.
--The client tries to authenticate itself using
--host-based authentication,
--public key authentication,
--challenge-response authentication,
--or password authentication.
--.Pp
--Regardless of the authentication type, the account is checked to
--ensure that it is accessible.  An account is not accessible if it is
--locked, listed in
--.Cm DenyUsers
--or its group is listed in
--.Cm DenyGroups
--\&.  The definition of a locked account is system dependant. Some platforms
--have their own account database (eg AIX) and some modify the passwd field (
--.Ql \&*LK\&*
--on Solaris and UnixWare,
--.Ql \&*
--on HP-UX, containing
--.Ql Nologin
--on Tru64,
--a leading
--.Ql \&*LOCKED\&*
--on FreeBSD and a leading
--.Ql \&!
--on most Linuxes).
--If there is a requirement to disable password authentication
--for the account while allowing still public-key, then the passwd field
--should be set to something other than these values (eg
--.Ql NP
--or
--.Ql \&*NP\&*
--).
--.Pp
--If the client successfully authenticates itself, a dialog for
--preparing the session is entered.
--At this time the client may request
--things like allocating a pseudo-tty, forwarding X11 connections,
--forwarding TCP connections, or forwarding the authentication agent
--connection over the secure channel.
--.Pp
--After this, the client either requests a shell or execution of a command.
--The sides then enter session mode.
--In this mode, either side may send
--data at any time, and such data is forwarded to/from the shell or
--command on the server side, and the user terminal in the client side.
--.Pp
--When the user program terminates and all forwarded X11 and other
--connections have been closed, the server sends command exit status to
--the client, and both sides exit.
--.Sh LOGIN PROCESS
--When a user successfully logs in,
--.Nm
--does the following:
--.Bl -enum -offset indent
--.It
--If the login is on a tty, and no command has been specified,
--prints last login time and
--.Pa /etc/motd
--(unless prevented in the configuration file or by
--.Pa ~/.hushlogin ;
--see the
--.Sx FILES
--section).
--.It
--If the login is on a tty, records login time.
--.It
--Checks
--.Pa /etc/nologin ;
--if it exists, prints contents and quits
--(unless root).
--.It
--Changes to run with normal user privileges.
--.It
--Sets up basic environment.
--.It
--Reads the file
--.Pa ~/.ssh/environment ,
--if it exists, and users are allowed to change their environment.
--See the
--.Cm PermitUserEnvironment
--option in
--.Xr sshd_config 5 .
--.It
--Changes to user's home directory.
--.It
--If
--.Pa ~/.ssh/rc
--exists and the
--.Xr sshd_config 5
--.Cm PermitUserRC
--option is set, runs it; else if
--.Pa /etc/ssh/sshrc
--exists, runs
--it; otherwise runs xauth.
--The
--.Dq rc
--files are given the X11
--authentication protocol and cookie in standard input.
--See
--.Sx SSHRC ,
--below.
--.It
--Runs user's shell or command.
--All commands are run under the user's login shell as specified in the
--system password database.
--.El
--.Sh SSHRC
--If the file
--.Pa ~/.ssh/rc
--exists,
--.Xr sh 1
--runs it after reading the
--environment files but before starting the user's shell or command.
--It must not produce any output on stdout; stderr must be used
--instead.
--If X11 forwarding is in use, it will receive the "proto cookie" pair in
--its standard input (and
--.Ev DISPLAY
--in its environment).
--The script must call
--.Xr xauth 1
--because
--.Nm
--will not run xauth automatically to add X11 cookies.
--.Pp
--The primary purpose of this file is to run any initialization routines
--which may be needed before the user's home directory becomes
--accessible; AFS is a particular example of such an environment.
--.Pp
--This file will probably contain some initialization code followed by
--something similar to:
--.Bd -literal -offset 3n
--if read proto cookie && [ -n "$DISPLAY" ]; then
--	if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then
--		# X11UseLocalhost=yes
--		echo add unix:`echo $DISPLAY |
--		    cut -c11-` $proto $cookie
--	else
--		# X11UseLocalhost=no
--		echo add $DISPLAY $proto $cookie
--	fi | xauth -q -
--fi
--.Ed
--.Pp
--If this file does not exist,
--.Pa /etc/ssh/sshrc
--is run, and if that
--does not exist either, xauth is used to add the cookie.
--.Sh AUTHORIZED_KEYS FILE FORMAT
--.Cm AuthorizedKeysFile
--specifies the files containing public keys for
--public key authentication;
--if none is specified, the default is
--.Pa ~/.ssh/authorized_keys
--and
--.Pa ~/.ssh/authorized_keys2 .
--Each line of the file contains one
--key (empty lines and lines starting with a
--.Ql #
--are ignored as
--comments).
--Protocol 1 public keys consist of the following space-separated fields:
--options, bits, exponent, modulus, comment.
--Protocol 2 public key consist of:
--options, keytype, base64-encoded key, comment.
--The options field is optional;
--its presence is determined by whether the line starts
--with a number or not (the options field never starts with a number).
--The bits, exponent, modulus, and comment fields give the RSA key for
--protocol version 1; the
--comment field is not used for anything (but may be convenient for the
--user to identify the key).
--For protocol version 2 the keytype is
--.Dq ecdsa-sha2-nistp256 ,
--.Dq ecdsa-sha2-nistp384 ,
--.Dq ecdsa-sha2-nistp521 ,
--.Dq ssh-ed25519 ,
--.Dq ssh-dss
--or
--.Dq ssh-rsa .
--.Pp
--Note that lines in this file are usually several hundred bytes long
--(because of the size of the public key encoding) up to a limit of
--8 kilobytes, which permits DSA keys up to 8 kilobits and RSA
--keys up to 16 kilobits.
--You don't want to type them in; instead, copy the
--.Pa identity.pub ,
--.Pa id_dsa.pub ,
--.Pa id_ecdsa.pub ,
--.Pa id_ed25519.pub ,
--or the
--.Pa id_rsa.pub
--file and edit it.
--.Pp
--.Nm
--enforces a minimum RSA key modulus size for protocol 1
--and protocol 2 keys of 768 bits.
--.Pp
--The options (if present) consist of comma-separated option
--specifications.
--No spaces are permitted, except within double quotes.
--The following option specifications are supported (note
--that option keywords are case-insensitive):
--.Bl -tag -width Ds
--.It Cm cert-authority
--Specifies that the listed key is a certification authority (CA) that is
--trusted to validate signed certificates for user authentication.
--.Pp
--Certificates may encode access restrictions similar to these key options.
--If both certificate restrictions and key options are present, the most
--restrictive union of the two is applied.
--.It Cm command="command"
--Specifies that the command is executed whenever this key is used for
--authentication.
--The command supplied by the user (if any) is ignored.
--The command is run on a pty if the client requests a pty;
--otherwise it is run without a tty.
--If an 8-bit clean channel is required,
--one must not request a pty or should specify
--.Cm no-pty .
--A quote may be included in the command by quoting it with a backslash.
--This option might be useful
--to restrict certain public keys to perform just a specific operation.
--An example might be a key that permits remote backups but nothing else.
--Note that the client may specify TCP and/or X11
--forwarding unless they are explicitly prohibited.
--The command originally supplied by the client is available in the
--.Ev SSH_ORIGINAL_COMMAND
--environment variable.
--Note that this option applies to shell, command or subsystem execution.
--Also note that this command may be superseded by either a
--.Xr sshd_config 5
--.Cm ForceCommand
--directive or a command embedded in a certificate.
--.It Cm environment="NAME=value"
--Specifies that the string is to be added to the environment when
--logging in using this key.
--Environment variables set this way
--override other default environment values.
--Multiple options of this type are permitted.
--Environment processing is disabled by default and is
--controlled via the
--.Cm PermitUserEnvironment
--option.
--This option is automatically disabled if
--.Cm UseLogin
--is enabled.
--.It Cm from="pattern-list"
--Specifies that in addition to public key authentication, either the canonical
--name of the remote host or its IP address must be present in the
--comma-separated list of patterns.
--See PATTERNS in
--.Xr ssh_config 5
--for more information on patterns.
--.Pp
--In addition to the wildcard matching that may be applied to hostnames or
--addresses, a
--.Cm from
--stanza may match IP addresses using CIDR address/masklen notation.
--.Pp
--The purpose of this option is to optionally increase security: public key
--authentication by itself does not trust the network or name servers or
--anything (but the key); however, if somebody somehow steals the key, the key
--permits an intruder to log in from anywhere in the world.
--This additional option makes using a stolen key more difficult (name
--servers and/or routers would have to be compromised in addition to
--just the key).
--.It Cm no-agent-forwarding
--Forbids authentication agent forwarding when this key is used for
--authentication.
--.It Cm no-port-forwarding
--Forbids TCP forwarding when this key is used for authentication.
--Any port forward requests by the client will return an error.
--This might be used, e.g. in connection with the
--.Cm command
--option.
--.It Cm no-pty
--Prevents tty allocation (a request to allocate a pty will fail).
--.It Cm no-user-rc
--Disables execution of
--.Pa ~/.ssh/rc .
--.It Cm no-X11-forwarding
--Forbids X11 forwarding when this key is used for authentication.
--Any X11 forward requests by the client will return an error.
--.It Cm permitopen="host:port"
--Limit local port forwarding with
--.Xr ssh 1
--.Fl L
--such that it may only connect to the specified host and port.
--IPv6 addresses can be specified by enclosing the address in square brackets.
--Multiple
--.Cm permitopen
--options may be applied separated by commas.
--No pattern matching is performed on the specified hostnames,
--they must be literal domains or addresses.
--A port specification of
--.Cm *
--matches any port.
--.It Cm principals="principals"
--On a
--.Cm cert-authority
--line, specifies allowed principals for certificate authentication as a
--comma-separated list.
--At least one name from the list must appear in the certificate's
--list of principals for the certificate to be accepted.
--This option is ignored for keys that are not marked as trusted certificate
--signers using the
--.Cm cert-authority
--option.
--.It Cm tunnel="n"
--Force a
--.Xr tun 4
--device on the server.
--Without this option, the next available device will be used if
--the client requests a tunnel.
--.El
--.Pp
--An example authorized_keys file:
--.Bd -literal -offset 3n
--# Comments allowed at start of line
--ssh-rsa AAAAB3Nza...LiPk== user@example.net
--from="*.sales.example.net,!pc.sales.example.net" ssh-rsa
--AAAAB2...19Q== john@example.net
--command="dump /home",no-pty,no-port-forwarding ssh-dss
--AAAAC3...51R== example.net
--permitopen="192.0.2.1:80",permitopen="192.0.2.2:25" ssh-dss
--AAAAB5...21S==
--tunnel="0",command="sh /etc/netstart tun0" ssh-rsa AAAA...==
--jane@example.net
--.Ed
--.Sh SSH_KNOWN_HOSTS FILE FORMAT
--The
--.Pa /etc/ssh/ssh_known_hosts
--and
--.Pa ~/.ssh/known_hosts
--files contain host public keys for all known hosts.
--The global file should
--be prepared by the administrator (optional), and the per-user file is
--maintained automatically: whenever the user connects from an unknown host,
--its key is added to the per-user file.
--.Pp
--Each line in these files contains the following fields: markers (optional),
--hostnames, bits, exponent, modulus, comment.
--The fields are separated by spaces.
--.Pp
--The marker is optional, but if it is present then it must be one of
--.Dq @cert-authority ,
--to indicate that the line contains a certification authority (CA) key,
--or
--.Dq @revoked ,
--to indicate that the key contained on the line is revoked and must not ever
--be accepted.
--Only one marker should be used on a key line.
--.Pp
--Hostnames is a comma-separated list of patterns
--.Pf ( Ql *
--and
--.Ql \&?
--act as
--wildcards); each pattern in turn is matched against the canonical host
--name (when authenticating a client) or against the user-supplied
--name (when authenticating a server).
--A pattern may also be preceded by
--.Ql \&!
--to indicate negation: if the host name matches a negated
--pattern, it is not accepted (by that line) even if it matched another
--pattern on the line.
--A hostname or address may optionally be enclosed within
--.Ql \&[
--and
--.Ql \&]
--brackets then followed by
--.Ql \&:
--and a non-standard port number.
--.Pp
--Alternately, hostnames may be stored in a hashed form which hides host names
--and addresses should the file's contents be disclosed.
--Hashed hostnames start with a
--.Ql |
--character.
--Only one hashed hostname may appear on a single line and none of the above
--negation or wildcard operators may be applied.
--.Pp
--Bits, exponent, and modulus are taken directly from the RSA host key; they
--can be obtained, for example, from
--.Pa /etc/ssh/ssh_host_key.pub .
--The optional comment field continues to the end of the line, and is not used.
--.Pp
--Lines starting with
--.Ql #
--and empty lines are ignored as comments.
--.Pp
--When performing host authentication, authentication is accepted if any
--matching line has the proper key; either one that matches exactly or,
--if the server has presented a certificate for authentication, the key
--of the certification authority that signed the certificate.
--For a key to be trusted as a certification authority, it must use the
--.Dq @cert-authority
--marker described above.
--.Pp
--The known hosts file also provides a facility to mark keys as revoked,
--for example when it is known that the associated private key has been
--stolen.
--Revoked keys are specified by including the
--.Dq @revoked
--marker at the beginning of the key line, and are never accepted for
--authentication or as certification authorities, but instead will
--produce a warning from
--.Xr ssh 1
--when they are encountered.
--.Pp
--It is permissible (but not
--recommended) to have several lines or different host keys for the same
--names.
--This will inevitably happen when short forms of host names
--from different domains are put in the file.
--It is possible
--that the files contain conflicting information; authentication is
--accepted if valid information can be found from either file.
--.Pp
--Note that the lines in these files are typically hundreds of characters
--long, and you definitely don't want to type in the host keys by hand.
--Rather, generate them by a script,
--.Xr ssh-keyscan 1
--or by taking
--.Pa /etc/ssh/ssh_host_key.pub
--and adding the host names at the front.
--.Xr ssh-keygen 1
--also offers some basic automated editing for
--.Pa ~/.ssh/known_hosts
--including removing hosts matching a host name and converting all host
--names to their hashed representations.
--.Pp
--An example ssh_known_hosts file:
--.Bd -literal -offset 3n
--# Comments allowed at start of line
--closenet,...,192.0.2.53 1024 37 159...93 closenet.example.net
--cvs.example.net,192.0.2.10 ssh-rsa AAAA1234.....=
--# A hashed hostname
--|1|JfKTdBh7rNbXkVAQCRp4OQoPfmI=|USECr3SWf1JUPsms5AqfD5QfxkM= ssh-rsa
--AAAA1234.....=
--# A revoked key
--@revoked * ssh-rsa AAAAB5W...
--# A CA key, accepted for any host in *.mydomain.com or *.mydomain.org
--@cert-authority *.mydomain.org,*.mydomain.com ssh-rsa AAAAB5W...
--.Ed
--.Sh FILES
--.Bl -tag -width Ds -compact
--.It Pa ~/.hushlogin
--This file is used to suppress printing the last login time and
--.Pa /etc/motd ,
--if
--.Cm PrintLastLog
--and
--.Cm PrintMotd ,
--respectively,
--are enabled.
--It does not suppress printing of the banner specified by
--.Cm Banner .
--.Pp
--.It Pa ~/.rhosts
--This file is used for host-based authentication (see
--.Xr ssh 1
--for more information).
--On some machines this file may need to be
--world-readable if the user's home directory is on an NFS partition,
--because
--.Nm
--reads it as root.
--Additionally, this file must be owned by the user,
--and must not have write permissions for anyone else.
--The recommended
--permission for most machines is read/write for the user, and not
--accessible by others.
--.Pp
--.It Pa ~/.shosts
--This file is used in exactly the same way as
--.Pa .rhosts ,
--but allows host-based authentication without permitting login with
--rlogin/rsh.
--.Pp
--.It Pa ~/.ssh/
--This directory is the default location for all user-specific configuration
--and authentication information.
--There is no general requirement to keep the entire contents of this directory
--secret, but the recommended permissions are read/write/execute for the user,
--and not accessible by others.
--.Pp
--.It Pa ~/.ssh/authorized_keys
--Lists the public keys (DSA, ECDSA, Ed25519, RSA)
--that can be used for logging in as this user.
--The format of this file is described above.
--The content of the file is not highly sensitive, but the recommended
--permissions are read/write for the user, and not accessible by others.
--.Pp
--If this file, the
--.Pa ~/.ssh
--directory, or the user's home directory are writable
--by other users, then the file could be modified or replaced by unauthorized
--users.
--In this case,
--.Nm
--will not allow it to be used unless the
--.Cm StrictModes
--option has been set to
--.Dq no .
--.Pp
--.It Pa ~/.ssh/environment
--This file is read into the environment at login (if it exists).
--It can only contain empty lines, comment lines (that start with
--.Ql # ) ,
--and assignment lines of the form name=value.
--The file should be writable
--only by the user; it need not be readable by anyone else.
--Environment processing is disabled by default and is
--controlled via the
--.Cm PermitUserEnvironment
--option.
--.Pp
--.It Pa ~/.ssh/known_hosts
--Contains a list of host keys for all hosts the user has logged into
--that are not already in the systemwide list of known host keys.
--The format of this file is described above.
--This file should be writable only by root/the owner and
--can, but need not be, world-readable.
--.Pp
--.It Pa ~/.ssh/rc
--Contains initialization routines to be run before
--the user's home directory becomes accessible.
--This file should be writable only by the user, and need not be
--readable by anyone else.
--.Pp
--.It Pa /etc/hosts.equiv
--This file is for host-based authentication (see
--.Xr ssh 1 ) .
--It should only be writable by root.
--.Pp
--.It Pa /etc/moduli
--Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange".
--The file format is described in
--.Xr moduli 5 .
--.Pp
--.It Pa /etc/motd
--See
--.Xr motd 5 .
--.Pp
--.It Pa /etc/nologin
--If this file exists,
--.Nm
--refuses to let anyone except root log in.
--The contents of the file
--are displayed to anyone trying to log in, and non-root connections are
--refused.
--The file should be world-readable.
--.Pp
--.It Pa /etc/shosts.equiv
--This file is used in exactly the same way as
--.Pa hosts.equiv ,
--but allows host-based authentication without permitting login with
--rlogin/rsh.
--.Pp
--.It Pa /etc/ssh/ssh_host_key
--.It Pa /etc/ssh/ssh_host_dsa_key
--.It Pa /etc/ssh/ssh_host_ecdsa_key
--.It Pa /etc/ssh/ssh_host_ed25519_key
--.It Pa /etc/ssh/ssh_host_rsa_key
--These files contain the private parts of the host keys.
--These files should only be owned by root, readable only by root, and not
--accessible to others.
--Note that
--.Nm
--does not start if these files are group/world-accessible.
--.Pp
--.It Pa /etc/ssh/ssh_host_key.pub
--.It Pa /etc/ssh/ssh_host_dsa_key.pub
--.It Pa /etc/ssh/ssh_host_ecdsa_key.pub
--.It Pa /etc/ssh/ssh_host_ed25519_key.pub
--.It Pa /etc/ssh/ssh_host_rsa_key.pub
--These files contain the public parts of the host keys.
--These files should be world-readable but writable only by
--root.
--Their contents should match the respective private parts.
--These files are not
--really used for anything; they are provided for the convenience of
--the user so their contents can be copied to known hosts files.
--These files are created using
--.Xr ssh-keygen 1 .
--.Pp
--.It Pa /etc/ssh/ssh_known_hosts
--Systemwide list of known host keys.
--This file should be prepared by the
--system administrator to contain the public host keys of all machines in the
--organization.
--The format of this file is described above.
--This file should be writable only by root/the owner and
--should be world-readable.
--.Pp
--.It Pa /etc/ssh/sshd_config
--Contains configuration data for
--.Nm sshd .
--The file format and configuration options are described in
--.Xr sshd_config 5 .
--.Pp
--.It Pa /etc/ssh/sshrc
--Similar to
--.Pa ~/.ssh/rc ,
--it can be used to specify
--machine-specific login-time initializations globally.
--This file should be writable only by root, and should be world-readable.
--.Pp
--.It Pa /var/empty
--.Xr chroot 2
--directory used by
--.Nm
--during privilege separation in the pre-authentication phase.
--The directory should not contain any files and must be owned by root
--and not group or world-writable.
--.Pp
--.It Pa /var/run/sshd.pid
--Contains the process ID of the
--.Nm
--listening for connections (if there are several daemons running
--concurrently for different ports, this contains the process ID of the one
--started last).
--The content of this file is not sensitive; it can be world-readable.
--.El
--.Sh SEE ALSO
--.Xr scp 1 ,
--.Xr sftp 1 ,
--.Xr ssh 1 ,
--.Xr ssh-add 1 ,
--.Xr ssh-agent 1 ,
--.Xr ssh-keygen 1 ,
--.Xr ssh-keyscan 1 ,
--.Xr chroot 2 ,
--.Xr login.conf 5 ,
--.Xr moduli 5 ,
--.Xr sshd_config 5 ,
--.Xr inetd 8 ,
--.Xr sftp-server 8
--.Sh AUTHORS
--OpenSSH is a derivative of the original and free
--ssh 1.2.12 release by Tatu Ylonen.
--Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
--Theo de Raadt and Dug Song
--removed many bugs, re-added newer features and
--created OpenSSH.
--Markus Friedl contributed the support for SSH
--protocol versions 1.5 and 2.0.
--Niels Provos and Markus Friedl contributed support
--for privilege separation.
-diff --git a/sshd_config.4 b/sshd_config.4
-new file mode 100644
-index 0000000..ba4d79a
---- /dev/null
-+++ b/sshd_config.4
-@@ -0,0 +1,1736 @@
-+.\"
-+.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
-+.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
-+.\"                    All rights reserved
-+.\"
-+.\" As far as I am concerned, the code I have written for this software
-+.\" can be used freely for any purpose.  Any derived versions of this
-+.\" software must be clearly marked as such, and if the derived work is
-+.\" incompatible with the protocol description in the RFC file, it must be
-+.\" called by a name other than "ssh" or "Secure Shell".
-+.\"
-+.\" Copyright (c) 1999,2000 Markus Friedl.  All rights reserved.
-+.\" Copyright (c) 1999 Aaron Campbell.  All rights reserved.
-+.\" Copyright (c) 1999 Theo de Raadt.  All rights reserved.
-+.\"
-+.\" Redistribution and use in source and binary forms, with or without
-+.\" modification, are permitted provided that the following conditions
-+.\" are met:
-+.\" 1. Redistributions of source code must retain the above copyright
-+.\"    notice, this list of conditions and the following disclaimer.
-+.\" 2. Redistributions in binary form must reproduce the above copyright
-+.\"    notice, this list of conditions and the following disclaimer in the
-+.\"    documentation and/or other materials provided with the distribution.
-+.\"
-+.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
-+.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-+.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-+.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-+.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-+.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-+.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-+.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-+.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-+.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-+.\"
-+.\" $OpenBSD: sshd_config.5,v 1.211 2015/08/14 15:32:41 jmc Exp $
-+.Dd $Mdocdate: August 14 2015 $
-+.Dt SSHD_CONFIG 4
-+.Os
-+.Sh NAME
-+.Nm sshd_config
-+.Nd OpenSSH SSH daemon configuration file
-+.Sh SYNOPSIS
-+.Nm /etc/ssh/sshd_config
-+.Sh DESCRIPTION
-+.Xr sshd 1M
-+reads configuration data from
-+.Pa /etc/ssh/sshd_config
-+(or the file specified with
-+.Fl f
-+on the command line).
-+The file contains keyword-argument pairs, one per line.
-+Lines starting with
-+.Ql #
-+and empty lines are interpreted as comments.
-+Arguments may optionally be enclosed in double quotes
-+.Pq \&"
-+in order to represent arguments containing spaces.
-+.Pp
-+The possible
-+keywords and their meanings are as follows (note that
-+keywords are case-insensitive and arguments are case-sensitive):
-+.Bl -tag -width Ds
-+.It Cm AcceptEnv
-+Specifies what environment variables sent by the client will be copied into
-+the session's
-+.Xr environ 7 .
-+See
-+.Cm SendEnv
-+in
-+.Xr ssh_config 4
-+for how to configure the client.
-+Note that environment passing is only supported for protocol 2, and
-+that the
-+.Ev TERM
-+environment variable is always sent whenever the client
-+requests a pseudo-terminal as it is required by the protocol.
-+Variables are specified by name, which may contain the wildcard characters
-+.Ql *
-+and
-+.Ql \&? .
-+Multiple environment variables may be separated by whitespace or spread
-+across multiple
-+.Cm AcceptEnv
-+directives.
-+Be warned that some environment variables could be used to bypass restricted
-+user environments.
-+For this reason, care should be taken in the use of this directive.
-+The default is not to accept any environment variables.
-+.It Cm AddressFamily
-+Specifies which address family should be used by
-+.Xr sshd 1M .
-+Valid arguments are
-+.Dq any ,
-+.Dq inet
-+(use IPv4 only), or
-+.Dq inet6
-+(use IPv6 only).
-+The default is
-+.Dq any .
-+.It Cm AllowAgentForwarding
-+Specifies whether
-+.Xr ssh-agent 1
-+forwarding is permitted.
-+The default is
-+.Dq yes .
-+Note that disabling agent forwarding does not improve security
-+unless users are also denied shell access, as they can always install
-+their own forwarders.
-+.It Cm AllowGroups
-+This keyword can be followed by a list of group name patterns, separated
-+by spaces.
-+If specified, login is allowed only for users whose primary
-+group or supplementary group list matches one of the patterns.
-+Only group names are valid; a numerical group ID is not recognized.
-+By default, login is allowed for all groups.
-+The allow/deny directives are processed in the following order:
-+.Cm DenyUsers ,
-+.Cm AllowUsers ,
-+.Cm DenyGroups ,
-+and finally
-+.Cm AllowGroups .
-+.Pp
-+See PATTERNS in
-+.Xr ssh_config 4
-+for more information on patterns.
-+.It Cm AllowTcpForwarding
-+Specifies whether TCP forwarding is permitted.
-+The available options are
-+.Dq yes
-+or
-+.Dq all
-+to allow TCP forwarding,
-+.Dq no
-+to prevent all TCP forwarding,
-+.Dq local
-+to allow local (from the perspective of
-+.Xr ssh 1 )
-+forwarding only or
-+.Dq remote
-+to allow remote forwarding only.
-+The default is
-+.Dq yes .
-+Note that disabling TCP forwarding does not improve security unless
-+users are also denied shell access, as they can always install their
-+own forwarders.
-+.It Cm AllowStreamLocalForwarding
-+Specifies whether StreamLocal (Unix-domain socket) forwarding is permitted.
-+The available options are
-+.Dq yes
-+or
-+.Dq all
-+to allow StreamLocal forwarding,
-+.Dq no
-+to prevent all StreamLocal forwarding,
-+.Dq local
-+to allow local (from the perspective of
-+.Xr ssh 1 )
-+forwarding only or
-+.Dq remote
-+to allow remote forwarding only.
-+The default is
-+.Dq yes .
-+Note that disabling StreamLocal forwarding does not improve security unless
-+users are also denied shell access, as they can always install their
-+own forwarders.
-+.It Cm AllowUsers
-+This keyword can be followed by a list of user name patterns, separated
-+by spaces.
-+If specified, login is allowed only for user names that
-+match one of the patterns.
-+Only user names are valid; a numerical user ID is not recognized.
-+By default, login is allowed for all users.
-+If the pattern takes the form USER@HOST then USER and HOST
-+are separately checked, restricting logins to particular
-+users from particular hosts.
-+The allow/deny directives are processed in the following order:
-+.Cm DenyUsers ,
-+.Cm AllowUsers ,
-+.Cm DenyGroups ,
-+and finally
-+.Cm AllowGroups .
-+.Pp
-+See PATTERNS in
-+.Xr ssh_config 4
-+for more information on patterns.
-+.It Cm AuthenticationMethods
-+Specifies the authentication methods that must be successfully completed
-+for a user to be granted access.
-+This option must be followed by one or more comma-separated lists of
-+authentication method names.
-+Successful authentication requires completion of every method in at least
-+one of these lists.
-+.Pp
-+For example, an argument of
-+.Dq publickey,password publickey,keyboard-interactive
-+would require the user to complete public key authentication, followed by
-+either password or keyboard interactive authentication.
-+Only methods that are next in one or more lists are offered at each stage,
-+so for this example, it would not be possible to attempt password or
-+keyboard-interactive authentication before public key.
-+.Pp
-+For keyboard interactive authentication it is also possible to
-+restrict authentication to a specific device by appending a
-+colon followed by the device identifier
-+.Dq bsdauth ,
-+.Dq pam ,
-+or
-+.Dq skey ,
-+depending on the server configuration.
-+For example,
-+.Dq keyboard-interactive:bsdauth
-+would restrict keyboard interactive authentication to the
-+.Dq bsdauth
-+device.
-+.Pp
-+If the
-+.Dq publickey
-+method is listed more than once,
-+.Xr sshd 8
-+verifies that keys that have been used successfully are not reused for
-+subsequent authentications.
-+For example, an
-+.Cm AuthenticationMethods
-+of
-+.Dq publickey,publickey
-+will require successful authentication using two different public keys.
-+.Pp
-+This option is only available for SSH protocol 2 and will yield a fatal
-+error if enabled if protocol 1 is also enabled.
-+Note that each authentication method listed should also be explicitly enabled
-+in the configuration.
-+The default is not to require multiple authentication; successful completion
-+of a single authentication method is sufficient.
-+.It Cm AuthorizedKeysCommand
-+Specifies a program to be used to look up the user's public keys.
-+The program must be owned by root, not writable by group or others and
-+specified by an absolute path.
-+.Pp
-+Arguments to
-+.Cm AuthorizedKeysCommand
-+may be provided using the following tokens, which will be expanded
-+at runtime: %% is replaced by a literal '%', %u is replaced by the
-+username being authenticated, %h is replaced by the home directory
-+of the user being authenticated, %t is replaced with the key type
-+offered for authentication, %f is replaced with the fingerprint of
-+the key, and %k is replaced with the key being offered for authentication.
-+If no arguments are specified then the username of the target user
-+will be supplied.
-+.Pp
-+The program should produce on standard output zero or
-+more lines of authorized_keys output (see AUTHORIZED_KEYS in
-+.Xr sshd 1M ) .
-+If a key supplied by AuthorizedKeysCommand does not successfully authenticate
-+and authorize the user then public key authentication continues using the usual
-+.Cm AuthorizedKeysFile
-+files.
-+By default, no AuthorizedKeysCommand is run.
-+.It Cm AuthorizedKeysCommandUser
-+Specifies the user under whose account the AuthorizedKeysCommand is run.
-+It is recommended to use a dedicated user that has no other role on the host
-+than running authorized keys commands.
-+If
-+.Cm AuthorizedKeysCommand
-+is specified but
-+.Cm AuthorizedKeysCommandUser
-+is not, then
-+.Xr sshd 8
-+will refuse to start.
-+.It Cm AuthorizedKeysFile
-+Specifies the file that contains the public keys that can be used
-+for user authentication.
-+The format is described in the
-+AUTHORIZED_KEYS FILE FORMAT
-+section of
-+.Xr sshd 1M .
-+.Cm AuthorizedKeysFile
-+may contain tokens of the form %T which are substituted during connection
-+setup.
-+The following tokens are defined: %% is replaced by a literal '%',
-+%h is replaced by the home directory of the user being authenticated, and
-+%u is replaced by the username of that user.
-+After expansion,
-+.Cm AuthorizedKeysFile
-+is taken to be an absolute path or one relative to the user's home
-+directory.
-+Multiple files may be listed, separated by whitespace.
-+The default is
-+.Dq .ssh/authorized_keys .ssh/authorized_keys2 .
-+.It Cm AuthorizedPrincipalsCommand
-+Specifies a program to be used to generate the list of allowed
-+certificate principals as per
-+.Cm AuthorizedPrincipalsFile .
-+The program must be owned by root, not writable by group or others and
-+specified by an absolute path.
-+.Pp
-+Arguments to
-+.Cm AuthorizedPrincipalsCommand
-+may be provided using the following tokens, which will be expanded
-+at runtime: %% is replaced by a literal '%', %u is replaced by the
-+username being authenticated and %h is replaced by the home directory
-+of the user being authenticated.
-+.Pp
-+The program should produce on standard output zero or
-+more lines of
-+.Cm AuthorizedPrincipalsFile
-+output.
-+If either
-+.Cm AuthorizedPrincipalsCommand
-+or
-+.Cm AuthorizedPrincipalsFile
-+is specified, then certificates offered by the client for authentication
-+must contain a principal that is listed.
-+By default, no AuthorizedPrincipalsCommand is run.
-+.It Cm AuthorizedPrincipalsCommandUser
-+Specifies the user under whose account the AuthorizedPrincipalsCommand is run.
-+It is recommended to use a dedicated user that has no other role on the host
-+than running authorized principals commands.
-+If
-+.Cm AuthorizedPrincipalsCommand
-+is specified but
-+.Cm AuthorizedPrincipalsCommandUser
-+is not, then
-+.Xr sshd 8
-+will refuse to start.
-+.It Cm AuthorizedPrincipalsFile
-+Specifies a file that lists principal names that are accepted for
-+certificate authentication.
-+When using certificates signed by a key listed in
-+.Cm TrustedUserCAKeys ,
-+this file lists names, one of which must appear in the certificate for it
-+to be accepted for authentication.
-+Names are listed one per line preceded by key options (as described
-+in AUTHORIZED_KEYS FILE FORMAT in
-+.Xr sshd 1M ) .
-+Empty lines and comments starting with
-+.Ql #
-+are ignored.
-+.Pp
-+.Cm AuthorizedPrincipalsFile
-+may contain tokens of the form %T which are substituted during connection
-+setup.
-+The following tokens are defined: %% is replaced by a literal '%',
-+%h is replaced by the home directory of the user being authenticated, and
-+%u is replaced by the username of that user.
-+After expansion,
-+.Cm AuthorizedPrincipalsFile
-+is taken to be an absolute path or one relative to the user's home
-+directory.
-+.Pp
-+The default is
-+.Dq none ,
-+i.e. not to use a principals file \(en in this case, the username
-+of the user must appear in a certificate's principals list for it to be
-+accepted.
-+Note that
-+.Cm AuthorizedPrincipalsFile
-+is only used when authentication proceeds using a CA listed in
-+.Cm TrustedUserCAKeys
-+and is not consulted for certification authorities trusted via
-+.Pa ~/.ssh/authorized_keys ,
-+though the
-+.Cm principals=
-+key option offers a similar facility (see
-+.Xr sshd 1M
-+for details).
-+.It Cm Banner
-+The contents of the specified file are sent to the remote user before
-+authentication is allowed.
-+If the argument is
-+.Dq none
-+then no banner is displayed.
-+This option is only available for protocol version 2.
-+By default, no banner is displayed.
-+.It Cm ChallengeResponseAuthentication
-+Specifies whether challenge-response authentication is allowed (e.g. via
-+PAM or through authentication styles supported in
-+.Xr login.conf 5 )
-+The default is
-+.Dq yes .
-+.It Cm ChrootDirectory
-+Specifies the pathname of a directory to
-+.Xr chroot 2
-+to after authentication.
-+At session startup
-+.Xr sshd 8
-+checks that all components of the pathname are root-owned directories
-+which are not writable by any other user or group.
-+After the chroot,
-+.Xr sshd 1M
-+changes the working directory to the user's home directory.
-+.Pp
-+The pathname may contain the following tokens that are expanded at runtime once
-+the connecting user has been authenticated: %% is replaced by a literal '%',
-+%h is replaced by the home directory of the user being authenticated, and
-+%u is replaced by the username of that user.
-+.Pp
-+The
-+.Cm ChrootDirectory
-+must contain the necessary files and directories to support the
-+user's session.
-+For an interactive session this requires at least a shell, typically
-+.Xr sh 1 ,
-+and basic
-+.Pa /dev
-+nodes such as
-+.Xr null 4 ,
-+.Xr zero 4 ,
-+.Xr stdin 4 ,
-+.Xr stdout 4 ,
-+.Xr stderr 4 ,
-+and
-+.Xr tty 4
-+devices.
-+For file transfer sessions using
-+.Dq sftp ,
-+no additional configuration of the environment is necessary if the
-+in-process sftp server is used,
-+though sessions which use logging may require
-+.Pa /dev/log
-+inside the chroot directory on some operating systems (see
-+.Xr sftp-server 8
-+for details).
-+.Pp
-+For safety, it is very important that the directory hierarchy be
-+prevented from modification by other processes on the system (especially
-+those outside the jail).
-+Misconfiguration can lead to unsafe environments which
-+.Xr sshd 8
-+cannot detect.
-+.Pp
-+The default is not to
-+.Xr chroot 2 .
-+.It Cm Ciphers
-+Specifies the ciphers allowed for protocol version 2.
-+Multiple ciphers must be comma-separated.
-+If the specified value begins with a
-+.Sq +
-+character, then the specified ciphers will be appended to the default set
-+instead of replacing them.
-+.Pp
-+The supported ciphers are:
-+.Pp
-+.Bl -item -compact -offset indent
-+.It
-+3des-cbc
-+.It
-+aes128-cbc
-+.It
-+aes192-cbc
-+.It
-+aes256-cbc
-+.It
-+aes128-ctr
-+.It
-+aes192-ctr
-+.It
-+aes256-ctr
-+.It
-+aes128-gcm@openssh.com
-+.It
-+aes256-gcm@openssh.com
-+.It
-+arcfour
-+.It
-+arcfour128
-+.It
-+arcfour256
-+.It
-+blowfish-cbc
-+.It
-+cast128-cbc
-+.It
-+chacha20-poly1305@openssh.com
-+.El
-+.Pp
-+The default is:
-+.Bd -literal -offset indent
-+chacha20-poly1305@openssh.com,
-+aes128-ctr,aes192-ctr,aes256-ctr,
-+aes128-gcm@openssh.com,aes256-gcm@openssh.com
-+.Ed
-+.Pp
-+The list of available ciphers may also be obtained using the
-+.Fl Q
-+option of
-+.Xr ssh 1
-+with an argument of
-+.Dq cipher .
-+.It Cm ClientAliveCountMax
-+Sets the number of client alive messages (see below) which may be
-+sent without
-+.Xr sshd 1M
-+receiving any messages back from the client.
-+If this threshold is reached while client alive messages are being sent,
-+sshd will disconnect the client, terminating the session.
-+It is important to note that the use of client alive messages is very
-+different from
-+.Cm TCPKeepAlive
-+(below).
-+The client alive messages are sent through the encrypted channel
-+and therefore will not be spoofable.
-+The TCP keepalive option enabled by
-+.Cm TCPKeepAlive
-+is spoofable.
-+The client alive mechanism is valuable when the client or
-+server depend on knowing when a connection has become inactive.
-+.Pp
-+The default value is 3.
-+If
-+.Cm ClientAliveInterval
-+(see below) is set to 15, and
-+.Cm ClientAliveCountMax
-+is left at the default, unresponsive SSH clients
-+will be disconnected after approximately 45 seconds.
-+This option applies to protocol version 2 only.
-+.It Cm ClientAliveInterval
-+Sets a timeout interval in seconds after which if no data has been received
-+from the client,
-+.Xr sshd 1M
-+will send a message through the encrypted
-+channel to request a response from the client.
-+The default
-+is 0, indicating that these messages will not be sent to the client.
-+This option applies to protocol version 2 only.
-+.It Cm Compression
-+Specifies whether compression is allowed, or delayed until
-+the user has authenticated successfully.
-+The argument must be
-+.Dq yes ,
-+.Dq delayed ,
-+or
-+.Dq no .
-+The default is
-+.Dq delayed .
-+.It Cm DenyGroups
-+This keyword can be followed by a list of group name patterns, separated
-+by spaces.
-+Login is disallowed for users whose primary group or supplementary
-+group list matches one of the patterns.
-+Only group names are valid; a numerical group ID is not recognized.
-+By default, login is allowed for all groups.
-+The allow/deny directives are processed in the following order:
-+.Cm DenyUsers ,
-+.Cm AllowUsers ,
-+.Cm DenyGroups ,
-+and finally
-+.Cm AllowGroups .
-+.Pp
-+See PATTERNS in
-+.Xr ssh_config 4
-+for more information on patterns.
-+.It Cm DenyUsers
-+This keyword can be followed by a list of user name patterns, separated
-+by spaces.
-+Login is disallowed for user names that match one of the patterns.
-+Only user names are valid; a numerical user ID is not recognized.
-+By default, login is allowed for all users.
-+If the pattern takes the form USER@HOST then USER and HOST
-+are separately checked, restricting logins to particular
-+users from particular hosts.
-+The allow/deny directives are processed in the following order:
-+.Cm DenyUsers ,
-+.Cm AllowUsers ,
-+.Cm DenyGroups ,
-+and finally
-+.Cm AllowGroups .
-+.Pp
-+See PATTERNS in
-+.Xr ssh_config 4
-+for more information on patterns.
-+.It Cm FingerprintHash
-+Specifies the hash algorithm used when logging key fingerprints.
-+Valid options are:
-+.Dq md5
-+and
-+.Dq sha256 .
-+The default is
-+.Dq sha256 .
-+.It Cm ForceCommand
-+Forces the execution of the command specified by
-+.Cm ForceCommand ,
-+ignoring any command supplied by the client and
-+.Pa ~/.ssh/rc
-+if present.
-+The command is invoked by using the user's login shell with the -c option.
-+This applies to shell, command, or subsystem execution.
-+It is most useful inside a
-+.Cm Match
-+block.
-+The command originally supplied by the client is available in the
-+.Ev SSH_ORIGINAL_COMMAND
-+environment variable.
-+Specifying a command of
-+.Dq internal-sftp
-+will force the use of an in-process sftp server that requires no support
-+files when used with
-+.Cm ChrootDirectory .
-+.It Cm GatewayPorts
-+Specifies whether remote hosts are allowed to connect to ports
-+forwarded for the client.
-+By default,
-+.Xr sshd 1M
-+binds remote port forwardings to the loopback address.
-+This prevents other remote hosts from connecting to forwarded ports.
-+.Cm GatewayPorts
-+can be used to specify that sshd
-+should allow remote port forwardings to bind to non-loopback addresses, thus
-+allowing other hosts to connect.
-+The argument may be
-+.Dq no
-+to force remote port forwardings to be available to the local host only,
-+.Dq yes
-+to force remote port forwardings to bind to the wildcard address, or
-+.Dq clientspecified
-+to allow the client to select the address to which the forwarding is bound.
-+The default is
-+.Dq no .
-+.It Cm GSSAPIAuthentication
-+Specifies whether user authentication based on GSSAPI is allowed.
-+The default is
-+.Dq no .
-+Note that this option applies to protocol version 2 only.
-+.It Cm GSSAPICleanupCredentials
-+Specifies whether to automatically destroy the user's credentials cache
-+on logout.
-+The default is
-+.Dq yes .
-+Note that this option applies to protocol version 2 only.
-+.It Cm GSSAPIStrictAcceptorCheck
-+Determines whether to be strict about the identity of the GSSAPI acceptor
-+a client authenticates against.
-+If set to
-+.Dq yes
-+then the client must authenticate against the
-+.Pa host
-+service on the current hostname.
-+If set to
-+.Dq no
-+then the client may authenticate against any service key stored in the
-+machine's default store.
-+This facility is provided to assist with operation on multi homed machines.
-+The default is
-+.Dq yes .
-+.It Cm HostbasedAcceptedKeyTypes
-+Specifies the key types that will be accepted for hostbased authentication
-+as a comma-separated pattern list.
-+Alternately if the specified value begins with a
-+.Sq +
-+character, then the specified key types will be appended to the default set
-+instead of replacing them.
-+The default for this option is:
-+.Bd -literal -offset 3n
-+ecdsa-sha2-nistp256-cert-v01@openssh.com,
-+ecdsa-sha2-nistp384-cert-v01@openssh.com,
-+ecdsa-sha2-nistp521-cert-v01@openssh.com,
-+ssh-ed25519-cert-v01@openssh.com,
-+ssh-rsa-cert-v01@openssh.com,
-+ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
-+ssh-ed25519,ssh-rsa
-+.Ed
-+.Pp
-+The
-+.Fl Q
-+option of
-+.Xr ssh 1
-+may be used to list supported key types.
-+.It Cm HostbasedAuthentication
-+Specifies whether rhosts or /etc/hosts.equiv authentication together
-+with successful public key client host authentication is allowed
-+(host-based authentication).
-+This option is similar to
-+.Cm RhostsRSAAuthentication
-+and applies to protocol version 2 only.
-+The default is
-+.Dq no .
-+.It Cm HostbasedUsesNameFromPacketOnly
-+Specifies whether or not the server will attempt to perform a reverse
-+name lookup when matching the name in the
-+.Pa ~/.shosts ,
-+.Pa ~/.rhosts ,
-+and
-+.Pa /etc/hosts.equiv
-+files during
-+.Cm HostbasedAuthentication .
-+A setting of
-+.Dq yes
-+means that
-+.Xr sshd 1M
-+uses the name supplied by the client rather than
-+attempting to resolve the name from the TCP connection itself.
-+The default is
-+.Dq no .
-+.It Cm HostCertificate
-+Specifies a file containing a public host certificate.
-+The certificate's public key must match a private host key already specified
-+by
-+.Cm HostKey .
-+The default behaviour of
-+.Xr sshd 1M
-+is not to load any certificates.
-+.It Cm HostKey
-+Specifies a file containing a private host key
-+used by SSH.
-+The default is
-+.Pa /etc/ssh/ssh_host_key
-+for protocol version 1, and
-+.Pa /etc/ssh/ssh_host_dsa_key ,
-+.Pa /etc/ssh/ssh_host_ecdsa_key ,
-+.Pa /etc/ssh/ssh_host_ed25519_key
-+and
-+.Pa /etc/ssh/ssh_host_rsa_key
-+for protocol version 2.
-+.Pp
-+Note that
-+.Xr sshd 1M
-+will refuse to use a file if it is group/world-accessible
-+and that the
-+.Cm HostKeyAlgorithms
-+option restricts which of the keys are actually used by
-+.Xr sshd 1M .
-+.Pp
-+It is possible to have multiple host key files.
-+.Dq rsa1
-+keys are used for version 1 and
-+.Dq dsa ,
-+.Dq ecdsa ,
-+.Dq ed25519
-+or
-+.Dq rsa
-+are used for version 2 of the SSH protocol.
-+It is also possible to specify public host key files instead.
-+In this case operations on the private key will be delegated
-+to an
-+.Xr ssh-agent 1 .
-+.It Cm HostKeyAgent
-+Identifies the UNIX-domain socket used to communicate
-+with an agent that has access to the private host keys.
-+If
-+.Dq SSH_AUTH_SOCK
-+is specified, the location of the socket will be read from the
-+.Ev SSH_AUTH_SOCK
-+environment variable.
-+.It Cm HostKeyAlgorithms
-+Specifies the protocol version 2 host key algorithms
-+that the server offers.
-+The default for this option is:
-+.Bd -literal -offset 3n
-+ecdsa-sha2-nistp256-cert-v01@openssh.com,
-+ecdsa-sha2-nistp384-cert-v01@openssh.com,
-+ecdsa-sha2-nistp521-cert-v01@openssh.com,
-+ssh-ed25519-cert-v01@openssh.com,
-+ssh-rsa-cert-v01@openssh.com,
-+ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
-+ssh-ed25519,ssh-rsa
-+.Ed
-+.Pp
-+The list of available key types may also be obtained using the
-+.Fl Q
-+option of
-+.Xr ssh 1
-+with an argument of
-+.Dq key .
-+.It Cm IgnoreRhosts
-+Specifies that
-+.Pa .rhosts
-+and
-+.Pa .shosts
-+files will not be used in
-+.Cm RhostsRSAAuthentication
-+or
-+.Cm HostbasedAuthentication .
-+.Pp
-+.Pa /etc/hosts.equiv
-+and
-+.Pa /etc/shosts.equiv
-+are still used.
-+The default is
-+.Dq yes .
-+.It Cm IgnoreUserKnownHosts
-+Specifies whether
-+.Xr sshd 1M
-+should ignore the user's
-+.Pa ~/.ssh/known_hosts
-+during
-+.Cm RhostsRSAAuthentication
-+or
-+.Cm HostbasedAuthentication .
-+The default is
-+.Dq no .
-+.It Cm IPQoS
-+Specifies the IPv4 type-of-service or DSCP class for the connection.
-+Accepted values are
-+.Dq af11 ,
-+.Dq af12 ,
-+.Dq af13 ,
-+.Dq af21 ,
-+.Dq af22 ,
-+.Dq af23 ,
-+.Dq af31 ,
-+.Dq af32 ,
-+.Dq af33 ,
-+.Dq af41 ,
-+.Dq af42 ,
-+.Dq af43 ,
-+.Dq cs0 ,
-+.Dq cs1 ,
-+.Dq cs2 ,
-+.Dq cs3 ,
-+.Dq cs4 ,
-+.Dq cs5 ,
-+.Dq cs6 ,
-+.Dq cs7 ,
-+.Dq ef ,
-+.Dq lowdelay ,
-+.Dq throughput ,
-+.Dq reliability ,
-+or a numeric value.
-+This option may take one or two arguments, separated by whitespace.
-+If one argument is specified, it is used as the packet class unconditionally.
-+If two values are specified, the first is automatically selected for
-+interactive sessions and the second for non-interactive sessions.
-+The default is
-+.Dq lowdelay
-+for interactive sessions and
-+.Dq throughput
-+for non-interactive sessions.
-+.It Cm KbdInteractiveAuthentication
-+Specifies whether to allow keyboard-interactive authentication.
-+The argument to this keyword must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is to use whatever value
-+.Cm ChallengeResponseAuthentication
-+is set to
-+(by default
-+.Dq yes ) .
-+.It Cm KerberosAuthentication
-+Specifies whether the password provided by the user for
-+.Cm PasswordAuthentication
-+will be validated through the Kerberos KDC.
-+To use this option, the server needs a
-+Kerberos servtab which allows the verification of the KDC's identity.
-+The default is
-+.Dq no .
-+.It Cm KerberosGetAFSToken
-+If AFS is active and the user has a Kerberos 5 TGT, attempt to acquire
-+an AFS token before accessing the user's home directory.
-+The default is
-+.Dq no .
-+.It Cm KerberosOrLocalPasswd
-+If password authentication through Kerberos fails then
-+the password will be validated via any additional local mechanism
-+such as
-+.Pa /etc/passwd .
-+The default is
-+.Dq yes .
-+.It Cm KerberosTicketCleanup
-+Specifies whether to automatically destroy the user's ticket cache
-+file on logout.
-+The default is
-+.Dq yes .
-+.It Cm KexAlgorithms
-+Specifies the available KEX (Key Exchange) algorithms.
-+Multiple algorithms must be comma-separated.
-+Alternately if the specified value begins with a
-+.Sq +
-+character, then the specified methods will be appended to the default set
-+instead of replacing them.
-+The supported algorithms are:
-+.Pp
-+.Bl -item -compact -offset indent
-+.It
-+curve25519-sha256@libssh.org
-+.It
-+diffie-hellman-group1-sha1
-+.It
-+diffie-hellman-group14-sha1
-+.It
-+diffie-hellman-group-exchange-sha1
-+.It
-+diffie-hellman-group-exchange-sha256
-+.It
-+ecdh-sha2-nistp256
-+.It
-+ecdh-sha2-nistp384
-+.It
-+ecdh-sha2-nistp521
-+.El
-+.Pp
-+The default is:
-+.Bd -literal -offset indent
-+curve25519-sha256@libssh.org,
-+ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,
-+diffie-hellman-group-exchange-sha256,
-+diffie-hellman-group14-sha1
-+.Ed
-+.Pp
-+The list of available key exchange algorithms may also be obtained using the
-+.Fl Q
-+option of
-+.Xr ssh 1
-+with an argument of
-+.Dq kex .
-+.It Cm KeyRegenerationInterval
-+In protocol version 1, the ephemeral server key is automatically regenerated
-+after this many seconds (if it has been used).
-+The purpose of regeneration is to prevent
-+decrypting captured sessions by later breaking into the machine and
-+stealing the keys.
-+The key is never stored anywhere.
-+If the value is 0, the key is never regenerated.
-+The default is 3600 (seconds).
-+.It Cm ListenAddress
-+Specifies the local addresses
-+.Xr sshd 1M
-+should listen on.
-+The following forms may be used:
-+.Pp
-+.Bl -item -offset indent -compact
-+.It
-+.Cm ListenAddress
-+.Sm off
-+.Ar host | Ar IPv4_addr | Ar IPv6_addr
-+.Sm on
-+.It
-+.Cm ListenAddress
-+.Sm off
-+.Ar host | Ar IPv4_addr : Ar port
-+.Sm on
-+.It
-+.Cm ListenAddress
-+.Sm off
-+.Oo
-+.Ar host | Ar IPv6_addr Oc : Ar port
-+.Sm on
-+.El
-+.Pp
-+If
-+.Ar port
-+is not specified,
-+sshd will listen on the address and all
-+.Cm Port
-+options specified.
-+The default is to listen on all local addresses.
-+Multiple
-+.Cm ListenAddress
-+options are permitted.
-+.It Cm LoginGraceTime
-+The server disconnects after this time if the user has not
-+successfully logged in.
-+If the value is 0, there is no time limit.
-+The default is 120 seconds.
-+.It Cm LogLevel
-+Gives the verbosity level that is used when logging messages from
-+.Xr sshd 1M .
-+The possible values are:
-+QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3.
-+The default is INFO.
-+DEBUG and DEBUG1 are equivalent.
-+DEBUG2 and DEBUG3 each specify higher levels of debugging output.
-+Logging with a DEBUG level violates the privacy of users and is not recommended.
-+.It Cm MACs
-+Specifies the available MAC (message authentication code) algorithms.
-+The MAC algorithm is used in protocol version 2
-+for data integrity protection.
-+Multiple algorithms must be comma-separated.
-+If the specified value begins with a
-+.Sq +
-+character, then the specified algorithms will be appended to the default set
-+instead of replacing them.
-+.Pp
-+The algorithms that contain
-+.Dq -etm
-+calculate the MAC after encryption (encrypt-then-mac).
-+These are considered safer and their use recommended.
-+The supported MACs are:
-+.Pp
-+.Bl -item -compact -offset indent
-+.It
-+hmac-md5
-+.It
-+hmac-md5-96
-+.It
-+hmac-ripemd160
-+.It
-+hmac-sha1
-+.It
-+hmac-sha1-96
-+.It
-+hmac-sha2-256
-+.It
-+hmac-sha2-512
-+.It
-+umac-64@openssh.com
-+.It
-+umac-128@openssh.com
-+.It
-+hmac-md5-etm@openssh.com
-+.It
-+hmac-md5-96-etm@openssh.com
-+.It
-+hmac-ripemd160-etm@openssh.com
-+.It
-+hmac-sha1-etm@openssh.com
-+.It
-+hmac-sha1-96-etm@openssh.com
-+.It
-+hmac-sha2-256-etm@openssh.com
-+.It
-+hmac-sha2-512-etm@openssh.com
-+.It
-+umac-64-etm@openssh.com
-+.It
-+umac-128-etm@openssh.com
-+.El
-+.Pp
-+The default is:
-+.Bd -literal -offset indent
-+umac-64-etm@openssh.com,umac-128-etm@openssh.com,
-+hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,
-+umac-64@openssh.com,umac-128@openssh.com,
-+hmac-sha2-256,hmac-sha2-512
-+.Ed
-+.Pp
-+The list of available MAC algorithms may also be obtained using the
-+.Fl Q
-+option of
-+.Xr ssh 1
-+with an argument of
-+.Dq mac .
-+.It Cm Match
-+Introduces a conditional block.
-+If all of the criteria on the
-+.Cm Match
-+line are satisfied, the keywords on the following lines override those
-+set in the global section of the config file, until either another
-+.Cm Match
-+line or the end of the file.
-+If a keyword appears in multiple
-+.Cm Match
-+blocks that are satisfied, only the first instance of the keyword is
-+applied.
-+.Pp
-+The arguments to
-+.Cm Match
-+are one or more criteria-pattern pairs or the single token
-+.Cm All
-+which matches all criteria.
-+The available criteria are
-+.Cm User ,
-+.Cm Group ,
-+.Cm Host ,
-+.Cm LocalAddress ,
-+.Cm LocalPort ,
-+and
-+.Cm Address .
-+The match patterns may consist of single entries or comma-separated
-+lists and may use the wildcard and negation operators described in the
-+PATTERNS section of
-+.Xr ssh_config 4 .
-+.Pp
-+The patterns in an
-+.Cm Address
-+criteria may additionally contain addresses to match in CIDR
-+address/masklen format, e.g.\&
-+.Dq 192.0.2.0/24
-+or
-+.Dq 3ffe:ffff::/32 .
-+Note that the mask length provided must be consistent with the address -
-+it is an error to specify a mask length that is too long for the address
-+or one with bits set in this host portion of the address.
-+For example,
-+.Dq 192.0.2.0/33
-+and
-+.Dq 192.0.2.0/8
-+respectively.
-+.Pp
-+Only a subset of keywords may be used on the lines following a
-+.Cm Match
-+keyword.
-+Available keywords are
-+.Cm AcceptEnv ,
-+.Cm AllowAgentForwarding ,
-+.Cm AllowGroups ,
-+.Cm AllowStreamLocalForwarding ,
-+.Cm AllowTcpForwarding ,
-+.Cm AllowUsers ,
-+.Cm AuthenticationMethods ,
-+.Cm AuthorizedKeysCommand ,
-+.Cm AuthorizedKeysCommandUser ,
-+.Cm AuthorizedKeysFile ,
-+.Cm AuthorizedPrincipalsFile ,
-+.Cm Banner ,
-+.Cm ChrootDirectory ,
-+.Cm DenyGroups ,
-+.Cm DenyUsers ,
-+.Cm ForceCommand ,
-+.Cm GatewayPorts ,
-+.Cm GSSAPIAuthentication ,
-+.Cm HostbasedAcceptedKeyTypes ,
-+.Cm HostbasedAuthentication ,
-+.Cm HostbasedUsesNameFromPacketOnly ,
-+.Cm IPQoS ,
-+.Cm KbdInteractiveAuthentication ,
-+.Cm KerberosAuthentication ,
-+.Cm MaxAuthTries ,
-+.Cm MaxSessions ,
-+.Cm PasswordAuthentication ,
-+.Cm PermitEmptyPasswords ,
-+.Cm PermitOpen ,
-+.Cm PermitRootLogin ,
-+.Cm PermitTTY ,
-+.Cm PermitTunnel ,
-+.Cm PermitUserRC ,
-+.Cm PubkeyAcceptedKeyTypes ,
-+.Cm PubkeyAuthentication ,
-+.Cm RekeyLimit ,
-+.Cm RevokedKeys ,
-+.Cm RhostsRSAAuthentication ,
-+.Cm RSAAuthentication ,
-+.Cm StreamLocalBindMask ,
-+.Cm StreamLocalBindUnlink ,
-+.Cm TrustedUserCAKeys ,
-+.Cm X11DisplayOffset ,
-+.Cm X11Forwarding
-+and
-+.Cm X11UseLocalHost .
-+.It Cm MaxAuthTries
-+Specifies the maximum number of authentication attempts permitted per
-+connection.
-+Once the number of failures reaches half this value,
-+additional failures are logged.
-+The default is 6.
-+.It Cm MaxSessions
-+Specifies the maximum number of open sessions permitted per network connection.
-+The default is 10.
-+.It Cm MaxStartups
-+Specifies the maximum number of concurrent unauthenticated connections to the
-+SSH daemon.
-+Additional connections will be dropped until authentication succeeds or the
-+.Cm LoginGraceTime
-+expires for a connection.
-+The default is 10:30:100.
-+.Pp
-+Alternatively, random early drop can be enabled by specifying
-+the three colon separated values
-+.Dq start:rate:full
-+(e.g. "10:30:60").
-+.Xr sshd 1M
-+will refuse connection attempts with a probability of
-+.Dq rate/100
-+(30%)
-+if there are currently
-+.Dq start
-+(10)
-+unauthenticated connections.
-+The probability increases linearly and all connection attempts
-+are refused if the number of unauthenticated connections reaches
-+.Dq full
-+(60).
-+.It Cm PasswordAuthentication
-+Specifies whether password authentication is allowed.
-+The default is
-+.Dq yes .
-+.It Cm PermitEmptyPasswords
-+When password authentication is allowed, it specifies whether the
-+server allows login to accounts with empty password strings.
-+The default is
-+.Dq no .
-+.It Cm PermitOpen
-+Specifies the destinations to which TCP port forwarding is permitted.
-+The forwarding specification must be one of the following forms:
-+.Pp
-+.Bl -item -offset indent -compact
-+.It
-+.Cm PermitOpen
-+.Sm off
-+.Ar host : port
-+.Sm on
-+.It
-+.Cm PermitOpen
-+.Sm off
-+.Ar IPv4_addr : port
-+.Sm on
-+.It
-+.Cm PermitOpen
-+.Sm off
-+.Ar \&[ IPv6_addr \&] : port
-+.Sm on
-+.El
-+.Pp
-+Multiple forwards may be specified by separating them with whitespace.
-+An argument of
-+.Dq any
-+can be used to remove all restrictions and permit any forwarding requests.
-+An argument of
-+.Dq none
-+can be used to prohibit all forwarding requests.
-+By default all port forwarding requests are permitted.
-+.It Cm PermitRootLogin
-+Specifies whether root can log in using
-+.Xr ssh 1 .
-+The argument must be
-+.Dq yes ,
-+.Dq prohibit-password ,
-+.Dq without-password ,
-+.Dq forced-commands-only ,
-+or
-+.Dq no .
-+The default is
-+.Dq prohibit-password .
-+.Pp
-+If this option is set to
-+.Dq prohibit-password
-+or
-+.Dq without-password ,
-+password and keyboard-interactive authentication are disabled for root.
-+.Pp
-+If this option is set to
-+.Dq forced-commands-only ,
-+root login with public key authentication will be allowed,
-+but only if the
-+.Ar command
-+option has been specified
-+(which may be useful for taking remote backups even if root login is
-+normally not allowed).
-+All other authentication methods are disabled for root.
-+.Pp
-+If this option is set to
-+.Dq no ,
-+root is not allowed to log in.
-+.It Cm PermitTunnel
-+Specifies whether
-+.Xr tun 4
-+device forwarding is allowed.
-+The argument must be
-+.Dq yes ,
-+.Dq point-to-point
-+(layer 3),
-+.Dq ethernet
-+(layer 2), or
-+.Dq no .
-+Specifying
-+.Dq yes
-+permits both
-+.Dq point-to-point
-+and
-+.Dq ethernet .
-+The default is
-+.Dq no .
-+.Pp
-+Independent of this setting, the permissions of the selected
-+.Xr tun 4
-+device must allow access to the user.
-+.It Cm PermitTTY
-+Specifies whether
-+.Xr pty 4
-+allocation is permitted.
-+The default is
-+.Dq yes .
-+.It Cm PermitUserEnvironment
-+Specifies whether
-+.Pa ~/.ssh/environment
-+and
-+.Cm environment=
-+options in
-+.Pa ~/.ssh/authorized_keys
-+are processed by
-+.Xr sshd 1M .
-+The default is
-+.Dq no .
-+Enabling environment processing may enable users to bypass access
-+restrictions in some configurations using mechanisms such as
-+.Ev LD_PRELOAD .
-+.It Cm PermitUserRC
-+Specifies whether any
-+.Pa ~/.ssh/rc
-+file is executed.
-+The default is
-+.Dq yes .
-+.It Cm PidFile
-+Specifies the file that contains the process ID of the
-+SSH daemon, or
-+.Dq none
-+to not write one.
-+The default is
-+.Pa /var/run/sshd.pid .
-+.It Cm Port
-+Specifies the port number that
-+.Xr sshd 1M
-+listens on.
-+The default is 22.
-+Multiple options of this type are permitted.
-+See also
-+.Cm ListenAddress .
-+.It Cm PrintLastLog
-+Specifies whether
-+.Xr sshd 1M
-+should print the date and time of the last user login when a user logs
-+in interactively.
-+On Solaris this option is always ignored since pam_unix_session(5)
-+reports the last login time.
-+.It Cm PrintMotd
-+Specifies whether
-+.Xr sshd 1M
-+should print
-+.Pa /etc/motd
-+when a user logs in interactively.
-+(On some systems it is also printed by the shell,
-+.Pa /etc/profile ,
-+or equivalent.)
-+The default is
-+.Dq yes .
-+.It Cm Protocol
-+Specifies the protocol versions
-+.Xr sshd 1M
-+supports.
-+The possible values are
-+.Sq 1
-+and
-+.Sq 2 .
-+Multiple versions must be comma-separated.
-+The default is
-+.Sq 2 .
-+Note that the order of the protocol list does not indicate preference,
-+because the client selects among multiple protocol versions offered
-+by the server.
-+Specifying
-+.Dq 2,1
-+is identical to
-+.Dq 1,2 .
-+.It Cm PubkeyAcceptedKeyTypes
-+Specifies the key types that will be accepted for public key authentication
-+as a comma-separated pattern list.
-+Alternately if the specified value begins with a
-+.Sq +
-+character, then the specified key types will be appended to the default set
-+instead of replacing them.
-+The default for this option is:
-+.Bd -literal -offset 3n
-+ecdsa-sha2-nistp256-cert-v01@openssh.com,
-+ecdsa-sha2-nistp384-cert-v01@openssh.com,
-+ecdsa-sha2-nistp521-cert-v01@openssh.com,
-+ssh-ed25519-cert-v01@openssh.com,
-+ssh-rsa-cert-v01@openssh.com,
-+ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
-+ssh-ed25519,ssh-rsa
-+.Ed
-+.Pp
-+The
-+.Fl Q
-+option of
-+.Xr ssh 1
-+may be used to list supported key types.
-+.It Cm PubkeyAuthentication
-+Specifies whether public key authentication is allowed.
-+The default is
-+.Dq yes .
-+Note that this option applies to protocol version 2 only.
-+.It Cm RekeyLimit
-+Specifies the maximum amount of data that may be transmitted before the
-+session key is renegotiated, optionally followed a maximum amount of
-+time that may pass before the session key is renegotiated.
-+The first argument is specified in bytes and may have a suffix of
-+.Sq K ,
-+.Sq M ,
-+or
-+.Sq G
-+to indicate Kilobytes, Megabytes, or Gigabytes, respectively.
-+The default is between
-+.Sq 1G
-+and
-+.Sq 4G ,
-+depending on the cipher.
-+The optional second value is specified in seconds and may use any of the
-+units documented in the
-+.Sx TIME FORMATS
-+section.
-+The default value for
-+.Cm RekeyLimit
-+is
-+.Dq default none ,
-+which means that rekeying is performed after the cipher's default amount
-+of data has been sent or received and no time based rekeying is done.
-+This option applies to protocol version 2 only.
-+.It Cm RevokedKeys
-+Specifies revoked public keys file, or
-+.Dq none
-+to not use one.
-+Keys listed in this file will be refused for public key authentication.
-+Note that if this file is not readable, then public key authentication will
-+be refused for all users.
-+Keys may be specified as a text file, listing one public key per line, or as
-+an OpenSSH Key Revocation List (KRL) as generated by
-+.Xr ssh-keygen 1 .
-+For more information on KRLs, see the KEY REVOCATION LISTS section in
-+.Xr ssh-keygen 1 .
-+.It Cm RhostsRSAAuthentication
-+Specifies whether rhosts or /etc/hosts.equiv authentication together
-+with successful RSA host authentication is allowed.
-+The default is
-+.Dq no .
-+This option applies to protocol version 1 only.
-+.It Cm RSAAuthentication
-+Specifies whether pure RSA authentication is allowed.
-+The default is
-+.Dq yes .
-+This option applies to protocol version 1 only.
-+.It Cm ServerKeyBits
-+Defines the number of bits in the ephemeral protocol version 1 server key.
-+The default and minimum value is 1024.
-+.It Cm StreamLocalBindMask
-+Sets the octal file creation mode mask
-+.Pq umask
-+used when creating a Unix-domain socket file for local or remote
-+port forwarding.
-+This option is only used for port forwarding to a Unix-domain socket file.
-+.Pp
-+The default value is 0177, which creates a Unix-domain socket file that is
-+readable and writable only by the owner.
-+Note that not all operating systems honor the file mode on Unix-domain
-+socket files.
-+.It Cm StreamLocalBindUnlink
-+Specifies whether to remove an existing Unix-domain socket file for local
-+or remote port forwarding before creating a new one.
-+If the socket file already exists and
-+.Cm StreamLocalBindUnlink
-+is not enabled,
-+.Nm sshd
-+will be unable to forward the port to the Unix-domain socket file.
-+This option is only used for port forwarding to a Unix-domain socket file.
-+.Pp
-+The argument must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is
-+.Dq no .
-+.It Cm StrictModes
-+Specifies whether
-+.Xr sshd 1M
-+should check file modes and ownership of the
-+user's files and home directory before accepting login.
-+This is normally desirable because novices sometimes accidentally leave their
-+directory or files world-writable.
-+The default is
-+.Dq yes .
-+Note that this does not apply to
-+.Cm ChrootDirectory ,
-+whose permissions and ownership are checked unconditionally.
-+.It Cm Subsystem
-+Configures an external subsystem (e.g. file transfer daemon).
-+Arguments should be a subsystem name and a command (with optional arguments)
-+to execute upon subsystem request.
-+.Pp
-+The command
-+.Xr sftp-server 8
-+implements the
-+.Dq sftp
-+file transfer subsystem.
-+.Pp
-+Alternately the name
-+.Dq internal-sftp
-+implements an in-process
-+.Dq sftp
-+server.
-+This may simplify configurations using
-+.Cm ChrootDirectory
-+to force a different filesystem root on clients.
-+.Pp
-+By default no subsystems are defined.
-+Note that this option applies to protocol version 2 only.
-+.It Cm SyslogFacility
-+Gives the facility code that is used when logging messages from
-+.Xr sshd 1M .
-+The possible values are: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2,
-+LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7.
-+The default is AUTH.
-+.It Cm TCPKeepAlive
-+Specifies whether the system should send TCP keepalive messages to the
-+other side.
-+If they are sent, death of the connection or crash of one
-+of the machines will be properly noticed.
-+However, this means that
-+connections will die if the route is down temporarily, and some people
-+find it annoying.
-+On the other hand, if TCP keepalives are not sent,
-+sessions may hang indefinitely on the server, leaving
-+.Dq ghost
-+users and consuming server resources.
-+.Pp
-+The default is
-+.Dq yes
-+(to send TCP keepalive messages), and the server will notice
-+if the network goes down or the client host crashes.
-+This avoids infinitely hanging sessions.
-+.Pp
-+To disable TCP keepalive messages, the value should be set to
-+.Dq no .
-+.It Cm TrustedUserCAKeys
-+Specifies a file containing public keys of certificate authorities that are
-+trusted to sign user certificates for authentication, or
-+.Dq none
-+to not use one.
-+Keys are listed one per line; empty lines and comments starting with
-+.Ql #
-+are allowed.
-+If a certificate is presented for authentication and has its signing CA key
-+listed in this file, then it may be used for authentication for any user
-+listed in the certificate's principals list.
-+Note that certificates that lack a list of principals will not be permitted
-+for authentication using
-+.Cm TrustedUserCAKeys .
-+For more details on certificates, see the CERTIFICATES section in
-+.Xr ssh-keygen 1 .
-+.It Cm UseDNS
-+Specifies whether
-+.Xr sshd 1M
-+should look up the remote host name, and to check that
-+the resolved host name for the remote IP address maps back to the
-+very same IP address.
-+.Pp
-+If this option is set to
-+.Dq no
-+(the default) then only addresses and not host names may be used in
-+.Pa ~/.ssh/known_hosts
-+.Cm from
-+and
-+.Nm
-+.Cm Match
-+.Cm Host
-+directives.
-+.It Cm UseLogin
-+Specifies whether
-+.Xr login 1
-+is used for interactive login sessions.
-+The default is
-+.Dq no .
-+Note that
-+.Xr login 1
-+is never used for remote command execution.
-+Note also, that if this is enabled,
-+.Cm X11Forwarding
-+will be disabled because
-+.Xr login 1
-+does not know how to handle
-+.Xr xauth 1
-+cookies.
-+If
-+.Cm UsePrivilegeSeparation
-+is specified, it will be disabled after authentication.
-+.It Cm UsePAM
-+Enables the Pluggable Authentication Module interface.
-+If set to
-+.Dq yes
-+this will enable PAM authentication using
-+.Cm ChallengeResponseAuthentication
-+and
-+.Cm PasswordAuthentication
-+in addition to PAM account and session module processing for all
-+authentication types.
-+.Pp
-+Because PAM challenge-response authentication usually serves an equivalent
-+role to password authentication, you should disable either
-+.Cm PasswordAuthentication
-+or
-+.Cm ChallengeResponseAuthentication.
-+.Pp
-+If
-+.Cm UsePAM
-+is enabled, you will not be able to run
-+.Xr sshd 1M
-+as a non-root user.
-+The default is
-+.Dq no .
-+.It Cm UsePrivilegeSeparation
-+Specifies whether
-+.Xr sshd 1M
-+separates privileges by creating an unprivileged child process
-+to deal with incoming network traffic.
-+After successful authentication, another process will be created that has
-+the privilege of the authenticated user.
-+The goal of privilege separation is to prevent privilege
-+escalation by containing any corruption within the unprivileged processes.
-+The default is
-+.Dq yes .
-+If
-+.Cm UsePrivilegeSeparation
-+is set to
-+.Dq sandbox
-+then the pre-authentication unprivileged process is subject to additional
-+restrictions.
-+.It Cm VersionAddendum
-+Optionally specifies additional text to append to the SSH protocol banner
-+sent by the server upon connection.
-+The default is
-+.Dq none .
-+.It Cm X11DisplayOffset
-+Specifies the first display number available for
-+.Xr sshd 1M Ns 's
-+X11 forwarding.
-+This prevents sshd from interfering with real X11 servers.
-+The default is 10.
-+.It Cm X11Forwarding
-+Specifies whether X11 forwarding is permitted.
-+The argument must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is
-+.Dq no .
-+.Pp
-+When X11 forwarding is enabled, there may be additional exposure to
-+the server and to client displays if the
-+.Xr sshd 1M
-+proxy display is configured to listen on the wildcard address (see
-+.Cm X11UseLocalhost
-+below), though this is not the default.
-+Additionally, the authentication spoofing and authentication data
-+verification and substitution occur on the client side.
-+The security risk of using X11 forwarding is that the client's X11
-+display server may be exposed to attack when the SSH client requests
-+forwarding (see the warnings for
-+.Cm ForwardX11
-+in
-+.Xr ssh_config 4 ) .
-+A system administrator may have a stance in which they want to
-+protect clients that may expose themselves to attack by unwittingly
-+requesting X11 forwarding, which can warrant a
-+.Dq no
-+setting.
-+.Pp
-+Note that disabling X11 forwarding does not prevent users from
-+forwarding X11 traffic, as users can always install their own forwarders.
-+X11 forwarding is automatically disabled if
-+.Cm UseLogin
-+is enabled.
-+.It Cm X11UseLocalhost
-+Specifies whether
-+.Xr sshd 1M
-+should bind the X11 forwarding server to the loopback address or to
-+the wildcard address.
-+By default,
-+sshd binds the forwarding server to the loopback address and sets the
-+hostname part of the
-+.Ev DISPLAY
-+environment variable to
-+.Dq localhost .
-+This prevents remote hosts from connecting to the proxy display.
-+However, some older X11 clients may not function with this
-+configuration.
-+.Cm X11UseLocalhost
-+may be set to
-+.Dq no
-+to specify that the forwarding server should be bound to the wildcard
-+address.
-+The argument must be
-+.Dq yes
-+or
-+.Dq no .
-+The default is
-+.Dq yes .
-+.It Cm XAuthLocation
-+Specifies the full pathname of the
-+.Xr xauth 1
-+program, or
-+.Dq none
-+to not use one.
-+The default is
-+.Pa /usr/X11R6/bin/xauth .
-+.El
-+.Sh TIME FORMATS
-+.Xr sshd 1M
-+command-line arguments and configuration file options that specify time
-+may be expressed using a sequence of the form:
-+.Sm off
-+.Ar time Op Ar qualifier ,
-+.Sm on
-+where
-+.Ar time
-+is a positive integer value and
-+.Ar qualifier
-+is one of the following:
-+.Pp
-+.Bl -tag -width Ds -compact -offset indent
-+.It Aq Cm none
-+seconds
-+.It Cm s | Cm S
-+seconds
-+.It Cm m | Cm M
-+minutes
-+.It Cm h | Cm H
-+hours
-+.It Cm d | Cm D
-+days
-+.It Cm w | Cm W
-+weeks
-+.El
-+.Pp
-+Each member of the sequence is added together to calculate
-+the total time value.
-+.Pp
-+Time format examples:
-+.Pp
-+.Bl -tag -width Ds -compact -offset indent
-+.It 600
-+600 seconds (10 minutes)
-+.It 10m
-+10 minutes
-+.It 1h30m
-+1 hour 30 minutes (90 minutes)
-+.El
-+.Sh FILES
-+.Bl -tag -width Ds
-+.It Pa /etc/ssh/sshd_config
-+Contains configuration data for
-+.Xr sshd 1M .
-+This file should be writable by root only, but it is recommended
-+(though not necessary) that it be world-readable.
-+.El
-+.Sh SEE ALSO
-+.Xr sshd 1M ,
-+.Xr pam_unix_session 5
-+.Sh AUTHORS
-+OpenSSH is a derivative of the original and free
-+ssh 1.2.12 release by Tatu Ylonen.
-+Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
-+Theo de Raadt and Dug Song
-+removed many bugs, re-added newer features and
-+created OpenSSH.
-+Markus Friedl contributed the support for SSH
-+protocol versions 1.5 and 2.0.
-+Niels Provos and Markus Friedl contributed support
-+for privilege separation.
-diff --git a/sshd_config.5 b/sshd_config.5
-deleted file mode 100644
-index 476f71c..0000000
---- a/sshd_config.5
-+++ /dev/null
-@@ -1,1736 +0,0 @@
--.\"
--.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
--.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
--.\"                    All rights reserved
--.\"
--.\" As far as I am concerned, the code I have written for this software
--.\" can be used freely for any purpose.  Any derived versions of this
--.\" software must be clearly marked as such, and if the derived work is
--.\" incompatible with the protocol description in the RFC file, it must be
--.\" called by a name other than "ssh" or "Secure Shell".
--.\"
--.\" Copyright (c) 1999,2000 Markus Friedl.  All rights reserved.
--.\" Copyright (c) 1999 Aaron Campbell.  All rights reserved.
--.\" Copyright (c) 1999 Theo de Raadt.  All rights reserved.
--.\"
--.\" Redistribution and use in source and binary forms, with or without
--.\" modification, are permitted provided that the following conditions
--.\" are met:
--.\" 1. Redistributions of source code must retain the above copyright
--.\"    notice, this list of conditions and the following disclaimer.
--.\" 2. Redistributions in binary form must reproduce the above copyright
--.\"    notice, this list of conditions and the following disclaimer in the
--.\"    documentation and/or other materials provided with the distribution.
--.\"
--.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
--.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
--.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
--.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
--.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
--.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
--.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
--.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
--.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
--.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--.\"
--.\" $OpenBSD: sshd_config.5,v 1.211 2015/08/14 15:32:41 jmc Exp $
--.Dd $Mdocdate: August 14 2015 $
--.Dt SSHD_CONFIG 5
--.Os
--.Sh NAME
--.Nm sshd_config
--.Nd OpenSSH SSH daemon configuration file
--.Sh SYNOPSIS
--.Nm /etc/ssh/sshd_config
--.Sh DESCRIPTION
--.Xr sshd 8
--reads configuration data from
--.Pa /etc/ssh/sshd_config
--(or the file specified with
--.Fl f
--on the command line).
--The file contains keyword-argument pairs, one per line.
--Lines starting with
--.Ql #
--and empty lines are interpreted as comments.
--Arguments may optionally be enclosed in double quotes
--.Pq \&"
--in order to represent arguments containing spaces.
--.Pp
--The possible
--keywords and their meanings are as follows (note that
--keywords are case-insensitive and arguments are case-sensitive):
--.Bl -tag -width Ds
--.It Cm AcceptEnv
--Specifies what environment variables sent by the client will be copied into
--the session's
--.Xr environ 7 .
--See
--.Cm SendEnv
--in
--.Xr ssh_config 5
--for how to configure the client.
--Note that environment passing is only supported for protocol 2, and
--that the
--.Ev TERM
--environment variable is always sent whenever the client
--requests a pseudo-terminal as it is required by the protocol.
--Variables are specified by name, which may contain the wildcard characters
--.Ql *
--and
--.Ql \&? .
--Multiple environment variables may be separated by whitespace or spread
--across multiple
--.Cm AcceptEnv
--directives.
--Be warned that some environment variables could be used to bypass restricted
--user environments.
--For this reason, care should be taken in the use of this directive.
--The default is not to accept any environment variables.
--.It Cm AddressFamily
--Specifies which address family should be used by
--.Xr sshd 8 .
--Valid arguments are
--.Dq any ,
--.Dq inet
--(use IPv4 only), or
--.Dq inet6
--(use IPv6 only).
--The default is
--.Dq any .
--.It Cm AllowAgentForwarding
--Specifies whether
--.Xr ssh-agent 1
--forwarding is permitted.
--The default is
--.Dq yes .
--Note that disabling agent forwarding does not improve security
--unless users are also denied shell access, as they can always install
--their own forwarders.
--.It Cm AllowGroups
--This keyword can be followed by a list of group name patterns, separated
--by spaces.
--If specified, login is allowed only for users whose primary
--group or supplementary group list matches one of the patterns.
--Only group names are valid; a numerical group ID is not recognized.
--By default, login is allowed for all groups.
--The allow/deny directives are processed in the following order:
--.Cm DenyUsers ,
--.Cm AllowUsers ,
--.Cm DenyGroups ,
--and finally
--.Cm AllowGroups .
--.Pp
--See PATTERNS in
--.Xr ssh_config 5
--for more information on patterns.
--.It Cm AllowTcpForwarding
--Specifies whether TCP forwarding is permitted.
--The available options are
--.Dq yes
--or
--.Dq all
--to allow TCP forwarding,
--.Dq no
--to prevent all TCP forwarding,
--.Dq local
--to allow local (from the perspective of
--.Xr ssh 1 )
--forwarding only or
--.Dq remote
--to allow remote forwarding only.
--The default is
--.Dq yes .
--Note that disabling TCP forwarding does not improve security unless
--users are also denied shell access, as they can always install their
--own forwarders.
--.It Cm AllowStreamLocalForwarding
--Specifies whether StreamLocal (Unix-domain socket) forwarding is permitted.
--The available options are
--.Dq yes
--or
--.Dq all
--to allow StreamLocal forwarding,
--.Dq no
--to prevent all StreamLocal forwarding,
--.Dq local
--to allow local (from the perspective of
--.Xr ssh 1 )
--forwarding only or
--.Dq remote
--to allow remote forwarding only.
--The default is
--.Dq yes .
--Note that disabling StreamLocal forwarding does not improve security unless
--users are also denied shell access, as they can always install their
--own forwarders.
--.It Cm AllowUsers
--This keyword can be followed by a list of user name patterns, separated
--by spaces.
--If specified, login is allowed only for user names that
--match one of the patterns.
--Only user names are valid; a numerical user ID is not recognized.
--By default, login is allowed for all users.
--If the pattern takes the form USER@HOST then USER and HOST
--are separately checked, restricting logins to particular
--users from particular hosts.
--The allow/deny directives are processed in the following order:
--.Cm DenyUsers ,
--.Cm AllowUsers ,
--.Cm DenyGroups ,
--and finally
--.Cm AllowGroups .
--.Pp
--See PATTERNS in
--.Xr ssh_config 5
--for more information on patterns.
--.It Cm AuthenticationMethods
--Specifies the authentication methods that must be successfully completed
--for a user to be granted access.
--This option must be followed by one or more comma-separated lists of
--authentication method names.
--Successful authentication requires completion of every method in at least
--one of these lists.
--.Pp
--For example, an argument of
--.Dq publickey,password publickey,keyboard-interactive
--would require the user to complete public key authentication, followed by
--either password or keyboard interactive authentication.
--Only methods that are next in one or more lists are offered at each stage,
--so for this example, it would not be possible to attempt password or
--keyboard-interactive authentication before public key.
--.Pp
--For keyboard interactive authentication it is also possible to
--restrict authentication to a specific device by appending a
--colon followed by the device identifier
--.Dq bsdauth ,
--.Dq pam ,
--or
--.Dq skey ,
--depending on the server configuration.
--For example,
--.Dq keyboard-interactive:bsdauth
--would restrict keyboard interactive authentication to the
--.Dq bsdauth
--device.
--.Pp
--If the
--.Dq publickey
--method is listed more than once,
--.Xr sshd 8
--verifies that keys that have been used successfully are not reused for
--subsequent authentications.
--For example, an
--.Cm AuthenticationMethods
--of
--.Dq publickey,publickey
--will require successful authentication using two different public keys.
--.Pp
--This option is only available for SSH protocol 2 and will yield a fatal
--error if enabled if protocol 1 is also enabled.
--Note that each authentication method listed should also be explicitly enabled
--in the configuration.
--The default is not to require multiple authentication; successful completion
--of a single authentication method is sufficient.
--.It Cm AuthorizedKeysCommand
--Specifies a program to be used to look up the user's public keys.
--The program must be owned by root, not writable by group or others and
--specified by an absolute path.
--.Pp
--Arguments to
--.Cm AuthorizedKeysCommand
--may be provided using the following tokens, which will be expanded
--at runtime: %% is replaced by a literal '%', %u is replaced by the
--username being authenticated, %h is replaced by the home directory
--of the user being authenticated, %t is replaced with the key type
--offered for authentication, %f is replaced with the fingerprint of
--the key, and %k is replaced with the key being offered for authentication.
--If no arguments are specified then the username of the target user
--will be supplied.
--.Pp
--The program should produce on standard output zero or
--more lines of authorized_keys output (see AUTHORIZED_KEYS in
--.Xr sshd 8 ) .
--If a key supplied by AuthorizedKeysCommand does not successfully authenticate
--and authorize the user then public key authentication continues using the usual
--.Cm AuthorizedKeysFile
--files.
--By default, no AuthorizedKeysCommand is run.
--.It Cm AuthorizedKeysCommandUser
--Specifies the user under whose account the AuthorizedKeysCommand is run.
--It is recommended to use a dedicated user that has no other role on the host
--than running authorized keys commands.
--If
--.Cm AuthorizedKeysCommand
--is specified but
--.Cm AuthorizedKeysCommandUser
--is not, then
--.Xr sshd 8
--will refuse to start.
--.It Cm AuthorizedKeysFile
--Specifies the file that contains the public keys that can be used
--for user authentication.
--The format is described in the
--AUTHORIZED_KEYS FILE FORMAT
--section of
--.Xr sshd 8 .
--.Cm AuthorizedKeysFile
--may contain tokens of the form %T which are substituted during connection
--setup.
--The following tokens are defined: %% is replaced by a literal '%',
--%h is replaced by the home directory of the user being authenticated, and
--%u is replaced by the username of that user.
--After expansion,
--.Cm AuthorizedKeysFile
--is taken to be an absolute path or one relative to the user's home
--directory.
--Multiple files may be listed, separated by whitespace.
--The default is
--.Dq .ssh/authorized_keys .ssh/authorized_keys2 .
--.It Cm AuthorizedPrincipalsCommand
--Specifies a program to be used to generate the list of allowed
--certificate principals as per
--.Cm AuthorizedPrincipalsFile .
--The program must be owned by root, not writable by group or others and
--specified by an absolute path.
--.Pp
--Arguments to
--.Cm AuthorizedPrincipalsCommand
--may be provided using the following tokens, which will be expanded
--at runtime: %% is replaced by a literal '%', %u is replaced by the
--username being authenticated and %h is replaced by the home directory
--of the user being authenticated.
--.Pp
--The program should produce on standard output zero or
--more lines of
--.Cm AuthorizedPrincipalsFile
--output.
--If either
--.Cm AuthorizedPrincipalsCommand
--or
--.Cm AuthorizedPrincipalsFile
--is specified, then certificates offered by the client for authentication
--must contain a principal that is listed.
--By default, no AuthorizedPrincipalsCommand is run.
--.It Cm AuthorizedPrincipalsCommandUser
--Specifies the user under whose account the AuthorizedPrincipalsCommand is run.
--It is recommended to use a dedicated user that has no other role on the host
--than running authorized principals commands.
--If
--.Cm AuthorizedPrincipalsCommand
--is specified but
--.Cm AuthorizedPrincipalsCommandUser
--is not, then
--.Xr sshd 8
--will refuse to start.
--.It Cm AuthorizedPrincipalsFile
--Specifies a file that lists principal names that are accepted for
--certificate authentication.
--When using certificates signed by a key listed in
--.Cm TrustedUserCAKeys ,
--this file lists names, one of which must appear in the certificate for it
--to be accepted for authentication.
--Names are listed one per line preceded by key options (as described
--in AUTHORIZED_KEYS FILE FORMAT in
--.Xr sshd 8 ) .
--Empty lines and comments starting with
--.Ql #
--are ignored.
--.Pp
--.Cm AuthorizedPrincipalsFile
--may contain tokens of the form %T which are substituted during connection
--setup.
--The following tokens are defined: %% is replaced by a literal '%',
--%h is replaced by the home directory of the user being authenticated, and
--%u is replaced by the username of that user.
--After expansion,
--.Cm AuthorizedPrincipalsFile
--is taken to be an absolute path or one relative to the user's home
--directory.
--.Pp
--The default is
--.Dq none ,
--i.e. not to use a principals file \(en in this case, the username
--of the user must appear in a certificate's principals list for it to be
--accepted.
--Note that
--.Cm AuthorizedPrincipalsFile
--is only used when authentication proceeds using a CA listed in
--.Cm TrustedUserCAKeys
--and is not consulted for certification authorities trusted via
--.Pa ~/.ssh/authorized_keys ,
--though the
--.Cm principals=
--key option offers a similar facility (see
--.Xr sshd 8
--for details).
--.It Cm Banner
--The contents of the specified file are sent to the remote user before
--authentication is allowed.
--If the argument is
--.Dq none
--then no banner is displayed.
--This option is only available for protocol version 2.
--By default, no banner is displayed.
--.It Cm ChallengeResponseAuthentication
--Specifies whether challenge-response authentication is allowed (e.g. via
--PAM or through authentication styles supported in
--.Xr login.conf 5 )
--The default is
--.Dq yes .
--.It Cm ChrootDirectory
--Specifies the pathname of a directory to
--.Xr chroot 2
--to after authentication.
--At session startup
--.Xr sshd 8
--checks that all components of the pathname are root-owned directories
--which are not writable by any other user or group.
--After the chroot,
--.Xr sshd 8
--changes the working directory to the user's home directory.
--.Pp
--The pathname may contain the following tokens that are expanded at runtime once
--the connecting user has been authenticated: %% is replaced by a literal '%',
--%h is replaced by the home directory of the user being authenticated, and
--%u is replaced by the username of that user.
--.Pp
--The
--.Cm ChrootDirectory
--must contain the necessary files and directories to support the
--user's session.
--For an interactive session this requires at least a shell, typically
--.Xr sh 1 ,
--and basic
--.Pa /dev
--nodes such as
--.Xr null 4 ,
--.Xr zero 4 ,
--.Xr stdin 4 ,
--.Xr stdout 4 ,
--.Xr stderr 4 ,
--and
--.Xr tty 4
--devices.
--For file transfer sessions using
--.Dq sftp ,
--no additional configuration of the environment is necessary if the
--in-process sftp server is used,
--though sessions which use logging may require
--.Pa /dev/log
--inside the chroot directory on some operating systems (see
--.Xr sftp-server 8
--for details).
--.Pp
--For safety, it is very important that the directory hierarchy be
--prevented from modification by other processes on the system (especially
--those outside the jail).
--Misconfiguration can lead to unsafe environments which
--.Xr sshd 8
--cannot detect.
--.Pp
--The default is not to
--.Xr chroot 2 .
--.It Cm Ciphers
--Specifies the ciphers allowed for protocol version 2.
--Multiple ciphers must be comma-separated.
--If the specified value begins with a
--.Sq +
--character, then the specified ciphers will be appended to the default set
--instead of replacing them.
--.Pp
--The supported ciphers are:
--.Pp
--.Bl -item -compact -offset indent
--.It
--3des-cbc
--.It
--aes128-cbc
--.It
--aes192-cbc
--.It
--aes256-cbc
--.It
--aes128-ctr
--.It
--aes192-ctr
--.It
--aes256-ctr
--.It
--aes128-gcm@openssh.com
--.It
--aes256-gcm@openssh.com
--.It
--arcfour
--.It
--arcfour128
--.It
--arcfour256
--.It
--blowfish-cbc
--.It
--cast128-cbc
--.It
--chacha20-poly1305@openssh.com
--.El
--.Pp
--The default is:
--.Bd -literal -offset indent
--chacha20-poly1305@openssh.com,
--aes128-ctr,aes192-ctr,aes256-ctr,
--aes128-gcm@openssh.com,aes256-gcm@openssh.com
--.Ed
--.Pp
--The list of available ciphers may also be obtained using the
--.Fl Q
--option of
--.Xr ssh 1
--with an argument of
--.Dq cipher .
--.It Cm ClientAliveCountMax
--Sets the number of client alive messages (see below) which may be
--sent without
--.Xr sshd 8
--receiving any messages back from the client.
--If this threshold is reached while client alive messages are being sent,
--sshd will disconnect the client, terminating the session.
--It is important to note that the use of client alive messages is very
--different from
--.Cm TCPKeepAlive
--(below).
--The client alive messages are sent through the encrypted channel
--and therefore will not be spoofable.
--The TCP keepalive option enabled by
--.Cm TCPKeepAlive
--is spoofable.
--The client alive mechanism is valuable when the client or
--server depend on knowing when a connection has become inactive.
--.Pp
--The default value is 3.
--If
--.Cm ClientAliveInterval
--(see below) is set to 15, and
--.Cm ClientAliveCountMax
--is left at the default, unresponsive SSH clients
--will be disconnected after approximately 45 seconds.
--This option applies to protocol version 2 only.
--.It Cm ClientAliveInterval
--Sets a timeout interval in seconds after which if no data has been received
--from the client,
--.Xr sshd 8
--will send a message through the encrypted
--channel to request a response from the client.
--The default
--is 0, indicating that these messages will not be sent to the client.
--This option applies to protocol version 2 only.
--.It Cm Compression
--Specifies whether compression is allowed, or delayed until
--the user has authenticated successfully.
--The argument must be
--.Dq yes ,
--.Dq delayed ,
--or
--.Dq no .
--The default is
--.Dq delayed .
--.It Cm DenyGroups
--This keyword can be followed by a list of group name patterns, separated
--by spaces.
--Login is disallowed for users whose primary group or supplementary
--group list matches one of the patterns.
--Only group names are valid; a numerical group ID is not recognized.
--By default, login is allowed for all groups.
--The allow/deny directives are processed in the following order:
--.Cm DenyUsers ,
--.Cm AllowUsers ,
--.Cm DenyGroups ,
--and finally
--.Cm AllowGroups .
--.Pp
--See PATTERNS in
--.Xr ssh_config 5
--for more information on patterns.
--.It Cm DenyUsers
--This keyword can be followed by a list of user name patterns, separated
--by spaces.
--Login is disallowed for user names that match one of the patterns.
--Only user names are valid; a numerical user ID is not recognized.
--By default, login is allowed for all users.
--If the pattern takes the form USER@HOST then USER and HOST
--are separately checked, restricting logins to particular
--users from particular hosts.
--The allow/deny directives are processed in the following order:
--.Cm DenyUsers ,
--.Cm AllowUsers ,
--.Cm DenyGroups ,
--and finally
--.Cm AllowGroups .
--.Pp
--See PATTERNS in
--.Xr ssh_config 5
--for more information on patterns.
--.It Cm FingerprintHash
--Specifies the hash algorithm used when logging key fingerprints.
--Valid options are:
--.Dq md5
--and
--.Dq sha256 .
--The default is
--.Dq sha256 .
--.It Cm ForceCommand
--Forces the execution of the command specified by
--.Cm ForceCommand ,
--ignoring any command supplied by the client and
--.Pa ~/.ssh/rc
--if present.
--The command is invoked by using the user's login shell with the -c option.
--This applies to shell, command, or subsystem execution.
--It is most useful inside a
--.Cm Match
--block.
--The command originally supplied by the client is available in the
--.Ev SSH_ORIGINAL_COMMAND
--environment variable.
--Specifying a command of
--.Dq internal-sftp
--will force the use of an in-process sftp server that requires no support
--files when used with
--.Cm ChrootDirectory .
--.It Cm GatewayPorts
--Specifies whether remote hosts are allowed to connect to ports
--forwarded for the client.
--By default,
--.Xr sshd 8
--binds remote port forwardings to the loopback address.
--This prevents other remote hosts from connecting to forwarded ports.
--.Cm GatewayPorts
--can be used to specify that sshd
--should allow remote port forwardings to bind to non-loopback addresses, thus
--allowing other hosts to connect.
--The argument may be
--.Dq no
--to force remote port forwardings to be available to the local host only,
--.Dq yes
--to force remote port forwardings to bind to the wildcard address, or
--.Dq clientspecified
--to allow the client to select the address to which the forwarding is bound.
--The default is
--.Dq no .
--.It Cm GSSAPIAuthentication
--Specifies whether user authentication based on GSSAPI is allowed.
--The default is
--.Dq no .
--Note that this option applies to protocol version 2 only.
--.It Cm GSSAPICleanupCredentials
--Specifies whether to automatically destroy the user's credentials cache
--on logout.
--The default is
--.Dq yes .
--Note that this option applies to protocol version 2 only.
--.It Cm GSSAPIStrictAcceptorCheck
--Determines whether to be strict about the identity of the GSSAPI acceptor
--a client authenticates against.
--If set to
--.Dq yes
--then the client must authenticate against the
--.Pa host
--service on the current hostname.
--If set to
--.Dq no
--then the client may authenticate against any service key stored in the
--machine's default store.
--This facility is provided to assist with operation on multi homed machines.
--The default is
--.Dq yes .
--.It Cm HostbasedAcceptedKeyTypes
--Specifies the key types that will be accepted for hostbased authentication
--as a comma-separated pattern list.
--Alternately if the specified value begins with a
--.Sq +
--character, then the specified key types will be appended to the default set
--instead of replacing them.
--The default for this option is:
--.Bd -literal -offset 3n
--ecdsa-sha2-nistp256-cert-v01@openssh.com,
--ecdsa-sha2-nistp384-cert-v01@openssh.com,
--ecdsa-sha2-nistp521-cert-v01@openssh.com,
--ssh-ed25519-cert-v01@openssh.com,
--ssh-rsa-cert-v01@openssh.com,
--ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
--ssh-ed25519,ssh-rsa
--.Ed
--.Pp
--The
--.Fl Q
--option of
--.Xr ssh 1
--may be used to list supported key types.
--.It Cm HostbasedAuthentication
--Specifies whether rhosts or /etc/hosts.equiv authentication together
--with successful public key client host authentication is allowed
--(host-based authentication).
--This option is similar to
--.Cm RhostsRSAAuthentication
--and applies to protocol version 2 only.
--The default is
--.Dq no .
--.It Cm HostbasedUsesNameFromPacketOnly
--Specifies whether or not the server will attempt to perform a reverse
--name lookup when matching the name in the
--.Pa ~/.shosts ,
--.Pa ~/.rhosts ,
--and
--.Pa /etc/hosts.equiv
--files during
--.Cm HostbasedAuthentication .
--A setting of
--.Dq yes
--means that
--.Xr sshd 8
--uses the name supplied by the client rather than
--attempting to resolve the name from the TCP connection itself.
--The default is
--.Dq no .
--.It Cm HostCertificate
--Specifies a file containing a public host certificate.
--The certificate's public key must match a private host key already specified
--by
--.Cm HostKey .
--The default behaviour of
--.Xr sshd 8
--is not to load any certificates.
--.It Cm HostKey
--Specifies a file containing a private host key
--used by SSH.
--The default is
--.Pa /etc/ssh/ssh_host_key
--for protocol version 1, and
--.Pa /etc/ssh/ssh_host_dsa_key ,
--.Pa /etc/ssh/ssh_host_ecdsa_key ,
--.Pa /etc/ssh/ssh_host_ed25519_key
--and
--.Pa /etc/ssh/ssh_host_rsa_key
--for protocol version 2.
--.Pp
--Note that
--.Xr sshd 8
--will refuse to use a file if it is group/world-accessible
--and that the
--.Cm HostKeyAlgorithms
--option restricts which of the keys are actually used by
--.Xr sshd 8 .
--.Pp
--It is possible to have multiple host key files.
--.Dq rsa1
--keys are used for version 1 and
--.Dq dsa ,
--.Dq ecdsa ,
--.Dq ed25519
--or
--.Dq rsa
--are used for version 2 of the SSH protocol.
--It is also possible to specify public host key files instead.
--In this case operations on the private key will be delegated
--to an
--.Xr ssh-agent 1 .
--.It Cm HostKeyAgent
--Identifies the UNIX-domain socket used to communicate
--with an agent that has access to the private host keys.
--If
--.Dq SSH_AUTH_SOCK
--is specified, the location of the socket will be read from the
--.Ev SSH_AUTH_SOCK
--environment variable.
--.It Cm HostKeyAlgorithms
--Specifies the protocol version 2 host key algorithms
--that the server offers.
--The default for this option is:
--.Bd -literal -offset 3n
--ecdsa-sha2-nistp256-cert-v01@openssh.com,
--ecdsa-sha2-nistp384-cert-v01@openssh.com,
--ecdsa-sha2-nistp521-cert-v01@openssh.com,
--ssh-ed25519-cert-v01@openssh.com,
--ssh-rsa-cert-v01@openssh.com,
--ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
--ssh-ed25519,ssh-rsa
--.Ed
--.Pp
--The list of available key types may also be obtained using the
--.Fl Q
--option of
--.Xr ssh 1
--with an argument of
--.Dq key .
--.It Cm IgnoreRhosts
--Specifies that
--.Pa .rhosts
--and
--.Pa .shosts
--files will not be used in
--.Cm RhostsRSAAuthentication
--or
--.Cm HostbasedAuthentication .
--.Pp
--.Pa /etc/hosts.equiv
--and
--.Pa /etc/shosts.equiv
--are still used.
--The default is
--.Dq yes .
--.It Cm IgnoreUserKnownHosts
--Specifies whether
--.Xr sshd 8
--should ignore the user's
--.Pa ~/.ssh/known_hosts
--during
--.Cm RhostsRSAAuthentication
--or
--.Cm HostbasedAuthentication .
--The default is
--.Dq no .
--.It Cm IPQoS
--Specifies the IPv4 type-of-service or DSCP class for the connection.
--Accepted values are
--.Dq af11 ,
--.Dq af12 ,
--.Dq af13 ,
--.Dq af21 ,
--.Dq af22 ,
--.Dq af23 ,
--.Dq af31 ,
--.Dq af32 ,
--.Dq af33 ,
--.Dq af41 ,
--.Dq af42 ,
--.Dq af43 ,
--.Dq cs0 ,
--.Dq cs1 ,
--.Dq cs2 ,
--.Dq cs3 ,
--.Dq cs4 ,
--.Dq cs5 ,
--.Dq cs6 ,
--.Dq cs7 ,
--.Dq ef ,
--.Dq lowdelay ,
--.Dq throughput ,
--.Dq reliability ,
--or a numeric value.
--This option may take one or two arguments, separated by whitespace.
--If one argument is specified, it is used as the packet class unconditionally.
--If two values are specified, the first is automatically selected for
--interactive sessions and the second for non-interactive sessions.
--The default is
--.Dq lowdelay
--for interactive sessions and
--.Dq throughput
--for non-interactive sessions.
--.It Cm KbdInteractiveAuthentication
--Specifies whether to allow keyboard-interactive authentication.
--The argument to this keyword must be
--.Dq yes
--or
--.Dq no .
--The default is to use whatever value
--.Cm ChallengeResponseAuthentication
--is set to
--(by default
--.Dq yes ) .
--.It Cm KerberosAuthentication
--Specifies whether the password provided by the user for
--.Cm PasswordAuthentication
--will be validated through the Kerberos KDC.
--To use this option, the server needs a
--Kerberos servtab which allows the verification of the KDC's identity.
--The default is
--.Dq no .
--.It Cm KerberosGetAFSToken
--If AFS is active and the user has a Kerberos 5 TGT, attempt to acquire
--an AFS token before accessing the user's home directory.
--The default is
--.Dq no .
--.It Cm KerberosOrLocalPasswd
--If password authentication through Kerberos fails then
--the password will be validated via any additional local mechanism
--such as
--.Pa /etc/passwd .
--The default is
--.Dq yes .
--.It Cm KerberosTicketCleanup
--Specifies whether to automatically destroy the user's ticket cache
--file on logout.
--The default is
--.Dq yes .
--.It Cm KexAlgorithms
--Specifies the available KEX (Key Exchange) algorithms.
--Multiple algorithms must be comma-separated.
--Alternately if the specified value begins with a
--.Sq +
--character, then the specified methods will be appended to the default set
--instead of replacing them.
--The supported algorithms are:
--.Pp
--.Bl -item -compact -offset indent
--.It
--curve25519-sha256@libssh.org
--.It
--diffie-hellman-group1-sha1
--.It
--diffie-hellman-group14-sha1
--.It
--diffie-hellman-group-exchange-sha1
--.It
--diffie-hellman-group-exchange-sha256
--.It
--ecdh-sha2-nistp256
--.It
--ecdh-sha2-nistp384
--.It
--ecdh-sha2-nistp521
--.El
--.Pp
--The default is:
--.Bd -literal -offset indent
--curve25519-sha256@libssh.org,
--ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,
--diffie-hellman-group-exchange-sha256,
--diffie-hellman-group14-sha1
--.Ed
--.Pp
--The list of available key exchange algorithms may also be obtained using the
--.Fl Q
--option of
--.Xr ssh 1
--with an argument of
--.Dq kex .
--.It Cm KeyRegenerationInterval
--In protocol version 1, the ephemeral server key is automatically regenerated
--after this many seconds (if it has been used).
--The purpose of regeneration is to prevent
--decrypting captured sessions by later breaking into the machine and
--stealing the keys.
--The key is never stored anywhere.
--If the value is 0, the key is never regenerated.
--The default is 3600 (seconds).
--.It Cm ListenAddress
--Specifies the local addresses
--.Xr sshd 8
--should listen on.
--The following forms may be used:
--.Pp
--.Bl -item -offset indent -compact
--.It
--.Cm ListenAddress
--.Sm off
--.Ar host | Ar IPv4_addr | Ar IPv6_addr
--.Sm on
--.It
--.Cm ListenAddress
--.Sm off
--.Ar host | Ar IPv4_addr : Ar port
--.Sm on
--.It
--.Cm ListenAddress
--.Sm off
--.Oo
--.Ar host | Ar IPv6_addr Oc : Ar port
--.Sm on
--.El
--.Pp
--If
--.Ar port
--is not specified,
--sshd will listen on the address and all
--.Cm Port
--options specified.
--The default is to listen on all local addresses.
--Multiple
--.Cm ListenAddress
--options are permitted.
--.It Cm LoginGraceTime
--The server disconnects after this time if the user has not
--successfully logged in.
--If the value is 0, there is no time limit.
--The default is 120 seconds.
--.It Cm LogLevel
--Gives the verbosity level that is used when logging messages from
--.Xr sshd 8 .
--The possible values are:
--QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3.
--The default is INFO.
--DEBUG and DEBUG1 are equivalent.
--DEBUG2 and DEBUG3 each specify higher levels of debugging output.
--Logging with a DEBUG level violates the privacy of users and is not recommended.
--.It Cm MACs
--Specifies the available MAC (message authentication code) algorithms.
--The MAC algorithm is used in protocol version 2
--for data integrity protection.
--Multiple algorithms must be comma-separated.
--If the specified value begins with a
--.Sq +
--character, then the specified algorithms will be appended to the default set
--instead of replacing them.
--.Pp
--The algorithms that contain
--.Dq -etm
--calculate the MAC after encryption (encrypt-then-mac).
--These are considered safer and their use recommended.
--The supported MACs are:
--.Pp
--.Bl -item -compact -offset indent
--.It
--hmac-md5
--.It
--hmac-md5-96
--.It
--hmac-ripemd160
--.It
--hmac-sha1
--.It
--hmac-sha1-96
--.It
--hmac-sha2-256
--.It
--hmac-sha2-512
--.It
--umac-64@openssh.com
--.It
--umac-128@openssh.com
--.It
--hmac-md5-etm@openssh.com
--.It
--hmac-md5-96-etm@openssh.com
--.It
--hmac-ripemd160-etm@openssh.com
--.It
--hmac-sha1-etm@openssh.com
--.It
--hmac-sha1-96-etm@openssh.com
--.It
--hmac-sha2-256-etm@openssh.com
--.It
--hmac-sha2-512-etm@openssh.com
--.It
--umac-64-etm@openssh.com
--.It
--umac-128-etm@openssh.com
--.El
--.Pp
--The default is:
--.Bd -literal -offset indent
--umac-64-etm@openssh.com,umac-128-etm@openssh.com,
--hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,
--umac-64@openssh.com,umac-128@openssh.com,
--hmac-sha2-256,hmac-sha2-512
--.Ed
--.Pp
--The list of available MAC algorithms may also be obtained using the
--.Fl Q
--option of
--.Xr ssh 1
--with an argument of
--.Dq mac .
--.It Cm Match
--Introduces a conditional block.
--If all of the criteria on the
--.Cm Match
--line are satisfied, the keywords on the following lines override those
--set in the global section of the config file, until either another
--.Cm Match
--line or the end of the file.
--If a keyword appears in multiple
--.Cm Match
--blocks that are satisfied, only the first instance of the keyword is
--applied.
--.Pp
--The arguments to
--.Cm Match
--are one or more criteria-pattern pairs or the single token
--.Cm All
--which matches all criteria.
--The available criteria are
--.Cm User ,
--.Cm Group ,
--.Cm Host ,
--.Cm LocalAddress ,
--.Cm LocalPort ,
--and
--.Cm Address .
--The match patterns may consist of single entries or comma-separated
--lists and may use the wildcard and negation operators described in the
--PATTERNS section of
--.Xr ssh_config 5 .
--.Pp
--The patterns in an
--.Cm Address
--criteria may additionally contain addresses to match in CIDR
--address/masklen format, e.g.\&
--.Dq 192.0.2.0/24
--or
--.Dq 3ffe:ffff::/32 .
--Note that the mask length provided must be consistent with the address -
--it is an error to specify a mask length that is too long for the address
--or one with bits set in this host portion of the address.
--For example,
--.Dq 192.0.2.0/33
--and
--.Dq 192.0.2.0/8
--respectively.
--.Pp
--Only a subset of keywords may be used on the lines following a
--.Cm Match
--keyword.
--Available keywords are
--.Cm AcceptEnv ,
--.Cm AllowAgentForwarding ,
--.Cm AllowGroups ,
--.Cm AllowStreamLocalForwarding ,
--.Cm AllowTcpForwarding ,
--.Cm AllowUsers ,
--.Cm AuthenticationMethods ,
--.Cm AuthorizedKeysCommand ,
--.Cm AuthorizedKeysCommandUser ,
--.Cm AuthorizedKeysFile ,
--.Cm AuthorizedPrincipalsFile ,
--.Cm Banner ,
--.Cm ChrootDirectory ,
--.Cm DenyGroups ,
--.Cm DenyUsers ,
--.Cm ForceCommand ,
--.Cm GatewayPorts ,
--.Cm GSSAPIAuthentication ,
--.Cm HostbasedAcceptedKeyTypes ,
--.Cm HostbasedAuthentication ,
--.Cm HostbasedUsesNameFromPacketOnly ,
--.Cm IPQoS ,
--.Cm KbdInteractiveAuthentication ,
--.Cm KerberosAuthentication ,
--.Cm MaxAuthTries ,
--.Cm MaxSessions ,
--.Cm PasswordAuthentication ,
--.Cm PermitEmptyPasswords ,
--.Cm PermitOpen ,
--.Cm PermitRootLogin ,
--.Cm PermitTTY ,
--.Cm PermitTunnel ,
--.Cm PermitUserRC ,
--.Cm PubkeyAcceptedKeyTypes ,
--.Cm PubkeyAuthentication ,
--.Cm RekeyLimit ,
--.Cm RevokedKeys ,
--.Cm RhostsRSAAuthentication ,
--.Cm RSAAuthentication ,
--.Cm StreamLocalBindMask ,
--.Cm StreamLocalBindUnlink ,
--.Cm TrustedUserCAKeys ,
--.Cm X11DisplayOffset ,
--.Cm X11Forwarding
--and
--.Cm X11UseLocalHost .
--.It Cm MaxAuthTries
--Specifies the maximum number of authentication attempts permitted per
--connection.
--Once the number of failures reaches half this value,
--additional failures are logged.
--The default is 6.
--.It Cm MaxSessions
--Specifies the maximum number of open sessions permitted per network connection.
--The default is 10.
--.It Cm MaxStartups
--Specifies the maximum number of concurrent unauthenticated connections to the
--SSH daemon.
--Additional connections will be dropped until authentication succeeds or the
--.Cm LoginGraceTime
--expires for a connection.
--The default is 10:30:100.
--.Pp
--Alternatively, random early drop can be enabled by specifying
--the three colon separated values
--.Dq start:rate:full
--(e.g. "10:30:60").
--.Xr sshd 8
--will refuse connection attempts with a probability of
--.Dq rate/100
--(30%)
--if there are currently
--.Dq start
--(10)
--unauthenticated connections.
--The probability increases linearly and all connection attempts
--are refused if the number of unauthenticated connections reaches
--.Dq full
--(60).
--.It Cm PasswordAuthentication
--Specifies whether password authentication is allowed.
--The default is
--.Dq yes .
--.It Cm PermitEmptyPasswords
--When password authentication is allowed, it specifies whether the
--server allows login to accounts with empty password strings.
--The default is
--.Dq no .
--.It Cm PermitOpen
--Specifies the destinations to which TCP port forwarding is permitted.
--The forwarding specification must be one of the following forms:
--.Pp
--.Bl -item -offset indent -compact
--.It
--.Cm PermitOpen
--.Sm off
--.Ar host : port
--.Sm on
--.It
--.Cm PermitOpen
--.Sm off
--.Ar IPv4_addr : port
--.Sm on
--.It
--.Cm PermitOpen
--.Sm off
--.Ar \&[ IPv6_addr \&] : port
--.Sm on
--.El
--.Pp
--Multiple forwards may be specified by separating them with whitespace.
--An argument of
--.Dq any
--can be used to remove all restrictions and permit any forwarding requests.
--An argument of
--.Dq none
--can be used to prohibit all forwarding requests.
--By default all port forwarding requests are permitted.
--.It Cm PermitRootLogin
--Specifies whether root can log in using
--.Xr ssh 1 .
--The argument must be
--.Dq yes ,
--.Dq prohibit-password ,
--.Dq without-password ,
--.Dq forced-commands-only ,
--or
--.Dq no .
--The default is
--.Dq prohibit-password .
--.Pp
--If this option is set to
--.Dq prohibit-password
--or
--.Dq without-password ,
--password and keyboard-interactive authentication are disabled for root.
--.Pp
--If this option is set to
--.Dq forced-commands-only ,
--root login with public key authentication will be allowed,
--but only if the
--.Ar command
--option has been specified
--(which may be useful for taking remote backups even if root login is
--normally not allowed).
--All other authentication methods are disabled for root.
--.Pp
--If this option is set to
--.Dq no ,
--root is not allowed to log in.
--.It Cm PermitTunnel
--Specifies whether
--.Xr tun 4
--device forwarding is allowed.
--The argument must be
--.Dq yes ,
--.Dq point-to-point
--(layer 3),
--.Dq ethernet
--(layer 2), or
--.Dq no .
--Specifying
--.Dq yes
--permits both
--.Dq point-to-point
--and
--.Dq ethernet .
--The default is
--.Dq no .
--.Pp
--Independent of this setting, the permissions of the selected
--.Xr tun 4
--device must allow access to the user.
--.It Cm PermitTTY
--Specifies whether
--.Xr pty 4
--allocation is permitted.
--The default is
--.Dq yes .
--.It Cm PermitUserEnvironment
--Specifies whether
--.Pa ~/.ssh/environment
--and
--.Cm environment=
--options in
--.Pa ~/.ssh/authorized_keys
--are processed by
--.Xr sshd 8 .
--The default is
--.Dq no .
--Enabling environment processing may enable users to bypass access
--restrictions in some configurations using mechanisms such as
--.Ev LD_PRELOAD .
--.It Cm PermitUserRC
--Specifies whether any
--.Pa ~/.ssh/rc
--file is executed.
--The default is
--.Dq yes .
--.It Cm PidFile
--Specifies the file that contains the process ID of the
--SSH daemon, or
--.Dq none
--to not write one.
--The default is
--.Pa /var/run/sshd.pid .
--.It Cm Port
--Specifies the port number that
--.Xr sshd 8
--listens on.
--The default is 22.
--Multiple options of this type are permitted.
--See also
--.Cm ListenAddress .
--.It Cm PrintLastLog
--Specifies whether
--.Xr sshd 8
--should print the date and time of the last user login when a user logs
--in interactively.
--On Solaris this option is always ignored since pam_unix_session(5)
--reports the last login time.
--.It Cm PrintMotd
--Specifies whether
--.Xr sshd 8
--should print
--.Pa /etc/motd
--when a user logs in interactively.
--(On some systems it is also printed by the shell,
--.Pa /etc/profile ,
--or equivalent.)
--The default is
--.Dq yes .
--.It Cm Protocol
--Specifies the protocol versions
--.Xr sshd 8
--supports.
--The possible values are
--.Sq 1
--and
--.Sq 2 .
--Multiple versions must be comma-separated.
--The default is
--.Sq 2 .
--Note that the order of the protocol list does not indicate preference,
--because the client selects among multiple protocol versions offered
--by the server.
--Specifying
--.Dq 2,1
--is identical to
--.Dq 1,2 .
--.It Cm PubkeyAcceptedKeyTypes
--Specifies the key types that will be accepted for public key authentication
--as a comma-separated pattern list.
--Alternately if the specified value begins with a
--.Sq +
--character, then the specified key types will be appended to the default set
--instead of replacing them.
--The default for this option is:
--.Bd -literal -offset 3n
--ecdsa-sha2-nistp256-cert-v01@openssh.com,
--ecdsa-sha2-nistp384-cert-v01@openssh.com,
--ecdsa-sha2-nistp521-cert-v01@openssh.com,
--ssh-ed25519-cert-v01@openssh.com,
--ssh-rsa-cert-v01@openssh.com,
--ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
--ssh-ed25519,ssh-rsa
--.Ed
--.Pp
--The
--.Fl Q
--option of
--.Xr ssh 1
--may be used to list supported key types.
--.It Cm PubkeyAuthentication
--Specifies whether public key authentication is allowed.
--The default is
--.Dq yes .
--Note that this option applies to protocol version 2 only.
--.It Cm RekeyLimit
--Specifies the maximum amount of data that may be transmitted before the
--session key is renegotiated, optionally followed a maximum amount of
--time that may pass before the session key is renegotiated.
--The first argument is specified in bytes and may have a suffix of
--.Sq K ,
--.Sq M ,
--or
--.Sq G
--to indicate Kilobytes, Megabytes, or Gigabytes, respectively.
--The default is between
--.Sq 1G
--and
--.Sq 4G ,
--depending on the cipher.
--The optional second value is specified in seconds and may use any of the
--units documented in the
--.Sx TIME FORMATS
--section.
--The default value for
--.Cm RekeyLimit
--is
--.Dq default none ,
--which means that rekeying is performed after the cipher's default amount
--of data has been sent or received and no time based rekeying is done.
--This option applies to protocol version 2 only.
--.It Cm RevokedKeys
--Specifies revoked public keys file, or
--.Dq none
--to not use one.
--Keys listed in this file will be refused for public key authentication.
--Note that if this file is not readable, then public key authentication will
--be refused for all users.
--Keys may be specified as a text file, listing one public key per line, or as
--an OpenSSH Key Revocation List (KRL) as generated by
--.Xr ssh-keygen 1 .
--For more information on KRLs, see the KEY REVOCATION LISTS section in
--.Xr ssh-keygen 1 .
--.It Cm RhostsRSAAuthentication
--Specifies whether rhosts or /etc/hosts.equiv authentication together
--with successful RSA host authentication is allowed.
--The default is
--.Dq no .
--This option applies to protocol version 1 only.
--.It Cm RSAAuthentication
--Specifies whether pure RSA authentication is allowed.
--The default is
--.Dq yes .
--This option applies to protocol version 1 only.
--.It Cm ServerKeyBits
--Defines the number of bits in the ephemeral protocol version 1 server key.
--The default and minimum value is 1024.
--.It Cm StreamLocalBindMask
--Sets the octal file creation mode mask
--.Pq umask
--used when creating a Unix-domain socket file for local or remote
--port forwarding.
--This option is only used for port forwarding to a Unix-domain socket file.
--.Pp
--The default value is 0177, which creates a Unix-domain socket file that is
--readable and writable only by the owner.
--Note that not all operating systems honor the file mode on Unix-domain
--socket files.
--.It Cm StreamLocalBindUnlink
--Specifies whether to remove an existing Unix-domain socket file for local
--or remote port forwarding before creating a new one.
--If the socket file already exists and
--.Cm StreamLocalBindUnlink
--is not enabled,
--.Nm sshd
--will be unable to forward the port to the Unix-domain socket file.
--This option is only used for port forwarding to a Unix-domain socket file.
--.Pp
--The argument must be
--.Dq yes
--or
--.Dq no .
--The default is
--.Dq no .
--.It Cm StrictModes
--Specifies whether
--.Xr sshd 8
--should check file modes and ownership of the
--user's files and home directory before accepting login.
--This is normally desirable because novices sometimes accidentally leave their
--directory or files world-writable.
--The default is
--.Dq yes .
--Note that this does not apply to
--.Cm ChrootDirectory ,
--whose permissions and ownership are checked unconditionally.
--.It Cm Subsystem
--Configures an external subsystem (e.g. file transfer daemon).
--Arguments should be a subsystem name and a command (with optional arguments)
--to execute upon subsystem request.
--.Pp
--The command
--.Xr sftp-server 8
--implements the
--.Dq sftp
--file transfer subsystem.
--.Pp
--Alternately the name
--.Dq internal-sftp
--implements an in-process
--.Dq sftp
--server.
--This may simplify configurations using
--.Cm ChrootDirectory
--to force a different filesystem root on clients.
--.Pp
--By default no subsystems are defined.
--Note that this option applies to protocol version 2 only.
--.It Cm SyslogFacility
--Gives the facility code that is used when logging messages from
--.Xr sshd 8 .
--The possible values are: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2,
--LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7.
--The default is AUTH.
--.It Cm TCPKeepAlive
--Specifies whether the system should send TCP keepalive messages to the
--other side.
--If they are sent, death of the connection or crash of one
--of the machines will be properly noticed.
--However, this means that
--connections will die if the route is down temporarily, and some people
--find it annoying.
--On the other hand, if TCP keepalives are not sent,
--sessions may hang indefinitely on the server, leaving
--.Dq ghost
--users and consuming server resources.
--.Pp
--The default is
--.Dq yes
--(to send TCP keepalive messages), and the server will notice
--if the network goes down or the client host crashes.
--This avoids infinitely hanging sessions.
--.Pp
--To disable TCP keepalive messages, the value should be set to
--.Dq no .
--.It Cm TrustedUserCAKeys
--Specifies a file containing public keys of certificate authorities that are
--trusted to sign user certificates for authentication, or
--.Dq none
--to not use one.
--Keys are listed one per line; empty lines and comments starting with
--.Ql #
--are allowed.
--If a certificate is presented for authentication and has its signing CA key
--listed in this file, then it may be used for authentication for any user
--listed in the certificate's principals list.
--Note that certificates that lack a list of principals will not be permitted
--for authentication using
--.Cm TrustedUserCAKeys .
--For more details on certificates, see the CERTIFICATES section in
--.Xr ssh-keygen 1 .
--.It Cm UseDNS
--Specifies whether
--.Xr sshd 8
--should look up the remote host name, and to check that
--the resolved host name for the remote IP address maps back to the
--very same IP address.
--.Pp
--If this option is set to
--.Dq no
--(the default) then only addresses and not host names may be used in
--.Pa ~/.ssh/known_hosts
--.Cm from
--and
--.Nm
--.Cm Match
--.Cm Host
--directives.
--.It Cm UseLogin
--Specifies whether
--.Xr login 1
--is used for interactive login sessions.
--The default is
--.Dq no .
--Note that
--.Xr login 1
--is never used for remote command execution.
--Note also, that if this is enabled,
--.Cm X11Forwarding
--will be disabled because
--.Xr login 1
--does not know how to handle
--.Xr xauth 1
--cookies.
--If
--.Cm UsePrivilegeSeparation
--is specified, it will be disabled after authentication.
--.It Cm UsePAM
--Enables the Pluggable Authentication Module interface.
--If set to
--.Dq yes
--this will enable PAM authentication using
--.Cm ChallengeResponseAuthentication
--and
--.Cm PasswordAuthentication
--in addition to PAM account and session module processing for all
--authentication types.
--.Pp
--Because PAM challenge-response authentication usually serves an equivalent
--role to password authentication, you should disable either
--.Cm PasswordAuthentication
--or
--.Cm ChallengeResponseAuthentication.
--.Pp
--If
--.Cm UsePAM
--is enabled, you will not be able to run
--.Xr sshd 8
--as a non-root user.
--The default is
--.Dq no .
--.It Cm UsePrivilegeSeparation
--Specifies whether
--.Xr sshd 8
--separates privileges by creating an unprivileged child process
--to deal with incoming network traffic.
--After successful authentication, another process will be created that has
--the privilege of the authenticated user.
--The goal of privilege separation is to prevent privilege
--escalation by containing any corruption within the unprivileged processes.
--The default is
--.Dq yes .
--If
--.Cm UsePrivilegeSeparation
--is set to
--.Dq sandbox
--then the pre-authentication unprivileged process is subject to additional
--restrictions.
--.It Cm VersionAddendum
--Optionally specifies additional text to append to the SSH protocol banner
--sent by the server upon connection.
--The default is
--.Dq none .
--.It Cm X11DisplayOffset
--Specifies the first display number available for
--.Xr sshd 8 Ns 's
--X11 forwarding.
--This prevents sshd from interfering with real X11 servers.
--The default is 10.
--.It Cm X11Forwarding
--Specifies whether X11 forwarding is permitted.
--The argument must be
--.Dq yes
--or
--.Dq no .
--The default is
--.Dq no .
--.Pp
--When X11 forwarding is enabled, there may be additional exposure to
--the server and to client displays if the
--.Xr sshd 8
--proxy display is configured to listen on the wildcard address (see
--.Cm X11UseLocalhost
--below), though this is not the default.
--Additionally, the authentication spoofing and authentication data
--verification and substitution occur on the client side.
--The security risk of using X11 forwarding is that the client's X11
--display server may be exposed to attack when the SSH client requests
--forwarding (see the warnings for
--.Cm ForwardX11
--in
--.Xr ssh_config 5 ) .
--A system administrator may have a stance in which they want to
--protect clients that may expose themselves to attack by unwittingly
--requesting X11 forwarding, which can warrant a
--.Dq no
--setting.
--.Pp
--Note that disabling X11 forwarding does not prevent users from
--forwarding X11 traffic, as users can always install their own forwarders.
--X11 forwarding is automatically disabled if
--.Cm UseLogin
--is enabled.
--.It Cm X11UseLocalhost
--Specifies whether
--.Xr sshd 8
--should bind the X11 forwarding server to the loopback address or to
--the wildcard address.
--By default,
--sshd binds the forwarding server to the loopback address and sets the
--hostname part of the
--.Ev DISPLAY
--environment variable to
--.Dq localhost .
--This prevents remote hosts from connecting to the proxy display.
--However, some older X11 clients may not function with this
--configuration.
--.Cm X11UseLocalhost
--may be set to
--.Dq no
--to specify that the forwarding server should be bound to the wildcard
--address.
--The argument must be
--.Dq yes
--or
--.Dq no .
--The default is
--.Dq yes .
--.It Cm XAuthLocation
--Specifies the full pathname of the
--.Xr xauth 1
--program, or
--.Dq none
--to not use one.
--The default is
--.Pa /usr/X11R6/bin/xauth .
--.El
--.Sh TIME FORMATS
--.Xr sshd 8
--command-line arguments and configuration file options that specify time
--may be expressed using a sequence of the form:
--.Sm off
--.Ar time Op Ar qualifier ,
--.Sm on
--where
--.Ar time
--is a positive integer value and
--.Ar qualifier
--is one of the following:
--.Pp
--.Bl -tag -width Ds -compact -offset indent
--.It Aq Cm none
--seconds
--.It Cm s | Cm S
--seconds
--.It Cm m | Cm M
--minutes
--.It Cm h | Cm H
--hours
--.It Cm d | Cm D
--days
--.It Cm w | Cm W
--weeks
--.El
--.Pp
--Each member of the sequence is added together to calculate
--the total time value.
--.Pp
--Time format examples:
--.Pp
--.Bl -tag -width Ds -compact -offset indent
--.It 600
--600 seconds (10 minutes)
--.It 10m
--10 minutes
--.It 1h30m
--1 hour 30 minutes (90 minutes)
--.El
--.Sh FILES
--.Bl -tag -width Ds
--.It Pa /etc/ssh/sshd_config
--Contains configuration data for
--.Xr sshd 8 .
--This file should be writable by root only, but it is recommended
--(though not necessary) that it be world-readable.
--.El
--.Sh SEE ALSO
--.Xr sshd 8 ,
--.Xr pam_unix_session 5
--.Sh AUTHORS
--OpenSSH is a derivative of the original and free
--ssh 1.2.12 release by Tatu Ylonen.
--Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
--Theo de Raadt and Dug Song
--removed many bugs, re-added newer features and
--created OpenSSH.
--Markus Friedl contributed the support for SSH
--protocol versions 1.5 and 2.0.
--Niels Provos and Markus Friedl contributed support
--for privilege separation.
--- 
-2.3.2 (Apple Git-55)
-
--- /dev/null	Wed Feb 10 16:25:00 2016
+++ new/build/openssh/patches/0006-Reorganise-man-pages-into-Illumos-numbering-adjust-t.patch	Wed Feb 10 16:25:00 2016
@@ -0,0 +1,9930 @@
+From 310f67442b9faf22eb3a30a614202cdd04f99119 Mon Sep 17 00:00:00 2001
+From: oracle <solaris@oracle.com>
+Date: Mon, 3 Aug 2015 14:34:55 -0700
+Subject: [PATCH 06/36] Reorganise man pages into Illumos numbering, adjust
+ text
+
+---
+ Makefile.in          |   22 +-
+ moduli.4             |  127 ++++
+ moduli.5             |  127 ----
+ sftp-server.1m       |  170 +++++
+ sftp-server.8        |  170 -----
+ ssh-keygen.1         |    6 +-
+ ssh-keysign.1m       |   93 +++
+ ssh-keysign.8        |   93 ---
+ ssh-pkcs11-helper.1m |   43 ++
+ ssh-pkcs11-helper.8  |   43 --
+ ssh_config.4         | 1726 +++++++++++++++++++++++++++++++++++++++++++++++++
+ ssh_config.5         | 1726 -------------------------------------------------
+ sshd.1m              |  971 ++++++++++++++++++++++++++++
+ sshd.8               |  971 ----------------------------
+ sshd_config.4        | 1736 ++++++++++++++++++++++++++++++++++++++++++++++++++
+ sshd_config.5        | 1736 --------------------------------------------------
+ 16 files changed, 4879 insertions(+), 4881 deletions(-)
+ create mode 100644 moduli.4
+ delete mode 100644 moduli.5
+ create mode 100644 sftp-server.1m
+ delete mode 100644 sftp-server.8
+ create mode 100644 ssh-keysign.1m
+ delete mode 100644 ssh-keysign.8
+ create mode 100644 ssh-pkcs11-helper.1m
+ delete mode 100644 ssh-pkcs11-helper.8
+ create mode 100644 ssh_config.4
+ delete mode 100644 ssh_config.5
+ create mode 100644 sshd.1m
+ delete mode 100644 sshd.8
+ create mode 100644 sshd_config.4
+ delete mode 100644 sshd_config.5
+
+diff --git a/Makefile.in b/Makefile.in
+index bc4660f..9f953e1 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -113,8 +113,8 @@ SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \
+ 	sandbox-null.o sandbox-rlimit.o sandbox-systrace.o sandbox-darwin.o \
+ 	sandbox-seccomp-filter.o sandbox-capsicum.o sandbox-solaris.o
+ 
+-MANPAGES	= moduli.5.out scp.1.out ssh-add.1.out ssh-agent.1.out ssh-keygen.1.out ssh-keyscan.1.out ssh.1.out sshd.8.out sftp-server.8.out sftp.1.out ssh-keysign.8.out ssh-pkcs11-helper.8.out sshd_config.5.out ssh_config.5.out
+-MANPAGES_IN	= moduli.5 scp.1 ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh-keyscan.1 ssh.1 sshd.8 sftp-server.8 sftp.1 ssh-keysign.8 ssh-pkcs11-helper.8 sshd_config.5 ssh_config.5
++MANPAGES	= moduli.4.out scp.1.out ssh-add.1.out ssh-agent.1.out ssh-keygen.1.out ssh-keyscan.1.out ssh.1.out sshd.1m.out sftp-server.1m.out sftp.1.out ssh-keysign.1m.out ssh-pkcs11-helper.1m.out sshd_config.4.out ssh_config.4.out
++MANPAGES_IN	= moduli.4 scp.1 ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh-keyscan.1 ssh.1 sshd.1m sftp-server.1m sftp.1 ssh-keysign.1m ssh-pkcs11-helper.1m sshd_config.4 ssh_config.4
+ MANTYPE		= @MANTYPE@
+ 
+ CONFIGFILES=sshd_config.out ssh_config.out moduli.out
+@@ -308,8 +308,8 @@ install-files:
+ 	$(srcdir)/mkinstalldirs $(DESTDIR)$(sbindir)
+ 	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)
+ 	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/$(mansubdir)1
+-	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/$(mansubdir)5
+-	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/$(mansubdir)8
++	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/$(mansubdir)4
++	$(srcdir)/mkinstalldirs $(DESTDIR)$(mandir)/$(mansubdir)1m
+ 	$(srcdir)/mkinstalldirs $(DESTDIR)$(libexecdir)
+ 	(umask 022 ; $(srcdir)/mkinstalldirs $(DESTDIR)$(PRIVSEP_PATH))
+ 	$(INSTALL) -m 0755 $(STRIP_OPT) ssh$(EXEEXT) $(DESTDIR)$(bindir)/ssh$(EXEEXT)
+@@ -329,14 +329,14 @@ install-files:
+ 	$(INSTALL) -m 644 ssh-agent.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-agent.1
+ 	$(INSTALL) -m 644 ssh-keygen.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-keygen.1
+ 	$(INSTALL) -m 644 ssh-keyscan.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/ssh-keyscan.1
+-	$(INSTALL) -m 644 moduli.5.out $(DESTDIR)$(mandir)/$(mansubdir)5/moduli.5
+-	$(INSTALL) -m 644 sshd_config.5.out $(DESTDIR)$(mandir)/$(mansubdir)5/sshd_config.5
+-	$(INSTALL) -m 644 ssh_config.5.out $(DESTDIR)$(mandir)/$(mansubdir)5/ssh_config.5
+-	$(INSTALL) -m 644 sshd.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/sshd.8
++	$(INSTALL) -m 644 moduli.4.out $(DESTDIR)$(mandir)/$(mansubdir)4/moduli.4
++	$(INSTALL) -m 644 sshd_config.4.out $(DESTDIR)$(mandir)/$(mansubdir)4/sshd_config.4
++	$(INSTALL) -m 644 ssh_config.4.out $(DESTDIR)$(mandir)/$(mansubdir)4/ssh_config.4
++	$(INSTALL) -m 644 sshd.1m.out $(DESTDIR)$(mandir)/$(mansubdir)1m/sshd.1m
+ 	$(INSTALL) -m 644 sftp.1.out $(DESTDIR)$(mandir)/$(mansubdir)1/sftp.1
+-	$(INSTALL) -m 644 sftp-server.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/sftp-server.8
+-	$(INSTALL) -m 644 ssh-keysign.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/ssh-keysign.8
+-	$(INSTALL) -m 644 ssh-pkcs11-helper.8.out $(DESTDIR)$(mandir)/$(mansubdir)8/ssh-pkcs11-helper.8
++	$(INSTALL) -m 644 sftp-server.1m.out $(DESTDIR)$(mandir)/$(mansubdir)1m/sftp-server.1m
++	$(INSTALL) -m 644 ssh-keysign.1m.out $(DESTDIR)$(mandir)/$(mansubdir)1m/ssh-keysign.1m
++	$(INSTALL) -m 644 ssh-pkcs11-helper.1m.out $(DESTDIR)$(mandir)/$(mansubdir)1m/ssh-pkcs11-helper.1m
+ 	-rm -f $(DESTDIR)$(bindir)/slogin
+ 	ln -s ./ssh$(EXEEXT) $(DESTDIR)$(bindir)/slogin
+ 	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/slogin.1
+diff --git a/moduli.4 b/moduli.4
+new file mode 100644
+index 0000000..f87556b
+--- /dev/null
++++ b/moduli.4
+@@ -0,0 +1,127 @@
++.\"	$OpenBSD: moduli.5,v 1.17 2012/09/26 17:34:38 jmc Exp $
++.\"
++.\" Copyright (c) 2008 Damien Miller <djm@mindrot.org>
++.\"
++.\" Permission to use, copy, modify, and distribute this software for any
++.\" purpose with or without fee is hereby granted, provided that the above
++.\" copyright notice and this permission notice appear in all copies.
++.\"
++.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
++.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
++.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
++.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
++.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
++.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
++.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
++.Dd $Mdocdate: September 26 2012 $
++.Dt MODULI 4
++.Os
++.Sh NAME
++.Nm moduli
++.Nd Diffie-Hellman moduli
++.Sh DESCRIPTION
++The
++.Pa /etc/moduli
++file contains prime numbers and generators for use by
++.Xr sshd 1M
++in the Diffie-Hellman Group Exchange key exchange method.
++.Pp
++New moduli may be generated with
++.Xr ssh-keygen 1
++using a two-step process.
++An initial
++.Em candidate generation
++pass, using
++.Ic ssh-keygen -G ,
++calculates numbers that are likely to be useful.
++A second
++.Em primality testing
++pass, using
++.Ic ssh-keygen -T ,
++provides a high degree of assurance that the numbers are prime and are
++safe for use in Diffie-Hellman operations by
++.Xr sshd 1M .
++This
++.Nm
++format is used as the output from each pass.
++.Pp
++The file consists of newline-separated records, one per modulus,
++containing seven space-separated fields.
++These fields are as follows:
++.Bl -tag -width Description -offset indent
++.It timestamp
++The time that the modulus was last processed as YYYYMMDDHHMMSS.
++.It type
++Decimal number specifying the internal structure of the prime modulus.
++Supported types are:
++.Pp
++.Bl -tag -width 0x00 -compact
++.It 0
++Unknown, not tested.
++.It 2
++"Safe" prime; (p-1)/2 is also prime.
++.It 4
++Sophie Germain; 2p+1 is also prime.
++.El
++.Pp
++Moduli candidates initially produced by
++.Xr ssh-keygen 1
++are Sophie Germain primes (type 4).
++Further primality testing with
++.Xr ssh-keygen 1
++produces safe prime moduli (type 2) that are ready for use in
++.Xr sshd 1M .
++Other types are not used by OpenSSH.
++.It tests
++Decimal number indicating the type of primality tests that the number
++has been subjected to represented as a bitmask of the following values:
++.Pp
++.Bl -tag -width 0x00 -compact
++.It 0x00
++Not tested.
++.It 0x01
++Composite number \(en not prime.
++.It 0x02
++Sieve of Eratosthenes.
++.It 0x04
++Probabilistic Miller-Rabin primality tests.
++.El
++.Pp
++The
++.Xr ssh-keygen 1
++moduli candidate generation uses the Sieve of Eratosthenes (flag 0x02).
++Subsequent
++.Xr ssh-keygen 1
++primality tests are Miller-Rabin tests (flag 0x04).
++.It trials
++Decimal number indicating the number of primality trials
++that have been performed on the modulus.
++.It size
++Decimal number indicating the size of the prime in bits.
++.It generator
++The recommended generator for use with this modulus (hexadecimal).
++.It modulus
++The modulus itself in hexadecimal.
++.El
++.Pp
++When performing Diffie-Hellman Group Exchange,
++.Xr sshd 1M
++first estimates the size of the modulus required to produce enough
++Diffie-Hellman output to sufficiently key the selected symmetric cipher.
++.Xr sshd 1M
++then randomly selects a modulus from
++.Fa /etc/moduli
++that best meets the size requirement.
++.Sh SEE ALSO
++.Xr ssh-keygen 1 ,
++.Xr sshd 1M
++.Sh STANDARDS
++.Rs
++.%A M. Friedl
++.%A N. Provos
++.%A W. Simpson
++.%D March 2006
++.%R RFC 4419
++.%T Diffie-Hellman Group Exchange for the Secure Shell (SSH) Transport Layer Protocol
++.%D 2006
++.Re
+diff --git a/moduli.5 b/moduli.5
+deleted file mode 100644
+index ef0de08..0000000
+--- a/moduli.5
++++ /dev/null
+@@ -1,127 +0,0 @@
+-.\"	$OpenBSD: moduli.5,v 1.17 2012/09/26 17:34:38 jmc Exp $
+-.\"
+-.\" Copyright (c) 2008 Damien Miller <djm@mindrot.org>
+-.\"
+-.\" Permission to use, copy, modify, and distribute this software for any
+-.\" purpose with or without fee is hereby granted, provided that the above
+-.\" copyright notice and this permission notice appear in all copies.
+-.\"
+-.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+-.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+-.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+-.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+-.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+-.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+-.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+-.Dd $Mdocdate: September 26 2012 $
+-.Dt MODULI 5
+-.Os
+-.Sh NAME
+-.Nm moduli
+-.Nd Diffie-Hellman moduli
+-.Sh DESCRIPTION
+-The
+-.Pa /etc/moduli
+-file contains prime numbers and generators for use by
+-.Xr sshd 8
+-in the Diffie-Hellman Group Exchange key exchange method.
+-.Pp
+-New moduli may be generated with
+-.Xr ssh-keygen 1
+-using a two-step process.
+-An initial
+-.Em candidate generation
+-pass, using
+-.Ic ssh-keygen -G ,
+-calculates numbers that are likely to be useful.
+-A second
+-.Em primality testing
+-pass, using
+-.Ic ssh-keygen -T ,
+-provides a high degree of assurance that the numbers are prime and are
+-safe for use in Diffie-Hellman operations by
+-.Xr sshd 8 .
+-This
+-.Nm
+-format is used as the output from each pass.
+-.Pp
+-The file consists of newline-separated records, one per modulus,
+-containing seven space-separated fields.
+-These fields are as follows:
+-.Bl -tag -width Description -offset indent
+-.It timestamp
+-The time that the modulus was last processed as YYYYMMDDHHMMSS.
+-.It type
+-Decimal number specifying the internal structure of the prime modulus.
+-Supported types are:
+-.Pp
+-.Bl -tag -width 0x00 -compact
+-.It 0
+-Unknown, not tested.
+-.It 2
+-"Safe" prime; (p-1)/2 is also prime.
+-.It 4
+-Sophie Germain; 2p+1 is also prime.
+-.El
+-.Pp
+-Moduli candidates initially produced by
+-.Xr ssh-keygen 1
+-are Sophie Germain primes (type 4).
+-Further primality testing with
+-.Xr ssh-keygen 1
+-produces safe prime moduli (type 2) that are ready for use in
+-.Xr sshd 8 .
+-Other types are not used by OpenSSH.
+-.It tests
+-Decimal number indicating the type of primality tests that the number
+-has been subjected to represented as a bitmask of the following values:
+-.Pp
+-.Bl -tag -width 0x00 -compact
+-.It 0x00
+-Not tested.
+-.It 0x01
+-Composite number \(en not prime.
+-.It 0x02
+-Sieve of Eratosthenes.
+-.It 0x04
+-Probabilistic Miller-Rabin primality tests.
+-.El
+-.Pp
+-The
+-.Xr ssh-keygen 1
+-moduli candidate generation uses the Sieve of Eratosthenes (flag 0x02).
+-Subsequent
+-.Xr ssh-keygen 1
+-primality tests are Miller-Rabin tests (flag 0x04).
+-.It trials
+-Decimal number indicating the number of primality trials
+-that have been performed on the modulus.
+-.It size
+-Decimal number indicating the size of the prime in bits.
+-.It generator
+-The recommended generator for use with this modulus (hexadecimal).
+-.It modulus
+-The modulus itself in hexadecimal.
+-.El
+-.Pp
+-When performing Diffie-Hellman Group Exchange,
+-.Xr sshd 8
+-first estimates the size of the modulus required to produce enough
+-Diffie-Hellman output to sufficiently key the selected symmetric cipher.
+-.Xr sshd 8
+-then randomly selects a modulus from
+-.Fa /etc/moduli
+-that best meets the size requirement.
+-.Sh SEE ALSO
+-.Xr ssh-keygen 1 ,
+-.Xr sshd 8
+-.Sh STANDARDS
+-.Rs
+-.%A M. Friedl
+-.%A N. Provos
+-.%A W. Simpson
+-.%D March 2006
+-.%R RFC 4419
+-.%T Diffie-Hellman Group Exchange for the Secure Shell (SSH) Transport Layer Protocol
+-.%D 2006
+-.Re
+diff --git a/sftp-server.1m b/sftp-server.1m
+new file mode 100644
+index 0000000..42354c2
+--- /dev/null
++++ b/sftp-server.1m
+@@ -0,0 +1,170 @@
++.\" $OpenBSD: sftp-server.8,v 1.27 2014/12/11 04:16:14 djm Exp $
++.\"
++.\" Copyright (c) 2000 Markus Friedl.  All rights reserved.
++.\"
++.\" Redistribution and use in source and binary forms, with or without
++.\" modification, are permitted provided that the following conditions
++.\" are met:
++.\" 1. Redistributions of source code must retain the above copyright
++.\"    notice, this list of conditions and the following disclaimer.
++.\" 2. Redistributions in binary form must reproduce the above copyright
++.\"    notice, this list of conditions and the following disclaimer in the
++.\"    documentation and/or other materials provided with the distribution.
++.\"
++.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
++.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
++.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
++.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
++.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
++.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
++.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++.\"
++.Dd $Mdocdate: December 11 2014 $
++.Dt SFTP-SERVER 1M
++.Os
++.Sh NAME
++.Nm sftp-server
++.Nd SFTP server subsystem
++.Sh SYNOPSIS
++.Nm sftp-server
++.Bk -words
++.Op Fl ehR
++.Op Fl d Ar start_directory
++.Op Fl f Ar log_facility
++.Op Fl l Ar log_level
++.Op Fl P Ar blacklisted_requests
++.Op Fl p Ar whitelisted_requests
++.Op Fl u Ar umask
++.Ek
++.Nm
++.Fl Q Ar protocol_feature
++.Sh DESCRIPTION
++.Nm
++is a program that speaks the server side of SFTP protocol
++to stdout and expects client requests from stdin.
++.Nm
++is not intended to be called directly, but from
++.Xr sshd 1M
++using the
++.Cm Subsystem
++option.
++.Pp
++Command-line flags to
++.Nm
++should be specified in the
++.Cm Subsystem
++declaration.
++See
++.Xr sshd_config 4
++for more information.
++.Pp
++Valid options are:
++.Bl -tag -width Ds
++.It Fl d Ar start_directory
++specifies an alternate starting directory for users.
++The pathname may contain the following tokens that are expanded at runtime:
++%% is replaced by a literal '%',
++%d is replaced by the home directory of the user being authenticated,
++and %u is replaced by the username of that user.
++The default is to use the user's home directory.
++This option is useful in conjunction with the
++.Xr sshd_config 4
++.Cm ChrootDirectory
++option.
++.It Fl e
++Causes
++.Nm
++to print logging information to stderr instead of syslog for debugging.
++.It Fl f Ar log_facility
++Specifies the facility code that is used when logging messages from
++.Nm .
++The possible values are: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2,
++LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7.
++The default is AUTH.
++.It Fl h
++Displays
++.Nm
++usage information.
++.It Fl l Ar log_level
++Specifies which messages will be logged by
++.Nm .
++The possible values are:
++QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3.
++INFO and VERBOSE log transactions that
++.Nm
++performs on behalf of the client.
++DEBUG and DEBUG1 are equivalent.
++DEBUG2 and DEBUG3 each specify higher levels of debugging output.
++The default is ERROR.
++.It Fl P Ar blacklisted_requests
++Specify a comma-separated list of SFTP protocol requests that are banned by
++the server.
++.Nm
++will reply to any blacklisted request with a failure.
++The
++.Fl Q
++flag can be used to determine the supported request types.
++If both a blacklist and a whitelist are specified, then the blacklist is
++applied before the whitelist.
++.It Fl p Ar whitelisted_requests
++Specify a comma-separated list of SFTP protocol requests that are permitted
++by the server.
++All request types that are not on the whitelist will be logged and replied
++to with a failure message.
++.Pp
++Care must be taken when using this feature to ensure that requests made
++implicitly by SFTP clients are permitted.
++.It Fl Q Ar protocol_feature
++Query protocol features supported by
++.Nm .
++At present the only feature that may be queried is
++.Dq requests ,
++which may be used for black or whitelisting (flags
++.Fl P
++and
++.Fl p
++respectively).
++.It Fl R
++Places this instance of
++.Nm
++into a read-only mode.
++Attempts to open files for writing, as well as other operations that change
++the state of the filesystem, will be denied.
++.It Fl u Ar umask
++Sets an explicit
++.Xr umask 2
++to be applied to newly-created files and directories, instead of the
++user's default mask.
++.El
++.Pp
++On some systems,
++.Nm
++must be able to access
++.Pa /dev/log
++for logging to work, and use of
++.Nm
++in a chroot configuration therefore requires that
++.Xr syslogd 8
++establish a logging socket inside the chroot directory.
++.Sh SEE ALSO
++.Xr sftp 1 ,
++.Xr ssh 1 ,
++.Xr sshd_config 4 ,
++.Xr sshd 1M
++.Rs
++.%A T. Ylonen
++.%A S. Lehtinen
++.%T "SSH File Transfer Protocol"
++.%N draft-ietf-secsh-filexfer-02.txt
++.%D October 2001
++.%O work in progress material
++.Re
++.Sh HISTORY
++.Nm
++first appeared in
++.Ox 2.8 .
++.Sh AUTHORS
++.An Markus Friedl Aq Mt markus@openbsd.org
+diff --git a/sftp-server.8 b/sftp-server.8
+deleted file mode 100644
+index c117398..0000000
+--- a/sftp-server.8
++++ /dev/null
+@@ -1,170 +0,0 @@
+-.\" $OpenBSD: sftp-server.8,v 1.27 2014/12/11 04:16:14 djm Exp $
+-.\"
+-.\" Copyright (c) 2000 Markus Friedl.  All rights reserved.
+-.\"
+-.\" Redistribution and use in source and binary forms, with or without
+-.\" modification, are permitted provided that the following conditions
+-.\" are met:
+-.\" 1. Redistributions of source code must retain the above copyright
+-.\"    notice, this list of conditions and the following disclaimer.
+-.\" 2. Redistributions in binary form must reproduce the above copyright
+-.\"    notice, this list of conditions and the following disclaimer in the
+-.\"    documentation and/or other materials provided with the distribution.
+-.\"
+-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+-.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+-.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+-.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+-.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+-.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+-.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+-.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+-.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+-.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-.\"
+-.Dd $Mdocdate: December 11 2014 $
+-.Dt SFTP-SERVER 8
+-.Os
+-.Sh NAME
+-.Nm sftp-server
+-.Nd SFTP server subsystem
+-.Sh SYNOPSIS
+-.Nm sftp-server
+-.Bk -words
+-.Op Fl ehR
+-.Op Fl d Ar start_directory
+-.Op Fl f Ar log_facility
+-.Op Fl l Ar log_level
+-.Op Fl P Ar blacklisted_requests
+-.Op Fl p Ar whitelisted_requests
+-.Op Fl u Ar umask
+-.Ek
+-.Nm
+-.Fl Q Ar protocol_feature
+-.Sh DESCRIPTION
+-.Nm
+-is a program that speaks the server side of SFTP protocol
+-to stdout and expects client requests from stdin.
+-.Nm
+-is not intended to be called directly, but from
+-.Xr sshd 8
+-using the
+-.Cm Subsystem
+-option.
+-.Pp
+-Command-line flags to
+-.Nm
+-should be specified in the
+-.Cm Subsystem
+-declaration.
+-See
+-.Xr sshd_config 5
+-for more information.
+-.Pp
+-Valid options are:
+-.Bl -tag -width Ds
+-.It Fl d Ar start_directory
+-specifies an alternate starting directory for users.
+-The pathname may contain the following tokens that are expanded at runtime:
+-%% is replaced by a literal '%',
+-%d is replaced by the home directory of the user being authenticated,
+-and %u is replaced by the username of that user.
+-The default is to use the user's home directory.
+-This option is useful in conjunction with the
+-.Xr sshd_config 5
+-.Cm ChrootDirectory
+-option.
+-.It Fl e
+-Causes
+-.Nm
+-to print logging information to stderr instead of syslog for debugging.
+-.It Fl f Ar log_facility
+-Specifies the facility code that is used when logging messages from
+-.Nm .
+-The possible values are: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2,
+-LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7.
+-The default is AUTH.
+-.It Fl h
+-Displays
+-.Nm
+-usage information.
+-.It Fl l Ar log_level
+-Specifies which messages will be logged by
+-.Nm .
+-The possible values are:
+-QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3.
+-INFO and VERBOSE log transactions that
+-.Nm
+-performs on behalf of the client.
+-DEBUG and DEBUG1 are equivalent.
+-DEBUG2 and DEBUG3 each specify higher levels of debugging output.
+-The default is ERROR.
+-.It Fl P Ar blacklisted_requests
+-Specify a comma-separated list of SFTP protocol requests that are banned by
+-the server.
+-.Nm
+-will reply to any blacklisted request with a failure.
+-The
+-.Fl Q
+-flag can be used to determine the supported request types.
+-If both a blacklist and a whitelist are specified, then the blacklist is
+-applied before the whitelist.
+-.It Fl p Ar whitelisted_requests
+-Specify a comma-separated list of SFTP protocol requests that are permitted
+-by the server.
+-All request types that are not on the whitelist will be logged and replied
+-to with a failure message.
+-.Pp
+-Care must be taken when using this feature to ensure that requests made
+-implicitly by SFTP clients are permitted.
+-.It Fl Q Ar protocol_feature
+-Query protocol features supported by
+-.Nm .
+-At present the only feature that may be queried is
+-.Dq requests ,
+-which may be used for black or whitelisting (flags
+-.Fl P
+-and
+-.Fl p
+-respectively).
+-.It Fl R
+-Places this instance of
+-.Nm
+-into a read-only mode.
+-Attempts to open files for writing, as well as other operations that change
+-the state of the filesystem, will be denied.
+-.It Fl u Ar umask
+-Sets an explicit
+-.Xr umask 2
+-to be applied to newly-created files and directories, instead of the
+-user's default mask.
+-.El
+-.Pp
+-On some systems,
+-.Nm
+-must be able to access
+-.Pa /dev/log
+-for logging to work, and use of
+-.Nm
+-in a chroot configuration therefore requires that
+-.Xr syslogd 8
+-establish a logging socket inside the chroot directory.
+-.Sh SEE ALSO
+-.Xr sftp 1 ,
+-.Xr ssh 1 ,
+-.Xr sshd_config 5 ,
+-.Xr sshd 8
+-.Rs
+-.%A T. Ylonen
+-.%A S. Lehtinen
+-.%T "SSH File Transfer Protocol"
+-.%N draft-ietf-secsh-filexfer-02.txt
+-.%D October 2001
+-.%O work in progress material
+-.Re
+-.Sh HISTORY
+-.Nm
+-first appeared in
+-.Ox 2.8 .
+-.Sh AUTHORS
+-.An Markus Friedl Aq Mt markus@openbsd.org
+diff --git a/ssh-keygen.1 b/ssh-keygen.1
+index ed17a08..9616030 100644
+--- a/ssh-keygen.1
++++ b/ssh-keygen.1
+@@ -174,9 +174,7 @@ key in
+ .Pa ~/.ssh/id_ed25519
+ or
+ .Pa ~/.ssh/id_rsa .
+-Additionally, the system administrator may use this to generate host keys,
+-as seen in
+-.Pa /etc/rc .
++Additionally, the system administrator may use this to generate host keys.
+ .Pp
+ Normally this program generates the key and asks for a file in which
+ to store the private key.
+@@ -224,7 +222,7 @@ for which host keys
+ do not exist, generate the host keys with the default key file path,
+ an empty passphrase, default bits for the key type, and default comment.
+ This is used by
+-.Pa /etc/rc
++.Pa /lib/svc/method/sshd
+ to generate new host keys.
+ .It Fl a Ar rounds
+ When saving a new-format private key (i.e. an ed25519 key or any SSH protocol
+diff --git a/ssh-keysign.1m b/ssh-keysign.1m
+new file mode 100644
+index 0000000..60c96ad
+--- /dev/null
++++ b/ssh-keysign.1m
+@@ -0,0 +1,93 @@
++.\" $OpenBSD: ssh-keysign.8,v 1.14 2013/12/07 11:58:46 naddy Exp $
++.\"
++.\" Copyright (c) 2002 Markus Friedl.  All rights reserved.
++.\"
++.\" Redistribution and use in source and binary forms, with or without
++.\" modification, are permitted provided that the following conditions
++.\" are met:
++.\" 1. Redistributions of source code must retain the above copyright
++.\"    notice, this list of conditions and the following disclaimer.
++.\" 2. Redistributions in binary form must reproduce the above copyright
++.\"    notice, this list of conditions and the following disclaimer in the
++.\"    documentation and/or other materials provided with the distribution.
++.\"
++.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
++.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
++.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
++.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
++.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
++.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
++.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++.\"
++.Dd $Mdocdate: December 7 2013 $
++.Dt SSH-KEYSIGN 1M
++.Os
++.Sh NAME
++.Nm ssh-keysign
++.Nd ssh helper program for host-based authentication
++.Sh SYNOPSIS
++.Nm
++.Sh DESCRIPTION
++.Nm
++is used by
++.Xr ssh 1
++to access the local host keys and generate the digital signature
++required during host-based authentication with SSH protocol version 2.
++.Pp
++.Nm
++is disabled by default and can only be enabled in the
++global client configuration file
++.Pa /etc/ssh/ssh_config
++by setting
++.Cm EnableSSHKeysign
++to
++.Dq yes .
++.Pp
++.Nm
++is not intended to be invoked by the user, but from
++.Xr ssh 1 .
++See
++.Xr ssh 1
++and
++.Xr sshd 1M
++for more information about host-based authentication.
++.Sh FILES
++.Bl -tag -width Ds -compact
++.It Pa /etc/ssh/ssh_config
++Controls whether
++.Nm
++is enabled.
++.Pp
++.It Pa /etc/ssh/ssh_host_dsa_key
++.It Pa /etc/ssh/ssh_host_ecdsa_key
++.It Pa /etc/ssh/ssh_host_ed25519_key
++.It Pa /etc/ssh/ssh_host_rsa_key
++These files contain the private parts of the host keys used to
++generate the digital signature.
++They should be owned by root, readable only by root, and not
++accessible to others.
++Since they are readable only by root,
++.Nm
++must be set-uid root if host-based authentication is used.
++.Pp
++.It Pa /etc/ssh/ssh_host_dsa_key-cert.pub
++.It Pa /etc/ssh/ssh_host_ecdsa_key-cert.pub
++.It Pa /etc/ssh/ssh_host_ed25519_key-cert.pub
++.It Pa /etc/ssh/ssh_host_rsa_key-cert.pub
++If these files exist they are assumed to contain public certificate
++information corresponding with the private keys above.
++.El
++.Sh SEE ALSO
++.Xr ssh 1 ,
++.Xr ssh-keygen 1 ,
++.Xr ssh_config 4 ,
++.Xr sshd 1M
++.Sh HISTORY
++.Nm
++first appeared in
++.Ox 3.2 .
++.Sh AUTHORS
++.An Markus Friedl Aq Mt markus@openbsd.org
+diff --git a/ssh-keysign.8 b/ssh-keysign.8
+deleted file mode 100644
+index 69d0829..0000000
+--- a/ssh-keysign.8
++++ /dev/null
+@@ -1,93 +0,0 @@
+-.\" $OpenBSD: ssh-keysign.8,v 1.14 2013/12/07 11:58:46 naddy Exp $
+-.\"
+-.\" Copyright (c) 2002 Markus Friedl.  All rights reserved.
+-.\"
+-.\" Redistribution and use in source and binary forms, with or without
+-.\" modification, are permitted provided that the following conditions
+-.\" are met:
+-.\" 1. Redistributions of source code must retain the above copyright
+-.\"    notice, this list of conditions and the following disclaimer.
+-.\" 2. Redistributions in binary form must reproduce the above copyright
+-.\"    notice, this list of conditions and the following disclaimer in the
+-.\"    documentation and/or other materials provided with the distribution.
+-.\"
+-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+-.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+-.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+-.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+-.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+-.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+-.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+-.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+-.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+-.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-.\"
+-.Dd $Mdocdate: December 7 2013 $
+-.Dt SSH-KEYSIGN 8
+-.Os
+-.Sh NAME
+-.Nm ssh-keysign
+-.Nd ssh helper program for host-based authentication
+-.Sh SYNOPSIS
+-.Nm
+-.Sh DESCRIPTION
+-.Nm
+-is used by
+-.Xr ssh 1
+-to access the local host keys and generate the digital signature
+-required during host-based authentication with SSH protocol version 2.
+-.Pp
+-.Nm
+-is disabled by default and can only be enabled in the
+-global client configuration file
+-.Pa /etc/ssh/ssh_config
+-by setting
+-.Cm EnableSSHKeysign
+-to
+-.Dq yes .
+-.Pp
+-.Nm
+-is not intended to be invoked by the user, but from
+-.Xr ssh 1 .
+-See
+-.Xr ssh 1
+-and
+-.Xr sshd 8
+-for more information about host-based authentication.
+-.Sh FILES
+-.Bl -tag -width Ds -compact
+-.It Pa /etc/ssh/ssh_config
+-Controls whether
+-.Nm
+-is enabled.
+-.Pp
+-.It Pa /etc/ssh/ssh_host_dsa_key
+-.It Pa /etc/ssh/ssh_host_ecdsa_key
+-.It Pa /etc/ssh/ssh_host_ed25519_key
+-.It Pa /etc/ssh/ssh_host_rsa_key
+-These files contain the private parts of the host keys used to
+-generate the digital signature.
+-They should be owned by root, readable only by root, and not
+-accessible to others.
+-Since they are readable only by root,
+-.Nm
+-must be set-uid root if host-based authentication is used.
+-.Pp
+-.It Pa /etc/ssh/ssh_host_dsa_key-cert.pub
+-.It Pa /etc/ssh/ssh_host_ecdsa_key-cert.pub
+-.It Pa /etc/ssh/ssh_host_ed25519_key-cert.pub
+-.It Pa /etc/ssh/ssh_host_rsa_key-cert.pub
+-If these files exist they are assumed to contain public certificate
+-information corresponding with the private keys above.
+-.El
+-.Sh SEE ALSO
+-.Xr ssh 1 ,
+-.Xr ssh-keygen 1 ,
+-.Xr ssh_config 5 ,
+-.Xr sshd 8
+-.Sh HISTORY
+-.Nm
+-first appeared in
+-.Ox 3.2 .
+-.Sh AUTHORS
+-.An Markus Friedl Aq Mt markus@openbsd.org
+diff --git a/ssh-pkcs11-helper.1m b/ssh-pkcs11-helper.1m
+new file mode 100644
+index 0000000..646b1fa
+--- /dev/null
++++ b/ssh-pkcs11-helper.1m
+@@ -0,0 +1,43 @@
++.\" $OpenBSD: ssh-pkcs11-helper.8,v 1.4 2013/07/16 00:07:52 schwarze Exp $
++.\"
++.\" Copyright (c) 2010 Markus Friedl.  All rights reserved.
++.\"
++.\" Permission to use, copy, modify, and distribute this software for any
++.\" purpose with or without fee is hereby granted, provided that the above
++.\" copyright notice and this permission notice appear in all copies.
++.\"
++.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
++.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
++.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
++.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
++.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
++.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
++.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
++.\"
++.Dd $Mdocdate: July 16 2013 $
++.Dt SSH-PKCS11-HELPER 1M
++.Os
++.Sh NAME
++.Nm ssh-pkcs11-helper
++.Nd ssh-agent helper program for PKCS#11 support
++.Sh SYNOPSIS
++.Nm
++.Sh DESCRIPTION
++.Nm
++is used by
++.Xr ssh-agent 1
++to access keys provided by a PKCS#11 token.
++.Pp
++.Nm
++is not intended to be invoked by the user, but from
++.Xr ssh-agent 1 .
++.Sh SEE ALSO
++.Xr ssh 1 ,
++.Xr ssh-add 1 ,
++.Xr ssh-agent 1
++.Sh HISTORY
++.Nm
++first appeared in
++.Ox 4.7 .
++.Sh AUTHORS
++.An Markus Friedl Aq Mt markus@openbsd.org
+diff --git a/ssh-pkcs11-helper.8 b/ssh-pkcs11-helper.8
+deleted file mode 100644
+index 3728c4e..0000000
+--- a/ssh-pkcs11-helper.8
++++ /dev/null
+@@ -1,43 +0,0 @@
+-.\" $OpenBSD: ssh-pkcs11-helper.8,v 1.4 2013/07/16 00:07:52 schwarze Exp $
+-.\"
+-.\" Copyright (c) 2010 Markus Friedl.  All rights reserved.
+-.\"
+-.\" Permission to use, copy, modify, and distribute this software for any
+-.\" purpose with or without fee is hereby granted, provided that the above
+-.\" copyright notice and this permission notice appear in all copies.
+-.\"
+-.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+-.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+-.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+-.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+-.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+-.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+-.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+-.\"
+-.Dd $Mdocdate: July 16 2013 $
+-.Dt SSH-PKCS11-HELPER 8
+-.Os
+-.Sh NAME
+-.Nm ssh-pkcs11-helper
+-.Nd ssh-agent helper program for PKCS#11 support
+-.Sh SYNOPSIS
+-.Nm
+-.Sh DESCRIPTION
+-.Nm
+-is used by
+-.Xr ssh-agent 1
+-to access keys provided by a PKCS#11 token.
+-.Pp
+-.Nm
+-is not intended to be invoked by the user, but from
+-.Xr ssh-agent 1 .
+-.Sh SEE ALSO
+-.Xr ssh 1 ,
+-.Xr ssh-add 1 ,
+-.Xr ssh-agent 1
+-.Sh HISTORY
+-.Nm
+-first appeared in
+-.Ox 4.7 .
+-.Sh AUTHORS
+-.An Markus Friedl Aq Mt markus@openbsd.org
+diff --git a/ssh_config.4 b/ssh_config.4
+new file mode 100644
+index 0000000..8c099eb
+--- /dev/null
++++ b/ssh_config.4
+@@ -0,0 +1,1726 @@
++.\"
++.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
++.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
++.\"                    All rights reserved
++.\"
++.\" As far as I am concerned, the code I have written for this software
++.\" can be used freely for any purpose.  Any derived versions of this
++.\" software must be clearly marked as such, and if the derived work is
++.\" incompatible with the protocol description in the RFC file, it must be
++.\" called by a name other than "ssh" or "Secure Shell".
++.\"
++.\" Copyright (c) 1999,2000 Markus Friedl.  All rights reserved.
++.\" Copyright (c) 1999 Aaron Campbell.  All rights reserved.
++.\" Copyright (c) 1999 Theo de Raadt.  All rights reserved.
++.\"
++.\" Redistribution and use in source and binary forms, with or without
++.\" modification, are permitted provided that the following conditions
++.\" are met:
++.\" 1. Redistributions of source code must retain the above copyright
++.\"    notice, this list of conditions and the following disclaimer.
++.\" 2. Redistributions in binary form must reproduce the above copyright
++.\"    notice, this list of conditions and the following disclaimer in the
++.\"    documentation and/or other materials provided with the distribution.
++.\"
++.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
++.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
++.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
++.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
++.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
++.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
++.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++.\"
++.\" $OpenBSD: ssh_config.5,v 1.215 2015/08/14 15:32:41 jmc Exp $
++.Dd $Mdocdate: August 14 2015 $
++.Dt SSH_CONFIG 4
++.Os
++.Sh NAME
++.Nm ssh_config
++.Nd OpenSSH SSH client configuration files
++.Sh SYNOPSIS
++.Nm ~/.ssh/config
++.Nm /etc/ssh/ssh_config
++.Sh DESCRIPTION
++.Xr ssh 1
++obtains configuration data from the following sources in
++the following order:
++.Pp
++.Bl -enum -offset indent -compact
++.It
++command-line options
++.It
++user's configuration file
++.Pq Pa ~/.ssh/config
++.It
++system-wide configuration file
++.Pq Pa /etc/ssh/ssh_config
++.El
++.Pp
++For each parameter, the first obtained value
++will be used.
++The configuration files contain sections separated by
++.Dq Host
++specifications, and that section is only applied for hosts that
++match one of the patterns given in the specification.
++The matched host name is usually the one given on the command line
++(see the
++.Cm CanonicalizeHostname
++option for exceptions.)
++.Pp
++Since the first obtained value for each parameter is used, more
++host-specific declarations should be given near the beginning of the
++file, and general defaults at the end.
++.Pp
++The configuration file has the following format:
++.Pp
++Empty lines and lines starting with
++.Ql #
++are comments.
++Otherwise a line is of the format
++.Dq keyword arguments .
++Configuration options may be separated by whitespace or
++optional whitespace and exactly one
++.Ql = ;
++the latter format is useful to avoid the need to quote whitespace
++when specifying configuration options using the
++.Nm ssh ,
++.Nm scp ,
++and
++.Nm sftp
++.Fl o
++option.
++Arguments may optionally be enclosed in double quotes
++.Pq \&"
++in order to represent arguments containing spaces.
++.Pp
++The possible
++keywords and their meanings are as follows (note that
++keywords are case-insensitive and arguments are case-sensitive):
++.Bl -tag -width Ds
++.It Cm Host
++Restricts the following declarations (up to the next
++.Cm Host
++or
++.Cm Match
++keyword) to be only for those hosts that match one of the patterns
++given after the keyword.
++If more than one pattern is provided, they should be separated by whitespace.
++A single
++.Ql *
++as a pattern can be used to provide global
++defaults for all hosts.
++The host is usually the
++.Ar hostname
++argument given on the command line
++(see the
++.Cm CanonicalizeHostname
++option for exceptions.)
++.Pp
++A pattern entry may be negated by prefixing it with an exclamation mark
++.Pq Sq !\& .
++If a negated entry is matched, then the
++.Cm Host
++entry is ignored, regardless of whether any other patterns on the line
++match.
++Negated matches are therefore useful to provide exceptions for wildcard
++matches.
++.Pp
++See
++.Sx PATTERNS
++for more information on patterns.
++.It Cm Match
++Restricts the following declarations (up to the next
++.Cm Host
++or
++.Cm Match
++keyword) to be used only when the conditions following the
++.Cm Match
++keyword are satisfied.
++Match conditions are specified using one or more critera
++or the single token
++.Cm all
++which always matches.
++The available criteria keywords are:
++.Cm canonical ,
++.Cm exec ,
++.Cm host ,
++.Cm originalhost ,
++.Cm user ,
++and
++.Cm localuser .
++The
++.Cm all
++criteria must appear alone or immediately after
++.Cm canonical .
++Other criteria may be combined arbitrarily.
++All criteria but
++.Cm all
++and
++.Cm canonical
++require an argument.
++Criteria may be negated by prepending an exclamation mark
++.Pq Sq !\& .
++.Pp
++The
++.Cm canonical
++keyword matches only when the configuration file is being re-parsed
++after hostname canonicalization (see the
++.Cm CanonicalizeHostname
++option.)
++This may be useful to specify conditions that work with canonical host
++names only.
++The
++.Cm exec
++keyword executes the specified command under the user's shell.
++If the command returns a zero exit status then the condition is considered true.
++Commands containing whitespace characters must be quoted.
++The following character sequences in the command will be expanded prior to
++execution:
++.Ql %L
++will be substituted by the first component of the local host name,
++.Ql %l
++will be substituted by the local host name (including any domain name),
++.Ql %h
++will be substituted by the target host name,
++.Ql %n
++will be substituted by the original target host name
++specified on the command-line,
++.Ql %p
++the destination port,
++.Ql %r
++by the remote login username, and
++.Ql %u
++by the username of the user running
++.Xr ssh 1 .
++.Pp
++The other keywords' criteria must be single entries or comma-separated
++lists and may use the wildcard and negation operators described in the
++.Sx PATTERNS
++section.
++The criteria for the
++.Cm host
++keyword are matched against the target hostname, after any substitution
++by the
++.Cm Hostname
++or
++.Cm CanonicalizeHostname
++options.
++The
++.Cm originalhost
++keyword matches against the hostname as it was specified on the command-line.
++The
++.Cm user
++keyword matches against the target username on the remote host.
++The
++.Cm localuser
++keyword matches against the name of the local user running
++.Xr ssh 1
++(this keyword may be useful in system-wide
++.Nm
++files).
++.It Cm AddressFamily
++Specifies which address family to use when connecting.
++Valid arguments are
++.Dq any ,
++.Dq inet
++(use IPv4 only), or
++.Dq inet6
++(use IPv6 only).
++.It Cm BatchMode
++If set to
++.Dq yes ,
++passphrase/password querying will be disabled.
++This option is useful in scripts and other batch jobs where no user
++is present to supply the password.
++The argument must be
++.Dq yes
++or
++.Dq no .
++The default is
++.Dq no .
++.It Cm BindAddress
++Use the specified address on the local machine as the source address of
++the connection.
++Only useful on systems with more than one address.
++Note that this option does not work if
++.Cm UsePrivilegedPort
++is set to
++.Dq yes .
++.It Cm CanonicalDomains
++When
++.Cm CanonicalizeHostname
++is enabled, this option specifies the list of domain suffixes in which to
++search for the specified destination host.
++.It Cm CanonicalizeFallbackLocal
++Specifies whether to fail with an error when hostname canonicalization fails.
++The default,
++.Dq yes ,
++will attempt to look up the unqualified hostname using the system resolver's
++search rules.
++A value of
++.Dq no
++will cause
++.Xr ssh 1
++to fail instantly if
++.Cm CanonicalizeHostname
++is enabled and the target hostname cannot be found in any of the domains
++specified by
++.Cm CanonicalDomains .
++.It Cm CanonicalizeHostname
++Controls whether explicit hostname canonicalization is performed.
++The default,
++.Dq no ,
++is not to perform any name rewriting and let the system resolver handle all
++hostname lookups.
++If set to
++.Dq yes
++then, for connections that do not use a
++.Cm ProxyCommand ,
++.Xr ssh 1
++will attempt to canonicalize the hostname specified on the command line
++using the
++.Cm CanonicalDomains
++suffixes and
++.Cm CanonicalizePermittedCNAMEs
++rules.
++If
++.Cm CanonicalizeHostname
++is set to
++.Dq always ,
++then canonicalization is applied to proxied connections too.
++.Pp
++If this option is enabled, then the configuration files are processed
++again using the new target name to pick up any new configuration in matching
++.Cm Host
++and
++.Cm Match
++stanzas.
++.It Cm CanonicalizeMaxDots
++Specifies the maximum number of dot characters in a hostname before
++canonicalization is disabled.
++The default,
++.Dq 1 ,
++allows a single dot (i.e. hostname.subdomain).
++.It Cm CanonicalizePermittedCNAMEs
++Specifies rules to determine whether CNAMEs should be followed when
++canonicalizing hostnames.
++The rules consist of one or more arguments of
++.Ar source_domain_list : Ns Ar target_domain_list ,
++where
++.Ar source_domain_list
++is a pattern-list of domains that may follow CNAMEs in canonicalization,
++and
++.Ar target_domain_list
++is a pattern-list of domains that they may resolve to.
++.Pp
++For example,
++.Dq *.a.example.com:*.b.example.com,*.c.example.com
++will allow hostnames matching
++.Dq *.a.example.com
++to be canonicalized to names in the
++.Dq *.b.example.com
++or
++.Dq *.c.example.com
++domains.
++.It Cm ChallengeResponseAuthentication
++Specifies whether to use challenge-response authentication.
++The argument to this keyword must be
++.Dq yes
++or
++.Dq no .
++The default is
++.Dq yes .
++.It Cm CheckHostIP
++If this flag is set to
++.Dq yes ,
++.Xr ssh 1
++will additionally check the host IP address in the
++.Pa known_hosts
++file.
++This allows ssh to detect if a host key changed due to DNS spoofing
++and will add addresses of destination hosts to
++.Pa ~/.ssh/known_hosts
++in the process, regardless of the setting of
++.Cm StrictHostKeyChecking .
++If the option is set to
++.Dq no ,
++the check will not be executed.
++The default is
++.Dq yes .
++.It Cm Cipher
++Specifies the cipher to use for encrypting the session
++in protocol version 1.
++Currently,
++.Dq blowfish ,
++.Dq 3des ,
++and
++.Dq des
++are supported.
++.Ar des
++is only supported in the
++.Xr ssh 1
++client for interoperability with legacy protocol 1 implementations
++that do not support the
++.Ar 3des
++cipher.
++Its use is strongly discouraged due to cryptographic weaknesses.
++The default is
++.Dq 3des .
++.It Cm Ciphers
++Specifies the ciphers allowed for protocol version 2
++in order of preference.
++Multiple ciphers must be comma-separated.
++If the specified value begins with a
++.Sq +
++character, then the specified ciphers will be appended to the default set
++instead of replacing them.
++.Pp
++The supported ciphers are:
++.Pp
++.Bl -item -compact -offset indent
++.It
++3des-cbc
++.It
++aes128-cbc
++.It
++aes192-cbc
++.It
++aes256-cbc
++.It
++aes128-ctr
++.It
++aes192-ctr
++.It
++aes256-ctr
++.It
++aes128-gcm@openssh.com
++.It
++aes256-gcm@openssh.com
++.It
++arcfour
++.It
++arcfour128
++.It
++arcfour256
++.It
++blowfish-cbc
++.It
++cast128-cbc
++.It
++chacha20-poly1305@openssh.com
++.El
++.Pp
++The default is:
++.Bd -literal -offset indent
++chacha20-poly1305@openssh.com,
++aes128-ctr,aes192-ctr,aes256-ctr,
++aes128-gcm@openssh.com,aes256-gcm@openssh.com,
++arcfour256,arcfour128,
++aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,
++aes192-cbc,aes256-cbc,arcfour
++.Ed
++.Pp
++The list of available ciphers may also be obtained using the
++.Fl Q
++option of
++.Xr ssh 1
++with an argument of
++.Dq cipher .
++.It Cm ClearAllForwardings
++Specifies that all local, remote, and dynamic port forwardings
++specified in the configuration files or on the command line be
++cleared.
++This option is primarily useful when used from the
++.Xr ssh 1
++command line to clear port forwardings set in
++configuration files, and is automatically set by
++.Xr scp 1
++and
++.Xr sftp 1 .
++The argument must be
++.Dq yes
++or
++.Dq no .
++The default is
++.Dq no .
++.It Cm Compression
++Specifies whether to use compression.
++The argument must be
++.Dq yes
++or
++.Dq no .
++The default is
++.Dq no .
++.It Cm CompressionLevel
++Specifies the compression level to use if compression is enabled.
++The argument must be an integer from 1 (fast) to 9 (slow, best).
++The default level is 6, which is good for most applications.
++The meaning of the values is the same as in
++.Xr gzip 1 .
++Note that this option applies to protocol version 1 only.
++.It Cm ConnectionAttempts
++Specifies the number of tries (one per second) to make before exiting.
++The argument must be an integer.
++This may be useful in scripts if the connection sometimes fails.
++The default is 1.
++.It Cm ConnectTimeout
++Specifies the timeout (in seconds) used when connecting to the
++SSH server, instead of using the default system TCP timeout.
++This value is used only when the target is down or really unreachable,
++not when it refuses the connection.
++.It Cm ControlMaster
++Enables the sharing of multiple sessions over a single network connection.
++When set to
++.Dq yes ,
++.Xr ssh 1
++will listen for connections on a control socket specified using the
++.Cm ControlPath
++argument.
++Additional sessions can connect to this socket using the same
++.Cm ControlPath
++with
++.Cm ControlMaster
++set to
++.Dq no
++(the default).
++These sessions will try to reuse the master instance's network connection
++rather than initiating new ones, but will fall back to connecting normally
++if the control socket does not exist, or is not listening.
++.Pp
++Setting this to
++.Dq ask
++will cause ssh
++to listen for control connections, but require confirmation using
++.Xr ssh-askpass 1 .
++If the
++.Cm ControlPath
++cannot be opened,
++ssh will continue without connecting to a master instance.
++.Pp
++X11 and
++.Xr ssh-agent 1
++forwarding is supported over these multiplexed connections, however the
++display and agent forwarded will be the one belonging to the master
++connection i.e. it is not possible to forward multiple displays or agents.
++.Pp
++Two additional options allow for opportunistic multiplexing: try to use a
++master connection but fall back to creating a new one if one does not already
++exist.
++These options are:
++.Dq auto
++and
++.Dq autoask .
++The latter requires confirmation like the
++.Dq ask
++option.
++.It Cm ControlPath
++Specify the path to the control socket used for connection sharing as described
++in the
++.Cm ControlMaster
++section above or the string
++.Dq none
++to disable connection sharing.
++In the path,
++.Ql %L
++will be substituted by the first component of the local host name,
++.Ql %l
++will be substituted by the local host name (including any domain name),
++.Ql %h
++will be substituted by the target host name,
++.Ql %n
++will be substituted by the original target host name
++specified on the command line,
++.Ql %p
++the destination port,
++.Ql %r
++by the remote login username,
++.Ql %u
++by the username of the user running
++.Xr ssh 1 , and
++.Ql \&%C
++by a hash of the concatenation: %l%h%p%r.
++It is recommended that any
++.Cm ControlPath
++used for opportunistic connection sharing include
++at least %h, %p, and %r (or alternatively %C) and be placed in a directory
++that is not writable by other users.
++This ensures that shared connections are uniquely identified.
++.It Cm ControlPersist
++When used in conjunction with
++.Cm ControlMaster ,
++specifies that the master connection should remain open
++in the background (waiting for future client connections)
++after the initial client connection has been closed.
++If set to
++.Dq no ,
++then the master connection will not be placed into the background,
++and will close as soon as the initial client connection is closed.
++If set to
++.Dq yes
++or
++.Dq 0 ,
++then the master connection will remain in the background indefinitely
++(until killed or closed via a mechanism such as the
++.Xr ssh 1
++.Dq Fl O No exit
++option).
++If set to a time in seconds, or a time in any of the formats documented in
++.Xr sshd_config 4 ,
++then the backgrounded master connection will automatically terminate
++after it has remained idle (with no client connections) for the
++specified time.
++.It Cm DynamicForward
++Specifies that a TCP port on the local machine be forwarded
++over the secure channel, and the application
++protocol is then used to determine where to connect to from the
++remote machine.
++.Pp
++The argument must be
++.Sm off
++.Oo Ar bind_address : Oc Ar port .
++.Sm on
++IPv6 addresses can be specified by enclosing addresses in square brackets.
++By default, the local port is bound in accordance with the
++.Cm GatewayPorts
++setting.
++However, an explicit
++.Ar bind_address
++may be used to bind the connection to a specific address.
++The
++.Ar bind_address
++of
++.Dq localhost
++indicates that the listening port be bound for local use only, while an
++empty address or
++.Sq *
++indicates that the port should be available from all interfaces.
++.Pp
++Currently the SOCKS4 and SOCKS5 protocols are supported, and
++.Xr ssh 1
++will act as a SOCKS server.
++Multiple forwardings may be specified, and
++additional forwardings can be given on the command line.
++Only the superuser can forward privileged ports.
++.It Cm EnableSSHKeysign
++Setting this option to
++.Dq yes
++in the global client configuration file
++.Pa /etc/ssh/ssh_config
++enables the use of the helper program
++.Xr ssh-keysign 8
++during
++.Cm HostbasedAuthentication .
++The argument must be
++.Dq yes
++or
++.Dq no .
++The default is
++.Dq no .
++This option should be placed in the non-hostspecific section.
++See
++.Xr ssh-keysign 8
++for more information.
++.It Cm EscapeChar
++Sets the escape character (default:
++.Ql ~ ) .
++The escape character can also
++be set on the command line.
++The argument should be a single character,
++.Ql ^
++followed by a letter, or
++.Dq none
++to disable the escape
++character entirely (making the connection transparent for binary
++data).
++.It Cm ExitOnForwardFailure
++Specifies whether
++.Xr ssh 1
++should terminate the connection if it cannot set up all requested
++dynamic, tunnel, local, and remote port forwardings.
++The argument must be
++.Dq yes
++or
++.Dq no .
++The default is
++.Dq no .
++.It Cm FingerprintHash
++Specifies the hash algorithm used when displaying key fingerprints.
++Valid options are:
++.Dq md5
++and
++.Dq sha256 .
++The default is
++.Dq sha256 .
++.It Cm ForwardAgent
++Specifies whether the connection to the authentication agent (if any)
++will be forwarded to the remote machine.
++The argument must be
++.Dq yes
++or
++.Dq no .
++The default is
++.Dq no .
++.Pp
++Agent forwarding should be enabled with caution.
++Users with the ability to bypass file permissions on the remote host
++(for the agent's Unix-domain socket)
++can access the local agent through the forwarded connection.
++An attacker cannot obtain key material from the agent,
++however they can perform operations on the keys that enable them to
++authenticate using the identities loaded into the agent.
++.It Cm ForwardX11
++Specifies whether X11 connections will be automatically redirected
++over the secure channel and
++.Ev DISPLAY
++set.
++The argument must be
++.Dq yes
++or
++.Dq no .
++The default is
++.Dq no .
++.Pp
++X11 forwarding should be enabled with caution.
++Users with the ability to bypass file permissions on the remote host
++(for the user's X11 authorization database)
++can access the local X11 display through the forwarded connection.
++An attacker may then be able to perform activities such as keystroke monitoring
++if the
++.Cm ForwardX11Trusted
++option is also enabled.
++.It Cm ForwardX11Timeout
++Specify a timeout for untrusted X11 forwarding
++using the format described in the
++TIME FORMATS section of
++.Xr sshd_config 4 .
++X11 connections received by
++.Xr ssh 1
++after this time will be refused.
++The default is to disable untrusted X11 forwarding after twenty minutes has
++elapsed.
++.It Cm ForwardX11Trusted
++If this option is set to
++.Dq yes ,
++remote X11 clients will have full access to the original X11 display.
++.Pp
++If this option is set to
++.Dq no ,
++remote X11 clients will be considered untrusted and prevented
++from stealing or tampering with data belonging to trusted X11
++clients.
++Furthermore, the
++.Xr xauth 1
++token used for the session will be set to expire after 20 minutes.
++Remote clients will be refused access after this time.
++.Pp
++The default is
++.Dq no .
++.Pp
++See the X11 SECURITY extension specification for full details on
++the restrictions imposed on untrusted clients.
++.It Cm GatewayPorts
++Specifies whether remote hosts are allowed to connect to local
++forwarded ports.
++By default,
++.Xr ssh 1
++binds local port forwardings to the loopback address.
++This prevents other remote hosts from connecting to forwarded ports.
++.Cm GatewayPorts
++can be used to specify that ssh
++should bind local port forwardings to the wildcard address,
++thus allowing remote hosts to connect to forwarded ports.
++The argument must be
++.Dq yes
++or
++.Dq no .
++The default is
++.Dq no .
++.It Cm GlobalKnownHostsFile
++Specifies one or more files to use for the global
++host key database, separated by whitespace.
++The default is
++.Pa /etc/ssh/ssh_known_hosts ,
++.Pa /etc/ssh/ssh_known_hosts2 .
++.It Cm GSSAPIAuthentication
++Specifies whether user authentication based on GSSAPI is allowed.
++The default is
++.Dq no .
++Note that this option applies to protocol version 2 only.
++.It Cm GSSAPIDelegateCredentials
++Forward (delegate) credentials to the server.
++The default is
++.Dq no .
++Note that this option applies to protocol version 2 only.
++.It Cm HashKnownHosts
++Indicates that
++.Xr ssh 1
++should hash host names and addresses when they are added to
++.Pa ~/.ssh/known_hosts .
++These hashed names may be used normally by
++.Xr ssh 1
++and
++.Xr sshd 1M ,
++but they do not reveal identifying information should the file's contents
++be disclosed.
++The default is
++.Dq no .
++Note that existing names and addresses in known hosts files
++will not be converted automatically,
++but may be manually hashed using
++.Xr ssh-keygen 1 .
++.It Cm HostbasedAuthentication
++Specifies whether to try rhosts based authentication with public key
++authentication.
++The argument must be
++.Dq yes
++or
++.Dq no .
++The default is
++.Dq no .
++This option applies to protocol version 2 only and
++is similar to
++.Cm RhostsRSAAuthentication .
++.It Cm HostbasedKeyTypes
++Specifies the key types that will be used for hostbased authentication
++as a comma-separated pattern list.
++Alternately if the specified value begins with a
++.Sq +
++character, then the specified key types will be appended to the default set
++instead of replacing them.
++The default for this option is:
++.Bd -literal -offset 3n
++ecdsa-sha2-nistp256-cert-v01@openssh.com,
++ecdsa-sha2-nistp384-cert-v01@openssh.com,
++ecdsa-sha2-nistp521-cert-v01@openssh.com,
++ssh-ed25519-cert-v01@openssh.com,
++ssh-rsa-cert-v01@openssh.com,
++ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
++ssh-ed25519,ssh-rsa
++.Ed
++.Pp
++The
++.Fl Q
++option of
++.Xr ssh 1
++may be used to list supported key types.
++.It Cm HostKeyAlgorithms
++Specifies the protocol version 2 host key algorithms
++that the client wants to use in order of preference.
++Alternately if the specified value begins with a
++.Sq +
++character, then the specified key types will be appended to the default set
++instead of replacing them.
++The default for this option is:
++.Bd -literal -offset 3n
++ecdsa-sha2-nistp256-cert-v01@openssh.com,
++ecdsa-sha2-nistp384-cert-v01@openssh.com,
++ecdsa-sha2-nistp521-cert-v01@openssh.com,
++ssh-ed25519-cert-v01@openssh.com,
++ssh-rsa-cert-v01@openssh.com,
++ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
++ssh-ed25519,ssh-rsa
++.Ed
++.Pp
++If hostkeys are known for the destination host then this default is modified
++to prefer their algorithms.
++.Pp
++The list of available key types may also be obtained using the
++.Fl Q
++option of
++.Xr ssh 1
++with an argument of
++.Dq key .
++.It Cm HostKeyAlias
++Specifies an alias that should be used instead of the
++real host name when looking up or saving the host key
++in the host key database files.
++This option is useful for tunneling SSH connections
++or for multiple servers running on a single host.
++.It Cm HostName
++Specifies the real host name to log into.
++This can be used to specify nicknames or abbreviations for hosts.
++If the hostname contains the character sequence
++.Ql %h ,
++then this will be replaced with the host name specified on the command line
++(this is useful for manipulating unqualified names).
++The character sequence
++.Ql %%
++will be replaced by a single
++.Ql %
++character, which may be used when specifying IPv6 link-local addresses.
++.Pp
++The default is the name given on the command line.
++Numeric IP addresses are also permitted (both on the command line and in
++.Cm HostName
++specifications).
++.It Cm IdentitiesOnly
++Specifies that
++.Xr ssh 1
++should only use the authentication identity files configured in the
++.Nm
++files,
++even if
++.Xr ssh-agent 1
++or a
++.Cm PKCS11Provider
++offers more identities.
++The argument to this keyword must be
++.Dq yes
++or
++.Dq no .
++This option is intended for situations where ssh-agent
++offers many different identities.
++The default is
++.Dq no .
++.It Cm IdentityFile
++Specifies a file from which the user's DSA, ECDSA, Ed25519 or RSA authentication
++identity is read.
++The default is
++.Pa ~/.ssh/identity
++for protocol version 1, and
++.Pa ~/.ssh/id_dsa ,
++.Pa ~/.ssh/id_ecdsa ,
++.Pa ~/.ssh/id_ed25519
++and
++.Pa ~/.ssh/id_rsa
++for protocol version 2.
++Additionally, any identities represented by the authentication agent
++will be used for authentication unless
++.Cm IdentitiesOnly
++is set.
++.Xr ssh 1
++will try to load certificate information from the filename obtained by
++appending
++.Pa -cert.pub
++to the path of a specified
++.Cm IdentityFile .
++.Pp
++The file name may use the tilde
++syntax to refer to a user's home directory or one of the following
++escape characters:
++.Ql %d
++(local user's home directory),
++.Ql %u
++(local user name),
++.Ql %l
++(local host name),
++.Ql %h
++(remote host name) or
++.Ql %r
++(remote user name).
++.Pp
++It is possible to have
++multiple identity files specified in configuration files; all these
++identities will be tried in sequence.
++Multiple
++.Cm IdentityFile
++directives will add to the list of identities tried (this behaviour
++differs from that of other configuration directives).
++.Pp
++.Cm IdentityFile
++may be used in conjunction with
++.Cm IdentitiesOnly
++to select which identities in an agent are offered during authentication.
++.It Cm IgnoreUnknown
++Specifies a pattern-list of unknown options to be ignored if they are
++encountered in configuration parsing.
++This may be used to suppress errors if
++.Nm
++contains options that are unrecognised by
++.Xr ssh 1 .
++It is recommended that
++.Cm IgnoreUnknown
++be listed early in the configuration file as it will not be applied
++to unknown options that appear before it.
++.It Cm IPQoS
++Specifies the IPv4 type-of-service or DSCP class for connections.
++Accepted values are
++.Dq af11 ,
++.Dq af12 ,
++.Dq af13 ,
++.Dq af21 ,
++.Dq af22 ,
++.Dq af23 ,
++.Dq af31 ,
++.Dq af32 ,
++.Dq af33 ,
++.Dq af41 ,
++.Dq af42 ,
++.Dq af43 ,
++.Dq cs0 ,
++.Dq cs1 ,
++.Dq cs2 ,
++.Dq cs3 ,
++.Dq cs4 ,
++.Dq cs5 ,
++.Dq cs6 ,
++.Dq cs7 ,
++.Dq ef ,
++.Dq lowdelay ,
++.Dq throughput ,
++.Dq reliability ,
++or a numeric value.
++This option may take one or two arguments, separated by whitespace.
++If one argument is specified, it is used as the packet class unconditionally.
++If two values are specified, the first is automatically selected for
++interactive sessions and the second for non-interactive sessions.
++The default is
++.Dq lowdelay
++for interactive sessions and
++.Dq throughput
++for non-interactive sessions.
++.It Cm KbdInteractiveAuthentication
++Specifies whether to use keyboard-interactive authentication.
++The argument to this keyword must be
++.Dq yes
++or
++.Dq no .
++The default is
++.Dq yes .
++.It Cm KbdInteractiveDevices
++Specifies the list of methods to use in keyboard-interactive authentication.
++Multiple method names must be comma-separated.
++The default is to use the server specified list.
++The methods available vary depending on what the server supports.
++For an OpenSSH server,
++it may be zero or more of:
++.Dq bsdauth ,
++.Dq pam ,
++and
++.Dq skey .
++.It Cm KexAlgorithms
++Specifies the available KEX (Key Exchange) algorithms.
++Multiple algorithms must be comma-separated.
++Alternately if the specified value begins with a
++.Sq +
++character, then the specified methods will be appended to the default set
++instead of replacing them.
++The default is:
++.Bd -literal -offset indent
++curve25519-sha256@libssh.org,
++ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,
++diffie-hellman-group-exchange-sha256,
++diffie-hellman-group-exchange-sha1,
++diffie-hellman-group14-sha1
++.Ed
++.Pp
++The list of available key exchange algorithms may also be obtained using the
++.Fl Q
++option of
++.Xr ssh 1
++with an argument of
++.Dq kex .
++.It Cm LocalCommand
++Specifies a command to execute on the local machine after successfully
++connecting to the server.
++The command string extends to the end of the line, and is executed with
++the user's shell.
++The following escape character substitutions will be performed:
++.Ql %d
++(local user's home directory),
++.Ql %h
++(remote host name),
++.Ql %l
++(local host name),
++.Ql %n
++(host name as provided on the command line),
++.Ql %p
++(remote port),
++.Ql %r
++(remote user name) or
++.Ql %u
++(local user name) or
++.Ql \&%C
++by a hash of the concatenation: %l%h%p%r.
++.Pp
++The command is run synchronously and does not have access to the
++session of the
++.Xr ssh 1
++that spawned it.
++It should not be used for interactive commands.
++.Pp
++This directive is ignored unless
++.Cm PermitLocalCommand
++has been enabled.
++.It Cm LocalForward
++Specifies that a TCP port on the local machine be forwarded over
++the secure channel to the specified host and port from the remote machine.
++The first argument must be
++.Sm off
++.Oo Ar bind_address : Oc Ar port
++.Sm on
++and the second argument must be
++.Ar host : Ns Ar hostport .
++IPv6 addresses can be specified by enclosing addresses in square brackets.
++Multiple forwardings may be specified, and additional forwardings can be
++given on the command line.
++Only the superuser can forward privileged ports.
++By default, the local port is bound in accordance with the
++.Cm GatewayPorts
++setting.
++However, an explicit
++.Ar bind_address
++may be used to bind the connection to a specific address.
++The
++.Ar bind_address
++of
++.Dq localhost
++indicates that the listening port be bound for local use only, while an
++empty address or
++.Sq *
++indicates that the port should be available from all interfaces.
++.It Cm LogLevel
++Gives the verbosity level that is used when logging messages from
++.Xr ssh 1 .
++The possible values are:
++QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3.
++The default is INFO.
++DEBUG and DEBUG1 are equivalent.
++DEBUG2 and DEBUG3 each specify higher levels of verbose output.
++.It Cm MACs
++Specifies the MAC (message authentication code) algorithms
++in order of preference.
++The MAC algorithm is used in protocol version 2
++for data integrity protection.
++Multiple algorithms must be comma-separated.
++If the specified value begins with a
++.Sq +
++character, then the specified algorithms will be appended to the default set
++instead of replacing them.
++.Pp
++The algorithms that contain
++.Dq -etm
++calculate the MAC after encryption (encrypt-then-mac).
++These are considered safer and their use recommended.
++.Pp
++The default is:
++.Bd -literal -offset indent
++umac-64-etm@openssh.com,umac-128-etm@openssh.com,
++hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,
++umac-64@openssh.com,umac-128@openssh.com,
++hmac-sha2-256,hmac-sha2-512,
++hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,
++hmac-ripemd160-etm@openssh.com,
++hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,
++hmac-md5,hmac-sha1,hmac-ripemd160,
++hmac-sha1-96,hmac-md5-96
++.Ed
++.Pp
++The list of available MAC algorithms may also be obtained using the
++.Fl Q
++option of
++.Xr ssh 1
++with an argument of
++.Dq mac .
++.It Cm NoHostAuthenticationForLocalhost
++This option can be used if the home directory is shared across machines.
++In this case localhost will refer to a different machine on each of
++the machines and the user will get many warnings about changed host keys.
++However, this option disables host authentication for localhost.
++The argument to this keyword must be
++.Dq yes
++or
++.Dq no .
++The default is to check the host key for localhost.
++.It Cm NumberOfPasswordPrompts
++Specifies the number of password prompts before giving up.
++The argument to this keyword must be an integer.
++The default is 3.
++.It Cm PasswordAuthentication
++Specifies whether to use password authentication.
++The argument to this keyword must be
++.Dq yes
++or
++.Dq no .
++The default is
++.Dq yes .
++.It Cm PermitLocalCommand
++Allow local command execution via the
++.Ic LocalCommand
++option or using the
++.Ic !\& Ns Ar command
++escape sequence in
++.Xr ssh 1 .
++The argument must be
++.Dq yes
++or
++.Dq no .
++The default is
++.Dq no .
++.It Cm PKCS11Provider
++Specifies which PKCS#11 provider to use.
++The argument to this keyword is the PKCS#11 shared library
++.Xr ssh 1
++should use to communicate with a PKCS#11 token providing the user's
++private RSA key.
++.It Cm Port
++Specifies the port number to connect on the remote host.
++The default is 22.
++.It Cm PreferredAuthentications
++Specifies the order in which the client should try protocol 2
++authentication methods.
++This allows a client to prefer one method (e.g.\&
++.Cm keyboard-interactive )
++over another method (e.g.\&
++.Cm password ) .
++The default is:
++.Bd -literal -offset indent
++gssapi-with-mic,hostbased,publickey,
++keyboard-interactive,password
++.Ed
++.It Cm Protocol
++Specifies the protocol versions
++.Xr ssh 1
++should support in order of preference.
++The possible values are
++.Sq 1
++and
++.Sq 2 .
++Multiple versions must be comma-separated.
++When this option is set to
++.Dq 2,1
++.Nm ssh
++will try version 2 and fall back to version 1
++if version 2 is not available.
++The default is
++.Sq 2 .
++.It Cm ProxyCommand
++Specifies the command to use to connect to the server.
++The command
++string extends to the end of the line, and is executed
++using the user's shell
++.Ql exec
++directive to avoid a lingering shell process.
++.Pp
++In the command string, any occurrence of
++.Ql %h
++will be substituted by the host name to
++connect,
++.Ql %p
++by the port, and
++.Ql %r
++by the remote user name.
++The command can be basically anything,
++and should read from its standard input and write to its standard output.
++It should eventually connect an
++.Xr sshd 8
++server running on some machine, or execute
++.Ic sshd -i
++somewhere.
++Host key management will be done using the
++HostName of the host being connected (defaulting to the name typed by
++the user).
++Setting the command to
++.Dq none
++disables this option entirely.
++Note that
++.Cm CheckHostIP
++is not available for connects with a proxy command.
++.Pp
++This directive is useful in conjunction with
++.Xr nc 1
++and its proxy support.
++For example, the following directive would connect via an HTTP proxy at
++192.0.2.0:
++.Bd -literal -offset 3n
++ProxyCommand /usr/bin/nc -X connect -x 192.0.2.0:8080 %h %p
++.Ed
++.It Cm ProxyUseFdpass
++Specifies that
++.Cm ProxyCommand
++will pass a connected file descriptor back to
++.Xr ssh 1
++instead of continuing to execute and pass data.
++The default is
++.Dq no .
++.It Cm PubkeyAcceptedKeyTypes
++Specifies the key types that will be used for public key authentication
++as a comma-separated pattern list.
++Alternately if the specified value begins with a
++.Sq +
++character, then the key types after it will be appended to the default
++instead of replacing it.
++The default for this option is:
++.Bd -literal -offset 3n
++ecdsa-sha2-nistp256-cert-v01@openssh.com,
++ecdsa-sha2-nistp384-cert-v01@openssh.com,
++ecdsa-sha2-nistp521-cert-v01@openssh.com,
++ssh-ed25519-cert-v01@openssh.com,
++ssh-rsa-cert-v01@openssh.com,
++ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
++ssh-ed25519,ssh-rsa
++.Ed
++.Pp
++The
++.Fl Q
++option of
++.Xr ssh 1
++may be used to list supported key types.
++.It Cm PubkeyAuthentication
++Specifies whether to try public key authentication.
++The argument to this keyword must be
++.Dq yes
++or
++.Dq no .
++The default is
++.Dq yes .
++This option applies to protocol version 2 only.
++.It Cm RekeyLimit
++Specifies the maximum amount of data that may be transmitted before the
++session key is renegotiated, optionally followed a maximum amount of
++time that may pass before the session key is renegotiated.
++The first argument is specified in bytes and may have a suffix of
++.Sq K ,
++.Sq M ,
++or
++.Sq G
++to indicate Kilobytes, Megabytes, or Gigabytes, respectively.
++The default is between
++.Sq 1G
++and
++.Sq 4G ,
++depending on the cipher.
++The optional second value is specified in seconds and may use any of the
++units documented in the
++TIME FORMATS section of
++.Xr sshd_config 4 .
++The default value for
++.Cm RekeyLimit
++is
++.Dq default none ,
++which means that rekeying is performed after the cipher's default amount
++of data has been sent or received and no time based rekeying is done.
++This option applies to protocol version 2 only.
++.It Cm RemoteForward
++Specifies that a TCP port on the remote machine be forwarded over
++the secure channel to the specified host and port from the local machine.
++The first argument must be
++.Sm off
++.Oo Ar bind_address : Oc Ar port
++.Sm on
++and the second argument must be
++.Ar host : Ns Ar hostport .
++IPv6 addresses can be specified by enclosing addresses in square brackets.
++Multiple forwardings may be specified, and additional
++forwardings can be given on the command line.
++Privileged ports can be forwarded only when
++logging in as root on the remote machine.
++.Pp
++If the
++.Ar port
++argument is
++.Ql 0 ,
++the listen port will be dynamically allocated on the server and reported
++to the client at run time.
++.Pp
++If the
++.Ar bind_address
++is not specified, the default is to only bind to loopback addresses.
++If the
++.Ar bind_address
++is
++.Ql *
++or an empty string, then the forwarding is requested to listen on all
++interfaces.
++Specifying a remote
++.Ar bind_address
++will only succeed if the server's
++.Cm GatewayPorts
++option is enabled (see
++.Xr sshd_config 4 ) .
++.It Cm RequestTTY
++Specifies whether to request a pseudo-tty for the session.
++The argument may be one of:
++.Dq no
++(never request a TTY),
++.Dq yes
++(always request a TTY when standard input is a TTY),
++.Dq force
++(always request a TTY) or
++.Dq auto
++(request a TTY when opening a login session).
++This option mirrors the
++.Fl t
++and
++.Fl T
++flags for
++.Xr ssh 1 .
++.It Cm RevokedHostKeys
++Specifies revoked host public keys.
++Keys listed in this file will be refused for host authentication.
++Note that if this file does not exist or is not readable,
++then host authentication will be refused for all hosts.
++Keys may be specified as a text file, listing one public key per line, or as
++an OpenSSH Key Revocation List (KRL) as generated by
++.Xr ssh-keygen 1 .
++For more information on KRLs, see the KEY REVOCATION LISTS section in
++.Xr ssh-keygen 1 .
++.It Cm RhostsRSAAuthentication
++Specifies whether to try rhosts based authentication with RSA host
++authentication.
++The argument must be
++.Dq yes
++or
++.Dq no .
++The default is
++.Dq no .
++This option applies to protocol version 1 only and requires
++.Xr ssh 1
++to be setuid root.
++.It Cm RSAAuthentication
++Specifies whether to try RSA authentication.
++The argument to this keyword must be
++.Dq yes
++or
++.Dq no .
++RSA authentication will only be
++attempted if the identity file exists, or an authentication agent is
++running.
++The default is
++.Dq yes .
++Note that this option applies to protocol version 1 only.
++.It Cm SendEnv
++Specifies what variables from the local
++.Xr environ 7
++should be sent to the server.
++Note that environment passing is only supported for protocol 2.
++The server must also support it, and the server must be configured to
++accept these environment variables.
++Note that the
++.Ev TERM
++environment variable is always sent whenever a
++pseudo-terminal is requested as it is required by the protocol.
++Refer to
++.Cm AcceptEnv
++in
++.Xr sshd_config 4
++for how to configure the server.
++Variables are specified by name, which may contain wildcard characters.
++Multiple environment variables may be separated by whitespace or spread
++across multiple
++.Cm SendEnv
++directives.
++The default is not to send any environment variables.
++.Pp
++See
++.Sx PATTERNS
++for more information on patterns.
++.It Cm ServerAliveCountMax
++Sets the number of server alive messages (see below) which may be
++sent without
++.Xr ssh 1
++receiving any messages back from the server.
++If this threshold is reached while server alive messages are being sent,
++ssh will disconnect from the server, terminating the session.
++It is important to note that the use of server alive messages is very
++different from
++.Cm TCPKeepAlive
++(below).
++The server alive messages are sent through the encrypted channel
++and therefore will not be spoofable.
++The TCP keepalive option enabled by
++.Cm TCPKeepAlive
++is spoofable.
++The server alive mechanism is valuable when the client or
++server depend on knowing when a connection has become inactive.
++.Pp
++The default value is 3.
++If, for example,
++.Cm ServerAliveInterval
++(see below) is set to 15 and
++.Cm ServerAliveCountMax
++is left at the default, if the server becomes unresponsive,
++ssh will disconnect after approximately 45 seconds.
++This option applies to protocol version 2 only.
++.It Cm ServerAliveInterval
++Sets a timeout interval in seconds after which if no data has been received
++from the server,
++.Xr ssh 1
++will send a message through the encrypted
++channel to request a response from the server.
++The default
++is 0, indicating that these messages will not be sent to the server.
++This option applies to protocol version 2 only.
++.It Cm StreamLocalBindMask
++Sets the octal file creation mode mask
++.Pq umask
++used when creating a Unix-domain socket file for local or remote
++port forwarding.
++This option is only used for port forwarding to a Unix-domain socket file.
++.Pp
++The default value is 0177, which creates a Unix-domain socket file that is
++readable and writable only by the owner.
++Note that not all operating systems honor the file mode on Unix-domain
++socket files.
++.It Cm StreamLocalBindUnlink
++Specifies whether to remove an existing Unix-domain socket file for local
++or remote port forwarding before creating a new one.
++If the socket file already exists and
++.Cm StreamLocalBindUnlink
++is not enabled,
++.Nm ssh
++will be unable to forward the port to the Unix-domain socket file.
++This option is only used for port forwarding to a Unix-domain socket file.
++.Pp
++The argument must be
++.Dq yes
++or
++.Dq no .
++The default is
++.Dq no .
++.It Cm StrictHostKeyChecking
++If this flag is set to
++.Dq yes ,
++.Xr ssh 1
++will never automatically add host keys to the
++.Pa ~/.ssh/known_hosts
++file, and refuses to connect to hosts whose host key has changed.
++This provides maximum protection against trojan horse attacks,
++though it can be annoying when the
++.Pa /etc/ssh/ssh_known_hosts
++file is poorly maintained or when connections to new hosts are
++frequently made.
++This option forces the user to manually
++add all new hosts.
++If this flag is set to
++.Dq no ,
++ssh will automatically add new host keys to the
++user known hosts files.
++If this flag is set to
++.Dq ask ,
++new host keys
++will be added to the user known host files only after the user
++has confirmed that is what they really want to do, and
++ssh will refuse to connect to hosts whose host key has changed.
++The host keys of
++known hosts will be verified automatically in all cases.
++The argument must be
++.Dq yes ,
++.Dq no ,
++or
++.Dq ask .
++The default is
++.Dq ask .
++.It Cm TCPKeepAlive
++Specifies whether the system should send TCP keepalive messages to the
++other side.
++If they are sent, death of the connection or crash of one
++of the machines will be properly noticed.
++However, this means that
++connections will die if the route is down temporarily, and some people
++find it annoying.
++.Pp
++The default is
++.Dq yes
++(to send TCP keepalive messages), and the client will notice
++if the network goes down or the remote host dies.
++This is important in scripts, and many users want it too.
++.Pp
++To disable TCP keepalive messages, the value should be set to
++.Dq no .
++.It Cm Tunnel
++Request
++.Xr tun 4
++device forwarding between the client and the server.
++The argument must be
++.Dq yes ,
++.Dq point-to-point
++(layer 3),
++.Dq ethernet
++(layer 2),
++or
++.Dq no .
++Specifying
++.Dq yes
++requests the default tunnel mode, which is
++.Dq point-to-point .
++The default is
++.Dq no .
++.It Cm TunnelDevice
++Specifies the
++.Xr tun 4
++devices to open on the client
++.Pq Ar local_tun
++and the server
++.Pq Ar remote_tun .
++.Pp
++The argument must be
++.Sm off
++.Ar local_tun Op : Ar remote_tun .
++.Sm on
++The devices may be specified by numerical ID or the keyword
++.Dq any ,
++which uses the next available tunnel device.
++If
++.Ar remote_tun
++is not specified, it defaults to
++.Dq any .
++The default is
++.Dq any:any .
++.It Cm UpdateHostKeys
++Specifies whether
++.Xr ssh 1
++should accept notifications of additional hostkeys from the server sent
++after authentication has completed and add them to
++.Cm UserKnownHostsFile .
++The argument must be
++.Dq yes ,
++.Dq no
++(the default) or
++.Dq ask .
++Enabling this option allows learning alternate hostkeys for a server
++and supports graceful key rotation by allowing a server to send replacement
++public keys before old ones are removed.
++Additional hostkeys are only accepted if the key used to authenticate the
++host was already trusted or explicity accepted by the user.
++If
++.Cm UpdateHostKeys
++is set to
++.Dq ask ,
++then the user is asked to confirm the modifications to the known_hosts file.
++Confirmation is currently incompatible with
++.Cm ControlPersist ,
++and will be disabled if it is enabled.
++.Pp
++Presently, only
++.Xr sshd 8
++from OpenSSH 6.8 and greater support the
++.Dq hostkeys@openssh.com
++protocol extension used to inform the client of all the server's hostkeys.
++.It Cm UsePrivilegedPort
++Specifies whether to use a privileged port for outgoing connections.
++The argument must be
++.Dq yes
++or
++.Dq no .
++The default is
++.Dq no .
++If set to
++.Dq yes ,
++.Xr ssh 1
++must be setuid root.
++Note that this option must be set to
++.Dq yes
++for
++.Cm RhostsRSAAuthentication
++with older servers.
++.It Cm User
++Specifies the user to log in as.
++This can be useful when a different user name is used on different machines.
++This saves the trouble of
++having to remember to give the user name on the command line.
++.It Cm UserKnownHostsFile
++Specifies one or more files to use for the user
++host key database, separated by whitespace.
++The default is
++.Pa ~/.ssh/known_hosts ,
++.Pa ~/.ssh/known_hosts2 .
++.It Cm VerifyHostKeyDNS
++Specifies whether to verify the remote key using DNS and SSHFP resource
++records.
++If this option is set to
++.Dq yes ,
++the client will implicitly trust keys that match a secure fingerprint
++from DNS.
++Insecure fingerprints will be handled as if this option was set to
++.Dq ask .
++If this option is set to
++.Dq ask ,
++information on fingerprint match will be displayed, but the user will still
++need to confirm new host keys according to the
++.Cm StrictHostKeyChecking
++option.
++The argument must be
++.Dq yes ,
++.Dq no ,
++or
++.Dq ask .
++The default is
++.Dq no .
++Note that this option applies to protocol version 2 only.
++.Pp
++See also VERIFYING HOST KEYS in
++.Xr ssh 1 .
++.It Cm VisualHostKey
++If this flag is set to
++.Dq yes ,
++an ASCII art representation of the remote host key fingerprint is
++printed in addition to the fingerprint string at login and
++for unknown host keys.
++If this flag is set to
++.Dq no ,
++no fingerprint strings are printed at login and
++only the fingerprint string will be printed for unknown host keys.
++The default is
++.Dq no .
++.It Cm XAuthLocation
++Specifies the full pathname of the
++.Xr xauth 1
++program.
++The default is
++.Pa /usr/X11R6/bin/xauth .
++.El
++.Sh PATTERNS
++A
++.Em pattern
++consists of zero or more non-whitespace characters,
++.Sq *
++(a wildcard that matches zero or more characters),
++or
++.Sq ?\&
++(a wildcard that matches exactly one character).
++For example, to specify a set of declarations for any host in the
++.Dq .co.uk
++set of domains,
++the following pattern could be used:
++.Pp
++.Dl Host *.co.uk
++.Pp
++The following pattern
++would match any host in the 192.168.0.[0-9] network range:
++.Pp
++.Dl Host 192.168.0.?
++.Pp
++A
++.Em pattern-list
++is a comma-separated list of patterns.
++Patterns within pattern-lists may be negated
++by preceding them with an exclamation mark
++.Pq Sq !\& .
++For example,
++to allow a key to be used from anywhere within an organization
++except from the
++.Dq dialup
++pool,
++the following entry (in authorized_keys) could be used:
++.Pp
++.Dl from=\&"!*.dialup.example.com,*.example.com\&"
++.Sh FILES
++.Bl -tag -width Ds
++.It Pa ~/.ssh/config
++This is the per-user configuration file.
++The format of this file is described above.
++This file is used by the SSH client.
++Because of the potential for abuse, this file must have strict permissions:
++read/write for the user, and not accessible by others.
++.It Pa /etc/ssh/ssh_config
++Systemwide configuration file.
++This file provides defaults for those
++values that are not specified in the user's configuration file, and
++for those users who do not have a configuration file.
++This file must be world-readable.
++.El
++.Sh SEE ALSO
++.Xr ssh 1
++.Sh AUTHORS
++OpenSSH is a derivative of the original and free
++ssh 1.2.12 release by Tatu Ylonen.
++Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
++Theo de Raadt and Dug Song
++removed many bugs, re-added newer features and
++created OpenSSH.
++Markus Friedl contributed the support for SSH
++protocol versions 1.5 and 2.0.
+diff --git a/ssh_config.5 b/ssh_config.5
+deleted file mode 100644
+index a47f3ca..0000000
+--- a/ssh_config.5
++++ /dev/null
+@@ -1,1726 +0,0 @@
+-.\"
+-.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
+-.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
+-.\"                    All rights reserved
+-.\"
+-.\" As far as I am concerned, the code I have written for this software
+-.\" can be used freely for any purpose.  Any derived versions of this
+-.\" software must be clearly marked as such, and if the derived work is
+-.\" incompatible with the protocol description in the RFC file, it must be
+-.\" called by a name other than "ssh" or "Secure Shell".
+-.\"
+-.\" Copyright (c) 1999,2000 Markus Friedl.  All rights reserved.
+-.\" Copyright (c) 1999 Aaron Campbell.  All rights reserved.
+-.\" Copyright (c) 1999 Theo de Raadt.  All rights reserved.
+-.\"
+-.\" Redistribution and use in source and binary forms, with or without
+-.\" modification, are permitted provided that the following conditions
+-.\" are met:
+-.\" 1. Redistributions of source code must retain the above copyright
+-.\"    notice, this list of conditions and the following disclaimer.
+-.\" 2. Redistributions in binary form must reproduce the above copyright
+-.\"    notice, this list of conditions and the following disclaimer in the
+-.\"    documentation and/or other materials provided with the distribution.
+-.\"
+-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+-.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+-.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+-.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+-.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+-.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+-.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+-.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+-.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+-.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-.\"
+-.\" $OpenBSD: ssh_config.5,v 1.215 2015/08/14 15:32:41 jmc Exp $
+-.Dd $Mdocdate: August 14 2015 $
+-.Dt SSH_CONFIG 5
+-.Os
+-.Sh NAME
+-.Nm ssh_config
+-.Nd OpenSSH SSH client configuration files
+-.Sh SYNOPSIS
+-.Nm ~/.ssh/config
+-.Nm /etc/ssh/ssh_config
+-.Sh DESCRIPTION
+-.Xr ssh 1
+-obtains configuration data from the following sources in
+-the following order:
+-.Pp
+-.Bl -enum -offset indent -compact
+-.It
+-command-line options
+-.It
+-user's configuration file
+-.Pq Pa ~/.ssh/config
+-.It
+-system-wide configuration file
+-.Pq Pa /etc/ssh/ssh_config
+-.El
+-.Pp
+-For each parameter, the first obtained value
+-will be used.
+-The configuration files contain sections separated by
+-.Dq Host
+-specifications, and that section is only applied for hosts that
+-match one of the patterns given in the specification.
+-The matched host name is usually the one given on the command line
+-(see the
+-.Cm CanonicalizeHostname
+-option for exceptions.)
+-.Pp
+-Since the first obtained value for each parameter is used, more
+-host-specific declarations should be given near the beginning of the
+-file, and general defaults at the end.
+-.Pp
+-The configuration file has the following format:
+-.Pp
+-Empty lines and lines starting with
+-.Ql #
+-are comments.
+-Otherwise a line is of the format
+-.Dq keyword arguments .
+-Configuration options may be separated by whitespace or
+-optional whitespace and exactly one
+-.Ql = ;
+-the latter format is useful to avoid the need to quote whitespace
+-when specifying configuration options using the
+-.Nm ssh ,
+-.Nm scp ,
+-and
+-.Nm sftp
+-.Fl o
+-option.
+-Arguments may optionally be enclosed in double quotes
+-.Pq \&"
+-in order to represent arguments containing spaces.
+-.Pp
+-The possible
+-keywords and their meanings are as follows (note that
+-keywords are case-insensitive and arguments are case-sensitive):
+-.Bl -tag -width Ds
+-.It Cm Host
+-Restricts the following declarations (up to the next
+-.Cm Host
+-or
+-.Cm Match
+-keyword) to be only for those hosts that match one of the patterns
+-given after the keyword.
+-If more than one pattern is provided, they should be separated by whitespace.
+-A single
+-.Ql *
+-as a pattern can be used to provide global
+-defaults for all hosts.
+-The host is usually the
+-.Ar hostname
+-argument given on the command line
+-(see the
+-.Cm CanonicalizeHostname
+-option for exceptions.)
+-.Pp
+-A pattern entry may be negated by prefixing it with an exclamation mark
+-.Pq Sq !\& .
+-If a negated entry is matched, then the
+-.Cm Host
+-entry is ignored, regardless of whether any other patterns on the line
+-match.
+-Negated matches are therefore useful to provide exceptions for wildcard
+-matches.
+-.Pp
+-See
+-.Sx PATTERNS
+-for more information on patterns.
+-.It Cm Match
+-Restricts the following declarations (up to the next
+-.Cm Host
+-or
+-.Cm Match
+-keyword) to be used only when the conditions following the
+-.Cm Match
+-keyword are satisfied.
+-Match conditions are specified using one or more critera
+-or the single token
+-.Cm all
+-which always matches.
+-The available criteria keywords are:
+-.Cm canonical ,
+-.Cm exec ,
+-.Cm host ,
+-.Cm originalhost ,
+-.Cm user ,
+-and
+-.Cm localuser .
+-The
+-.Cm all
+-criteria must appear alone or immediately after
+-.Cm canonical .
+-Other criteria may be combined arbitrarily.
+-All criteria but
+-.Cm all
+-and
+-.Cm canonical
+-require an argument.
+-Criteria may be negated by prepending an exclamation mark
+-.Pq Sq !\& .
+-.Pp
+-The
+-.Cm canonical
+-keyword matches only when the configuration file is being re-parsed
+-after hostname canonicalization (see the
+-.Cm CanonicalizeHostname
+-option.)
+-This may be useful to specify conditions that work with canonical host
+-names only.
+-The
+-.Cm exec
+-keyword executes the specified command under the user's shell.
+-If the command returns a zero exit status then the condition is considered true.
+-Commands containing whitespace characters must be quoted.
+-The following character sequences in the command will be expanded prior to
+-execution:
+-.Ql %L
+-will be substituted by the first component of the local host name,
+-.Ql %l
+-will be substituted by the local host name (including any domain name),
+-.Ql %h
+-will be substituted by the target host name,
+-.Ql %n
+-will be substituted by the original target host name
+-specified on the command-line,
+-.Ql %p
+-the destination port,
+-.Ql %r
+-by the remote login username, and
+-.Ql %u
+-by the username of the user running
+-.Xr ssh 1 .
+-.Pp
+-The other keywords' criteria must be single entries or comma-separated
+-lists and may use the wildcard and negation operators described in the
+-.Sx PATTERNS
+-section.
+-The criteria for the
+-.Cm host
+-keyword are matched against the target hostname, after any substitution
+-by the
+-.Cm Hostname
+-or
+-.Cm CanonicalizeHostname
+-options.
+-The
+-.Cm originalhost
+-keyword matches against the hostname as it was specified on the command-line.
+-The
+-.Cm user
+-keyword matches against the target username on the remote host.
+-The
+-.Cm localuser
+-keyword matches against the name of the local user running
+-.Xr ssh 1
+-(this keyword may be useful in system-wide
+-.Nm
+-files).
+-.It Cm AddressFamily
+-Specifies which address family to use when connecting.
+-Valid arguments are
+-.Dq any ,
+-.Dq inet
+-(use IPv4 only), or
+-.Dq inet6
+-(use IPv6 only).
+-.It Cm BatchMode
+-If set to
+-.Dq yes ,
+-passphrase/password querying will be disabled.
+-This option is useful in scripts and other batch jobs where no user
+-is present to supply the password.
+-The argument must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is
+-.Dq no .
+-.It Cm BindAddress
+-Use the specified address on the local machine as the source address of
+-the connection.
+-Only useful on systems with more than one address.
+-Note that this option does not work if
+-.Cm UsePrivilegedPort
+-is set to
+-.Dq yes .
+-.It Cm CanonicalDomains
+-When
+-.Cm CanonicalizeHostname
+-is enabled, this option specifies the list of domain suffixes in which to
+-search for the specified destination host.
+-.It Cm CanonicalizeFallbackLocal
+-Specifies whether to fail with an error when hostname canonicalization fails.
+-The default,
+-.Dq yes ,
+-will attempt to look up the unqualified hostname using the system resolver's
+-search rules.
+-A value of
+-.Dq no
+-will cause
+-.Xr ssh 1
+-to fail instantly if
+-.Cm CanonicalizeHostname
+-is enabled and the target hostname cannot be found in any of the domains
+-specified by
+-.Cm CanonicalDomains .
+-.It Cm CanonicalizeHostname
+-Controls whether explicit hostname canonicalization is performed.
+-The default,
+-.Dq no ,
+-is not to perform any name rewriting and let the system resolver handle all
+-hostname lookups.
+-If set to
+-.Dq yes
+-then, for connections that do not use a
+-.Cm ProxyCommand ,
+-.Xr ssh 1
+-will attempt to canonicalize the hostname specified on the command line
+-using the
+-.Cm CanonicalDomains
+-suffixes and
+-.Cm CanonicalizePermittedCNAMEs
+-rules.
+-If
+-.Cm CanonicalizeHostname
+-is set to
+-.Dq always ,
+-then canonicalization is applied to proxied connections too.
+-.Pp
+-If this option is enabled, then the configuration files are processed
+-again using the new target name to pick up any new configuration in matching
+-.Cm Host
+-and
+-.Cm Match
+-stanzas.
+-.It Cm CanonicalizeMaxDots
+-Specifies the maximum number of dot characters in a hostname before
+-canonicalization is disabled.
+-The default,
+-.Dq 1 ,
+-allows a single dot (i.e. hostname.subdomain).
+-.It Cm CanonicalizePermittedCNAMEs
+-Specifies rules to determine whether CNAMEs should be followed when
+-canonicalizing hostnames.
+-The rules consist of one or more arguments of
+-.Ar source_domain_list : Ns Ar target_domain_list ,
+-where
+-.Ar source_domain_list
+-is a pattern-list of domains that may follow CNAMEs in canonicalization,
+-and
+-.Ar target_domain_list
+-is a pattern-list of domains that they may resolve to.
+-.Pp
+-For example,
+-.Dq *.a.example.com:*.b.example.com,*.c.example.com
+-will allow hostnames matching
+-.Dq *.a.example.com
+-to be canonicalized to names in the
+-.Dq *.b.example.com
+-or
+-.Dq *.c.example.com
+-domains.
+-.It Cm ChallengeResponseAuthentication
+-Specifies whether to use challenge-response authentication.
+-The argument to this keyword must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is
+-.Dq yes .
+-.It Cm CheckHostIP
+-If this flag is set to
+-.Dq yes ,
+-.Xr ssh 1
+-will additionally check the host IP address in the
+-.Pa known_hosts
+-file.
+-This allows ssh to detect if a host key changed due to DNS spoofing
+-and will add addresses of destination hosts to
+-.Pa ~/.ssh/known_hosts
+-in the process, regardless of the setting of
+-.Cm StrictHostKeyChecking .
+-If the option is set to
+-.Dq no ,
+-the check will not be executed.
+-The default is
+-.Dq yes .
+-.It Cm Cipher
+-Specifies the cipher to use for encrypting the session
+-in protocol version 1.
+-Currently,
+-.Dq blowfish ,
+-.Dq 3des ,
+-and
+-.Dq des
+-are supported.
+-.Ar des
+-is only supported in the
+-.Xr ssh 1
+-client for interoperability with legacy protocol 1 implementations
+-that do not support the
+-.Ar 3des
+-cipher.
+-Its use is strongly discouraged due to cryptographic weaknesses.
+-The default is
+-.Dq 3des .
+-.It Cm Ciphers
+-Specifies the ciphers allowed for protocol version 2
+-in order of preference.
+-Multiple ciphers must be comma-separated.
+-If the specified value begins with a
+-.Sq +
+-character, then the specified ciphers will be appended to the default set
+-instead of replacing them.
+-.Pp
+-The supported ciphers are:
+-.Pp
+-.Bl -item -compact -offset indent
+-.It
+-3des-cbc
+-.It
+-aes128-cbc
+-.It
+-aes192-cbc
+-.It
+-aes256-cbc
+-.It
+-aes128-ctr
+-.It
+-aes192-ctr
+-.It
+-aes256-ctr
+-.It
+-aes128-gcm@openssh.com
+-.It
+-aes256-gcm@openssh.com
+-.It
+-arcfour
+-.It
+-arcfour128
+-.It
+-arcfour256
+-.It
+-blowfish-cbc
+-.It
+-cast128-cbc
+-.It
+-chacha20-poly1305@openssh.com
+-.El
+-.Pp
+-The default is:
+-.Bd -literal -offset indent
+-chacha20-poly1305@openssh.com,
+-aes128-ctr,aes192-ctr,aes256-ctr,
+-aes128-gcm@openssh.com,aes256-gcm@openssh.com,
+-arcfour256,arcfour128,
+-aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,
+-aes192-cbc,aes256-cbc,arcfour
+-.Ed
+-.Pp
+-The list of available ciphers may also be obtained using the
+-.Fl Q
+-option of
+-.Xr ssh 1
+-with an argument of
+-.Dq cipher .
+-.It Cm ClearAllForwardings
+-Specifies that all local, remote, and dynamic port forwardings
+-specified in the configuration files or on the command line be
+-cleared.
+-This option is primarily useful when used from the
+-.Xr ssh 1
+-command line to clear port forwardings set in
+-configuration files, and is automatically set by
+-.Xr scp 1
+-and
+-.Xr sftp 1 .
+-The argument must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is
+-.Dq no .
+-.It Cm Compression
+-Specifies whether to use compression.
+-The argument must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is
+-.Dq no .
+-.It Cm CompressionLevel
+-Specifies the compression level to use if compression is enabled.
+-The argument must be an integer from 1 (fast) to 9 (slow, best).
+-The default level is 6, which is good for most applications.
+-The meaning of the values is the same as in
+-.Xr gzip 1 .
+-Note that this option applies to protocol version 1 only.
+-.It Cm ConnectionAttempts
+-Specifies the number of tries (one per second) to make before exiting.
+-The argument must be an integer.
+-This may be useful in scripts if the connection sometimes fails.
+-The default is 1.
+-.It Cm ConnectTimeout
+-Specifies the timeout (in seconds) used when connecting to the
+-SSH server, instead of using the default system TCP timeout.
+-This value is used only when the target is down or really unreachable,
+-not when it refuses the connection.
+-.It Cm ControlMaster
+-Enables the sharing of multiple sessions over a single network connection.
+-When set to
+-.Dq yes ,
+-.Xr ssh 1
+-will listen for connections on a control socket specified using the
+-.Cm ControlPath
+-argument.
+-Additional sessions can connect to this socket using the same
+-.Cm ControlPath
+-with
+-.Cm ControlMaster
+-set to
+-.Dq no
+-(the default).
+-These sessions will try to reuse the master instance's network connection
+-rather than initiating new ones, but will fall back to connecting normally
+-if the control socket does not exist, or is not listening.
+-.Pp
+-Setting this to
+-.Dq ask
+-will cause ssh
+-to listen for control connections, but require confirmation using
+-.Xr ssh-askpass 1 .
+-If the
+-.Cm ControlPath
+-cannot be opened,
+-ssh will continue without connecting to a master instance.
+-.Pp
+-X11 and
+-.Xr ssh-agent 1
+-forwarding is supported over these multiplexed connections, however the
+-display and agent forwarded will be the one belonging to the master
+-connection i.e. it is not possible to forward multiple displays or agents.
+-.Pp
+-Two additional options allow for opportunistic multiplexing: try to use a
+-master connection but fall back to creating a new one if one does not already
+-exist.
+-These options are:
+-.Dq auto
+-and
+-.Dq autoask .
+-The latter requires confirmation like the
+-.Dq ask
+-option.
+-.It Cm ControlPath
+-Specify the path to the control socket used for connection sharing as described
+-in the
+-.Cm ControlMaster
+-section above or the string
+-.Dq none
+-to disable connection sharing.
+-In the path,
+-.Ql %L
+-will be substituted by the first component of the local host name,
+-.Ql %l
+-will be substituted by the local host name (including any domain name),
+-.Ql %h
+-will be substituted by the target host name,
+-.Ql %n
+-will be substituted by the original target host name
+-specified on the command line,
+-.Ql %p
+-the destination port,
+-.Ql %r
+-by the remote login username,
+-.Ql %u
+-by the username of the user running
+-.Xr ssh 1 , and
+-.Ql \&%C
+-by a hash of the concatenation: %l%h%p%r.
+-It is recommended that any
+-.Cm ControlPath
+-used for opportunistic connection sharing include
+-at least %h, %p, and %r (or alternatively %C) and be placed in a directory
+-that is not writable by other users.
+-This ensures that shared connections are uniquely identified.
+-.It Cm ControlPersist
+-When used in conjunction with
+-.Cm ControlMaster ,
+-specifies that the master connection should remain open
+-in the background (waiting for future client connections)
+-after the initial client connection has been closed.
+-If set to
+-.Dq no ,
+-then the master connection will not be placed into the background,
+-and will close as soon as the initial client connection is closed.
+-If set to
+-.Dq yes
+-or
+-.Dq 0 ,
+-then the master connection will remain in the background indefinitely
+-(until killed or closed via a mechanism such as the
+-.Xr ssh 1
+-.Dq Fl O No exit
+-option).
+-If set to a time in seconds, or a time in any of the formats documented in
+-.Xr sshd_config 5 ,
+-then the backgrounded master connection will automatically terminate
+-after it has remained idle (with no client connections) for the
+-specified time.
+-.It Cm DynamicForward
+-Specifies that a TCP port on the local machine be forwarded
+-over the secure channel, and the application
+-protocol is then used to determine where to connect to from the
+-remote machine.
+-.Pp
+-The argument must be
+-.Sm off
+-.Oo Ar bind_address : Oc Ar port .
+-.Sm on
+-IPv6 addresses can be specified by enclosing addresses in square brackets.
+-By default, the local port is bound in accordance with the
+-.Cm GatewayPorts
+-setting.
+-However, an explicit
+-.Ar bind_address
+-may be used to bind the connection to a specific address.
+-The
+-.Ar bind_address
+-of
+-.Dq localhost
+-indicates that the listening port be bound for local use only, while an
+-empty address or
+-.Sq *
+-indicates that the port should be available from all interfaces.
+-.Pp
+-Currently the SOCKS4 and SOCKS5 protocols are supported, and
+-.Xr ssh 1
+-will act as a SOCKS server.
+-Multiple forwardings may be specified, and
+-additional forwardings can be given on the command line.
+-Only the superuser can forward privileged ports.
+-.It Cm EnableSSHKeysign
+-Setting this option to
+-.Dq yes
+-in the global client configuration file
+-.Pa /etc/ssh/ssh_config
+-enables the use of the helper program
+-.Xr ssh-keysign 8
+-during
+-.Cm HostbasedAuthentication .
+-The argument must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is
+-.Dq no .
+-This option should be placed in the non-hostspecific section.
+-See
+-.Xr ssh-keysign 8
+-for more information.
+-.It Cm EscapeChar
+-Sets the escape character (default:
+-.Ql ~ ) .
+-The escape character can also
+-be set on the command line.
+-The argument should be a single character,
+-.Ql ^
+-followed by a letter, or
+-.Dq none
+-to disable the escape
+-character entirely (making the connection transparent for binary
+-data).
+-.It Cm ExitOnForwardFailure
+-Specifies whether
+-.Xr ssh 1
+-should terminate the connection if it cannot set up all requested
+-dynamic, tunnel, local, and remote port forwardings.
+-The argument must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is
+-.Dq no .
+-.It Cm FingerprintHash
+-Specifies the hash algorithm used when displaying key fingerprints.
+-Valid options are:
+-.Dq md5
+-and
+-.Dq sha256 .
+-The default is
+-.Dq sha256 .
+-.It Cm ForwardAgent
+-Specifies whether the connection to the authentication agent (if any)
+-will be forwarded to the remote machine.
+-The argument must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is
+-.Dq no .
+-.Pp
+-Agent forwarding should be enabled with caution.
+-Users with the ability to bypass file permissions on the remote host
+-(for the agent's Unix-domain socket)
+-can access the local agent through the forwarded connection.
+-An attacker cannot obtain key material from the agent,
+-however they can perform operations on the keys that enable them to
+-authenticate using the identities loaded into the agent.
+-.It Cm ForwardX11
+-Specifies whether X11 connections will be automatically redirected
+-over the secure channel and
+-.Ev DISPLAY
+-set.
+-The argument must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is
+-.Dq no .
+-.Pp
+-X11 forwarding should be enabled with caution.
+-Users with the ability to bypass file permissions on the remote host
+-(for the user's X11 authorization database)
+-can access the local X11 display through the forwarded connection.
+-An attacker may then be able to perform activities such as keystroke monitoring
+-if the
+-.Cm ForwardX11Trusted
+-option is also enabled.
+-.It Cm ForwardX11Timeout
+-Specify a timeout for untrusted X11 forwarding
+-using the format described in the
+-TIME FORMATS section of
+-.Xr sshd_config 5 .
+-X11 connections received by
+-.Xr ssh 1
+-after this time will be refused.
+-The default is to disable untrusted X11 forwarding after twenty minutes has
+-elapsed.
+-.It Cm ForwardX11Trusted
+-If this option is set to
+-.Dq yes ,
+-remote X11 clients will have full access to the original X11 display.
+-.Pp
+-If this option is set to
+-.Dq no ,
+-remote X11 clients will be considered untrusted and prevented
+-from stealing or tampering with data belonging to trusted X11
+-clients.
+-Furthermore, the
+-.Xr xauth 1
+-token used for the session will be set to expire after 20 minutes.
+-Remote clients will be refused access after this time.
+-.Pp
+-The default is
+-.Dq no .
+-.Pp
+-See the X11 SECURITY extension specification for full details on
+-the restrictions imposed on untrusted clients.
+-.It Cm GatewayPorts
+-Specifies whether remote hosts are allowed to connect to local
+-forwarded ports.
+-By default,
+-.Xr ssh 1
+-binds local port forwardings to the loopback address.
+-This prevents other remote hosts from connecting to forwarded ports.
+-.Cm GatewayPorts
+-can be used to specify that ssh
+-should bind local port forwardings to the wildcard address,
+-thus allowing remote hosts to connect to forwarded ports.
+-The argument must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is
+-.Dq no .
+-.It Cm GlobalKnownHostsFile
+-Specifies one or more files to use for the global
+-host key database, separated by whitespace.
+-The default is
+-.Pa /etc/ssh/ssh_known_hosts ,
+-.Pa /etc/ssh/ssh_known_hosts2 .
+-.It Cm GSSAPIAuthentication
+-Specifies whether user authentication based on GSSAPI is allowed.
+-The default is
+-.Dq no .
+-Note that this option applies to protocol version 2 only.
+-.It Cm GSSAPIDelegateCredentials
+-Forward (delegate) credentials to the server.
+-The default is
+-.Dq no .
+-Note that this option applies to protocol version 2 only.
+-.It Cm HashKnownHosts
+-Indicates that
+-.Xr ssh 1
+-should hash host names and addresses when they are added to
+-.Pa ~/.ssh/known_hosts .
+-These hashed names may be used normally by
+-.Xr ssh 1
+-and
+-.Xr sshd 8 ,
+-but they do not reveal identifying information should the file's contents
+-be disclosed.
+-The default is
+-.Dq no .
+-Note that existing names and addresses in known hosts files
+-will not be converted automatically,
+-but may be manually hashed using
+-.Xr ssh-keygen 1 .
+-.It Cm HostbasedAuthentication
+-Specifies whether to try rhosts based authentication with public key
+-authentication.
+-The argument must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is
+-.Dq no .
+-This option applies to protocol version 2 only and
+-is similar to
+-.Cm RhostsRSAAuthentication .
+-.It Cm HostbasedKeyTypes
+-Specifies the key types that will be used for hostbased authentication
+-as a comma-separated pattern list.
+-Alternately if the specified value begins with a
+-.Sq +
+-character, then the specified key types will be appended to the default set
+-instead of replacing them.
+-The default for this option is:
+-.Bd -literal -offset 3n
+-ecdsa-sha2-nistp256-cert-v01@openssh.com,
+-ecdsa-sha2-nistp384-cert-v01@openssh.com,
+-ecdsa-sha2-nistp521-cert-v01@openssh.com,
+-ssh-ed25519-cert-v01@openssh.com,
+-ssh-rsa-cert-v01@openssh.com,
+-ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
+-ssh-ed25519,ssh-rsa
+-.Ed
+-.Pp
+-The
+-.Fl Q
+-option of
+-.Xr ssh 1
+-may be used to list supported key types.
+-.It Cm HostKeyAlgorithms
+-Specifies the protocol version 2 host key algorithms
+-that the client wants to use in order of preference.
+-Alternately if the specified value begins with a
+-.Sq +
+-character, then the specified key types will be appended to the default set
+-instead of replacing them.
+-The default for this option is:
+-.Bd -literal -offset 3n
+-ecdsa-sha2-nistp256-cert-v01@openssh.com,
+-ecdsa-sha2-nistp384-cert-v01@openssh.com,
+-ecdsa-sha2-nistp521-cert-v01@openssh.com,
+-ssh-ed25519-cert-v01@openssh.com,
+-ssh-rsa-cert-v01@openssh.com,
+-ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
+-ssh-ed25519,ssh-rsa
+-.Ed
+-.Pp
+-If hostkeys are known for the destination host then this default is modified
+-to prefer their algorithms.
+-.Pp
+-The list of available key types may also be obtained using the
+-.Fl Q
+-option of
+-.Xr ssh 1
+-with an argument of
+-.Dq key .
+-.It Cm HostKeyAlias
+-Specifies an alias that should be used instead of the
+-real host name when looking up or saving the host key
+-in the host key database files.
+-This option is useful for tunneling SSH connections
+-or for multiple servers running on a single host.
+-.It Cm HostName
+-Specifies the real host name to log into.
+-This can be used to specify nicknames or abbreviations for hosts.
+-If the hostname contains the character sequence
+-.Ql %h ,
+-then this will be replaced with the host name specified on the command line
+-(this is useful for manipulating unqualified names).
+-The character sequence
+-.Ql %%
+-will be replaced by a single
+-.Ql %
+-character, which may be used when specifying IPv6 link-local addresses.
+-.Pp
+-The default is the name given on the command line.
+-Numeric IP addresses are also permitted (both on the command line and in
+-.Cm HostName
+-specifications).
+-.It Cm IdentitiesOnly
+-Specifies that
+-.Xr ssh 1
+-should only use the authentication identity files configured in the
+-.Nm
+-files,
+-even if
+-.Xr ssh-agent 1
+-or a
+-.Cm PKCS11Provider
+-offers more identities.
+-The argument to this keyword must be
+-.Dq yes
+-or
+-.Dq no .
+-This option is intended for situations where ssh-agent
+-offers many different identities.
+-The default is
+-.Dq no .
+-.It Cm IdentityFile
+-Specifies a file from which the user's DSA, ECDSA, Ed25519 or RSA authentication
+-identity is read.
+-The default is
+-.Pa ~/.ssh/identity
+-for protocol version 1, and
+-.Pa ~/.ssh/id_dsa ,
+-.Pa ~/.ssh/id_ecdsa ,
+-.Pa ~/.ssh/id_ed25519
+-and
+-.Pa ~/.ssh/id_rsa
+-for protocol version 2.
+-Additionally, any identities represented by the authentication agent
+-will be used for authentication unless
+-.Cm IdentitiesOnly
+-is set.
+-.Xr ssh 1
+-will try to load certificate information from the filename obtained by
+-appending
+-.Pa -cert.pub
+-to the path of a specified
+-.Cm IdentityFile .
+-.Pp
+-The file name may use the tilde
+-syntax to refer to a user's home directory or one of the following
+-escape characters:
+-.Ql %d
+-(local user's home directory),
+-.Ql %u
+-(local user name),
+-.Ql %l
+-(local host name),
+-.Ql %h
+-(remote host name) or
+-.Ql %r
+-(remote user name).
+-.Pp
+-It is possible to have
+-multiple identity files specified in configuration files; all these
+-identities will be tried in sequence.
+-Multiple
+-.Cm IdentityFile
+-directives will add to the list of identities tried (this behaviour
+-differs from that of other configuration directives).
+-.Pp
+-.Cm IdentityFile
+-may be used in conjunction with
+-.Cm IdentitiesOnly
+-to select which identities in an agent are offered during authentication.
+-.It Cm IgnoreUnknown
+-Specifies a pattern-list of unknown options to be ignored if they are
+-encountered in configuration parsing.
+-This may be used to suppress errors if
+-.Nm
+-contains options that are unrecognised by
+-.Xr ssh 1 .
+-It is recommended that
+-.Cm IgnoreUnknown
+-be listed early in the configuration file as it will not be applied
+-to unknown options that appear before it.
+-.It Cm IPQoS
+-Specifies the IPv4 type-of-service or DSCP class for connections.
+-Accepted values are
+-.Dq af11 ,
+-.Dq af12 ,
+-.Dq af13 ,
+-.Dq af21 ,
+-.Dq af22 ,
+-.Dq af23 ,
+-.Dq af31 ,
+-.Dq af32 ,
+-.Dq af33 ,
+-.Dq af41 ,
+-.Dq af42 ,
+-.Dq af43 ,
+-.Dq cs0 ,
+-.Dq cs1 ,
+-.Dq cs2 ,
+-.Dq cs3 ,
+-.Dq cs4 ,
+-.Dq cs5 ,
+-.Dq cs6 ,
+-.Dq cs7 ,
+-.Dq ef ,
+-.Dq lowdelay ,
+-.Dq throughput ,
+-.Dq reliability ,
+-or a numeric value.
+-This option may take one or two arguments, separated by whitespace.
+-If one argument is specified, it is used as the packet class unconditionally.
+-If two values are specified, the first is automatically selected for
+-interactive sessions and the second for non-interactive sessions.
+-The default is
+-.Dq lowdelay
+-for interactive sessions and
+-.Dq throughput
+-for non-interactive sessions.
+-.It Cm KbdInteractiveAuthentication
+-Specifies whether to use keyboard-interactive authentication.
+-The argument to this keyword must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is
+-.Dq yes .
+-.It Cm KbdInteractiveDevices
+-Specifies the list of methods to use in keyboard-interactive authentication.
+-Multiple method names must be comma-separated.
+-The default is to use the server specified list.
+-The methods available vary depending on what the server supports.
+-For an OpenSSH server,
+-it may be zero or more of:
+-.Dq bsdauth ,
+-.Dq pam ,
+-and
+-.Dq skey .
+-.It Cm KexAlgorithms
+-Specifies the available KEX (Key Exchange) algorithms.
+-Multiple algorithms must be comma-separated.
+-Alternately if the specified value begins with a
+-.Sq +
+-character, then the specified methods will be appended to the default set
+-instead of replacing them.
+-The default is:
+-.Bd -literal -offset indent
+-curve25519-sha256@libssh.org,
+-ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,
+-diffie-hellman-group-exchange-sha256,
+-diffie-hellman-group-exchange-sha1,
+-diffie-hellman-group14-sha1
+-.Ed
+-.Pp
+-The list of available key exchange algorithms may also be obtained using the
+-.Fl Q
+-option of
+-.Xr ssh 1
+-with an argument of
+-.Dq kex .
+-.It Cm LocalCommand
+-Specifies a command to execute on the local machine after successfully
+-connecting to the server.
+-The command string extends to the end of the line, and is executed with
+-the user's shell.
+-The following escape character substitutions will be performed:
+-.Ql %d
+-(local user's home directory),
+-.Ql %h
+-(remote host name),
+-.Ql %l
+-(local host name),
+-.Ql %n
+-(host name as provided on the command line),
+-.Ql %p
+-(remote port),
+-.Ql %r
+-(remote user name) or
+-.Ql %u
+-(local user name) or
+-.Ql \&%C
+-by a hash of the concatenation: %l%h%p%r.
+-.Pp
+-The command is run synchronously and does not have access to the
+-session of the
+-.Xr ssh 1
+-that spawned it.
+-It should not be used for interactive commands.
+-.Pp
+-This directive is ignored unless
+-.Cm PermitLocalCommand
+-has been enabled.
+-.It Cm LocalForward
+-Specifies that a TCP port on the local machine be forwarded over
+-the secure channel to the specified host and port from the remote machine.
+-The first argument must be
+-.Sm off
+-.Oo Ar bind_address : Oc Ar port
+-.Sm on
+-and the second argument must be
+-.Ar host : Ns Ar hostport .
+-IPv6 addresses can be specified by enclosing addresses in square brackets.
+-Multiple forwardings may be specified, and additional forwardings can be
+-given on the command line.
+-Only the superuser can forward privileged ports.
+-By default, the local port is bound in accordance with the
+-.Cm GatewayPorts
+-setting.
+-However, an explicit
+-.Ar bind_address
+-may be used to bind the connection to a specific address.
+-The
+-.Ar bind_address
+-of
+-.Dq localhost
+-indicates that the listening port be bound for local use only, while an
+-empty address or
+-.Sq *
+-indicates that the port should be available from all interfaces.
+-.It Cm LogLevel
+-Gives the verbosity level that is used when logging messages from
+-.Xr ssh 1 .
+-The possible values are:
+-QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3.
+-The default is INFO.
+-DEBUG and DEBUG1 are equivalent.
+-DEBUG2 and DEBUG3 each specify higher levels of verbose output.
+-.It Cm MACs
+-Specifies the MAC (message authentication code) algorithms
+-in order of preference.
+-The MAC algorithm is used in protocol version 2
+-for data integrity protection.
+-Multiple algorithms must be comma-separated.
+-If the specified value begins with a
+-.Sq +
+-character, then the specified algorithms will be appended to the default set
+-instead of replacing them.
+-.Pp
+-The algorithms that contain
+-.Dq -etm
+-calculate the MAC after encryption (encrypt-then-mac).
+-These are considered safer and their use recommended.
+-.Pp
+-The default is:
+-.Bd -literal -offset indent
+-umac-64-etm@openssh.com,umac-128-etm@openssh.com,
+-hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,
+-umac-64@openssh.com,umac-128@openssh.com,
+-hmac-sha2-256,hmac-sha2-512,
+-hmac-md5-etm@openssh.com,hmac-sha1-etm@openssh.com,
+-hmac-ripemd160-etm@openssh.com,
+-hmac-sha1-96-etm@openssh.com,hmac-md5-96-etm@openssh.com,
+-hmac-md5,hmac-sha1,hmac-ripemd160,
+-hmac-sha1-96,hmac-md5-96
+-.Ed
+-.Pp
+-The list of available MAC algorithms may also be obtained using the
+-.Fl Q
+-option of
+-.Xr ssh 1
+-with an argument of
+-.Dq mac .
+-.It Cm NoHostAuthenticationForLocalhost
+-This option can be used if the home directory is shared across machines.
+-In this case localhost will refer to a different machine on each of
+-the machines and the user will get many warnings about changed host keys.
+-However, this option disables host authentication for localhost.
+-The argument to this keyword must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is to check the host key for localhost.
+-.It Cm NumberOfPasswordPrompts
+-Specifies the number of password prompts before giving up.
+-The argument to this keyword must be an integer.
+-The default is 3.
+-.It Cm PasswordAuthentication
+-Specifies whether to use password authentication.
+-The argument to this keyword must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is
+-.Dq yes .
+-.It Cm PermitLocalCommand
+-Allow local command execution via the
+-.Ic LocalCommand
+-option or using the
+-.Ic !\& Ns Ar command
+-escape sequence in
+-.Xr ssh 1 .
+-The argument must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is
+-.Dq no .
+-.It Cm PKCS11Provider
+-Specifies which PKCS#11 provider to use.
+-The argument to this keyword is the PKCS#11 shared library
+-.Xr ssh 1
+-should use to communicate with a PKCS#11 token providing the user's
+-private RSA key.
+-.It Cm Port
+-Specifies the port number to connect on the remote host.
+-The default is 22.
+-.It Cm PreferredAuthentications
+-Specifies the order in which the client should try protocol 2
+-authentication methods.
+-This allows a client to prefer one method (e.g.\&
+-.Cm keyboard-interactive )
+-over another method (e.g.\&
+-.Cm password ) .
+-The default is:
+-.Bd -literal -offset indent
+-gssapi-with-mic,hostbased,publickey,
+-keyboard-interactive,password
+-.Ed
+-.It Cm Protocol
+-Specifies the protocol versions
+-.Xr ssh 1
+-should support in order of preference.
+-The possible values are
+-.Sq 1
+-and
+-.Sq 2 .
+-Multiple versions must be comma-separated.
+-When this option is set to
+-.Dq 2,1
+-.Nm ssh
+-will try version 2 and fall back to version 1
+-if version 2 is not available.
+-The default is
+-.Sq 2 .
+-.It Cm ProxyCommand
+-Specifies the command to use to connect to the server.
+-The command
+-string extends to the end of the line, and is executed
+-using the user's shell
+-.Ql exec
+-directive to avoid a lingering shell process.
+-.Pp
+-In the command string, any occurrence of
+-.Ql %h
+-will be substituted by the host name to
+-connect,
+-.Ql %p
+-by the port, and
+-.Ql %r
+-by the remote user name.
+-The command can be basically anything,
+-and should read from its standard input and write to its standard output.
+-It should eventually connect an
+-.Xr sshd 8
+-server running on some machine, or execute
+-.Ic sshd -i
+-somewhere.
+-Host key management will be done using the
+-HostName of the host being connected (defaulting to the name typed by
+-the user).
+-Setting the command to
+-.Dq none
+-disables this option entirely.
+-Note that
+-.Cm CheckHostIP
+-is not available for connects with a proxy command.
+-.Pp
+-This directive is useful in conjunction with
+-.Xr nc 1
+-and its proxy support.
+-For example, the following directive would connect via an HTTP proxy at
+-192.0.2.0:
+-.Bd -literal -offset 3n
+-ProxyCommand /usr/bin/nc -X connect -x 192.0.2.0:8080 %h %p
+-.Ed
+-.It Cm ProxyUseFdpass
+-Specifies that
+-.Cm ProxyCommand
+-will pass a connected file descriptor back to
+-.Xr ssh 1
+-instead of continuing to execute and pass data.
+-The default is
+-.Dq no .
+-.It Cm PubkeyAcceptedKeyTypes
+-Specifies the key types that will be used for public key authentication
+-as a comma-separated pattern list.
+-Alternately if the specified value begins with a
+-.Sq +
+-character, then the key types after it will be appended to the default
+-instead of replacing it.
+-The default for this option is:
+-.Bd -literal -offset 3n
+-ecdsa-sha2-nistp256-cert-v01@openssh.com,
+-ecdsa-sha2-nistp384-cert-v01@openssh.com,
+-ecdsa-sha2-nistp521-cert-v01@openssh.com,
+-ssh-ed25519-cert-v01@openssh.com,
+-ssh-rsa-cert-v01@openssh.com,
+-ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
+-ssh-ed25519,ssh-rsa
+-.Ed
+-.Pp
+-The
+-.Fl Q
+-option of
+-.Xr ssh 1
+-may be used to list supported key types.
+-.It Cm PubkeyAuthentication
+-Specifies whether to try public key authentication.
+-The argument to this keyword must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is
+-.Dq yes .
+-This option applies to protocol version 2 only.
+-.It Cm RekeyLimit
+-Specifies the maximum amount of data that may be transmitted before the
+-session key is renegotiated, optionally followed a maximum amount of
+-time that may pass before the session key is renegotiated.
+-The first argument is specified in bytes and may have a suffix of
+-.Sq K ,
+-.Sq M ,
+-or
+-.Sq G
+-to indicate Kilobytes, Megabytes, or Gigabytes, respectively.
+-The default is between
+-.Sq 1G
+-and
+-.Sq 4G ,
+-depending on the cipher.
+-The optional second value is specified in seconds and may use any of the
+-units documented in the
+-TIME FORMATS section of
+-.Xr sshd_config 5 .
+-The default value for
+-.Cm RekeyLimit
+-is
+-.Dq default none ,
+-which means that rekeying is performed after the cipher's default amount
+-of data has been sent or received and no time based rekeying is done.
+-This option applies to protocol version 2 only.
+-.It Cm RemoteForward
+-Specifies that a TCP port on the remote machine be forwarded over
+-the secure channel to the specified host and port from the local machine.
+-The first argument must be
+-.Sm off
+-.Oo Ar bind_address : Oc Ar port
+-.Sm on
+-and the second argument must be
+-.Ar host : Ns Ar hostport .
+-IPv6 addresses can be specified by enclosing addresses in square brackets.
+-Multiple forwardings may be specified, and additional
+-forwardings can be given on the command line.
+-Privileged ports can be forwarded only when
+-logging in as root on the remote machine.
+-.Pp
+-If the
+-.Ar port
+-argument is
+-.Ql 0 ,
+-the listen port will be dynamically allocated on the server and reported
+-to the client at run time.
+-.Pp
+-If the
+-.Ar bind_address
+-is not specified, the default is to only bind to loopback addresses.
+-If the
+-.Ar bind_address
+-is
+-.Ql *
+-or an empty string, then the forwarding is requested to listen on all
+-interfaces.
+-Specifying a remote
+-.Ar bind_address
+-will only succeed if the server's
+-.Cm GatewayPorts
+-option is enabled (see
+-.Xr sshd_config 5 ) .
+-.It Cm RequestTTY
+-Specifies whether to request a pseudo-tty for the session.
+-The argument may be one of:
+-.Dq no
+-(never request a TTY),
+-.Dq yes
+-(always request a TTY when standard input is a TTY),
+-.Dq force
+-(always request a TTY) or
+-.Dq auto
+-(request a TTY when opening a login session).
+-This option mirrors the
+-.Fl t
+-and
+-.Fl T
+-flags for
+-.Xr ssh 1 .
+-.It Cm RevokedHostKeys
+-Specifies revoked host public keys.
+-Keys listed in this file will be refused for host authentication.
+-Note that if this file does not exist or is not readable,
+-then host authentication will be refused for all hosts.
+-Keys may be specified as a text file, listing one public key per line, or as
+-an OpenSSH Key Revocation List (KRL) as generated by
+-.Xr ssh-keygen 1 .
+-For more information on KRLs, see the KEY REVOCATION LISTS section in
+-.Xr ssh-keygen 1 .
+-.It Cm RhostsRSAAuthentication
+-Specifies whether to try rhosts based authentication with RSA host
+-authentication.
+-The argument must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is
+-.Dq no .
+-This option applies to protocol version 1 only and requires
+-.Xr ssh 1
+-to be setuid root.
+-.It Cm RSAAuthentication
+-Specifies whether to try RSA authentication.
+-The argument to this keyword must be
+-.Dq yes
+-or
+-.Dq no .
+-RSA authentication will only be
+-attempted if the identity file exists, or an authentication agent is
+-running.
+-The default is
+-.Dq yes .
+-Note that this option applies to protocol version 1 only.
+-.It Cm SendEnv
+-Specifies what variables from the local
+-.Xr environ 7
+-should be sent to the server.
+-Note that environment passing is only supported for protocol 2.
+-The server must also support it, and the server must be configured to
+-accept these environment variables.
+-Note that the
+-.Ev TERM
+-environment variable is always sent whenever a
+-pseudo-terminal is requested as it is required by the protocol.
+-Refer to
+-.Cm AcceptEnv
+-in
+-.Xr sshd_config 5
+-for how to configure the server.
+-Variables are specified by name, which may contain wildcard characters.
+-Multiple environment variables may be separated by whitespace or spread
+-across multiple
+-.Cm SendEnv
+-directives.
+-The default is not to send any environment variables.
+-.Pp
+-See
+-.Sx PATTERNS
+-for more information on patterns.
+-.It Cm ServerAliveCountMax
+-Sets the number of server alive messages (see below) which may be
+-sent without
+-.Xr ssh 1
+-receiving any messages back from the server.
+-If this threshold is reached while server alive messages are being sent,
+-ssh will disconnect from the server, terminating the session.
+-It is important to note that the use of server alive messages is very
+-different from
+-.Cm TCPKeepAlive
+-(below).
+-The server alive messages are sent through the encrypted channel
+-and therefore will not be spoofable.
+-The TCP keepalive option enabled by
+-.Cm TCPKeepAlive
+-is spoofable.
+-The server alive mechanism is valuable when the client or
+-server depend on knowing when a connection has become inactive.
+-.Pp
+-The default value is 3.
+-If, for example,
+-.Cm ServerAliveInterval
+-(see below) is set to 15 and
+-.Cm ServerAliveCountMax
+-is left at the default, if the server becomes unresponsive,
+-ssh will disconnect after approximately 45 seconds.
+-This option applies to protocol version 2 only.
+-.It Cm ServerAliveInterval
+-Sets a timeout interval in seconds after which if no data has been received
+-from the server,
+-.Xr ssh 1
+-will send a message through the encrypted
+-channel to request a response from the server.
+-The default
+-is 0, indicating that these messages will not be sent to the server.
+-This option applies to protocol version 2 only.
+-.It Cm StreamLocalBindMask
+-Sets the octal file creation mode mask
+-.Pq umask
+-used when creating a Unix-domain socket file for local or remote
+-port forwarding.
+-This option is only used for port forwarding to a Unix-domain socket file.
+-.Pp
+-The default value is 0177, which creates a Unix-domain socket file that is
+-readable and writable only by the owner.
+-Note that not all operating systems honor the file mode on Unix-domain
+-socket files.
+-.It Cm StreamLocalBindUnlink
+-Specifies whether to remove an existing Unix-domain socket file for local
+-or remote port forwarding before creating a new one.
+-If the socket file already exists and
+-.Cm StreamLocalBindUnlink
+-is not enabled,
+-.Nm ssh
+-will be unable to forward the port to the Unix-domain socket file.
+-This option is only used for port forwarding to a Unix-domain socket file.
+-.Pp
+-The argument must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is
+-.Dq no .
+-.It Cm StrictHostKeyChecking
+-If this flag is set to
+-.Dq yes ,
+-.Xr ssh 1
+-will never automatically add host keys to the
+-.Pa ~/.ssh/known_hosts
+-file, and refuses to connect to hosts whose host key has changed.
+-This provides maximum protection against trojan horse attacks,
+-though it can be annoying when the
+-.Pa /etc/ssh/ssh_known_hosts
+-file is poorly maintained or when connections to new hosts are
+-frequently made.
+-This option forces the user to manually
+-add all new hosts.
+-If this flag is set to
+-.Dq no ,
+-ssh will automatically add new host keys to the
+-user known hosts files.
+-If this flag is set to
+-.Dq ask ,
+-new host keys
+-will be added to the user known host files only after the user
+-has confirmed that is what they really want to do, and
+-ssh will refuse to connect to hosts whose host key has changed.
+-The host keys of
+-known hosts will be verified automatically in all cases.
+-The argument must be
+-.Dq yes ,
+-.Dq no ,
+-or
+-.Dq ask .
+-The default is
+-.Dq ask .
+-.It Cm TCPKeepAlive
+-Specifies whether the system should send TCP keepalive messages to the
+-other side.
+-If they are sent, death of the connection or crash of one
+-of the machines will be properly noticed.
+-However, this means that
+-connections will die if the route is down temporarily, and some people
+-find it annoying.
+-.Pp
+-The default is
+-.Dq yes
+-(to send TCP keepalive messages), and the client will notice
+-if the network goes down or the remote host dies.
+-This is important in scripts, and many users want it too.
+-.Pp
+-To disable TCP keepalive messages, the value should be set to
+-.Dq no .
+-.It Cm Tunnel
+-Request
+-.Xr tun 4
+-device forwarding between the client and the server.
+-The argument must be
+-.Dq yes ,
+-.Dq point-to-point
+-(layer 3),
+-.Dq ethernet
+-(layer 2),
+-or
+-.Dq no .
+-Specifying
+-.Dq yes
+-requests the default tunnel mode, which is
+-.Dq point-to-point .
+-The default is
+-.Dq no .
+-.It Cm TunnelDevice
+-Specifies the
+-.Xr tun 4
+-devices to open on the client
+-.Pq Ar local_tun
+-and the server
+-.Pq Ar remote_tun .
+-.Pp
+-The argument must be
+-.Sm off
+-.Ar local_tun Op : Ar remote_tun .
+-.Sm on
+-The devices may be specified by numerical ID or the keyword
+-.Dq any ,
+-which uses the next available tunnel device.
+-If
+-.Ar remote_tun
+-is not specified, it defaults to
+-.Dq any .
+-The default is
+-.Dq any:any .
+-.It Cm UpdateHostKeys
+-Specifies whether
+-.Xr ssh 1
+-should accept notifications of additional hostkeys from the server sent
+-after authentication has completed and add them to
+-.Cm UserKnownHostsFile .
+-The argument must be
+-.Dq yes ,
+-.Dq no
+-(the default) or
+-.Dq ask .
+-Enabling this option allows learning alternate hostkeys for a server
+-and supports graceful key rotation by allowing a server to send replacement
+-public keys before old ones are removed.
+-Additional hostkeys are only accepted if the key used to authenticate the
+-host was already trusted or explicity accepted by the user.
+-If
+-.Cm UpdateHostKeys
+-is set to
+-.Dq ask ,
+-then the user is asked to confirm the modifications to the known_hosts file.
+-Confirmation is currently incompatible with
+-.Cm ControlPersist ,
+-and will be disabled if it is enabled.
+-.Pp
+-Presently, only
+-.Xr sshd 8
+-from OpenSSH 6.8 and greater support the
+-.Dq hostkeys@openssh.com
+-protocol extension used to inform the client of all the server's hostkeys.
+-.It Cm UsePrivilegedPort
+-Specifies whether to use a privileged port for outgoing connections.
+-The argument must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is
+-.Dq no .
+-If set to
+-.Dq yes ,
+-.Xr ssh 1
+-must be setuid root.
+-Note that this option must be set to
+-.Dq yes
+-for
+-.Cm RhostsRSAAuthentication
+-with older servers.
+-.It Cm User
+-Specifies the user to log in as.
+-This can be useful when a different user name is used on different machines.
+-This saves the trouble of
+-having to remember to give the user name on the command line.
+-.It Cm UserKnownHostsFile
+-Specifies one or more files to use for the user
+-host key database, separated by whitespace.
+-The default is
+-.Pa ~/.ssh/known_hosts ,
+-.Pa ~/.ssh/known_hosts2 .
+-.It Cm VerifyHostKeyDNS
+-Specifies whether to verify the remote key using DNS and SSHFP resource
+-records.
+-If this option is set to
+-.Dq yes ,
+-the client will implicitly trust keys that match a secure fingerprint
+-from DNS.
+-Insecure fingerprints will be handled as if this option was set to
+-.Dq ask .
+-If this option is set to
+-.Dq ask ,
+-information on fingerprint match will be displayed, but the user will still
+-need to confirm new host keys according to the
+-.Cm StrictHostKeyChecking
+-option.
+-The argument must be
+-.Dq yes ,
+-.Dq no ,
+-or
+-.Dq ask .
+-The default is
+-.Dq no .
+-Note that this option applies to protocol version 2 only.
+-.Pp
+-See also VERIFYING HOST KEYS in
+-.Xr ssh 1 .
+-.It Cm VisualHostKey
+-If this flag is set to
+-.Dq yes ,
+-an ASCII art representation of the remote host key fingerprint is
+-printed in addition to the fingerprint string at login and
+-for unknown host keys.
+-If this flag is set to
+-.Dq no ,
+-no fingerprint strings are printed at login and
+-only the fingerprint string will be printed for unknown host keys.
+-The default is
+-.Dq no .
+-.It Cm XAuthLocation
+-Specifies the full pathname of the
+-.Xr xauth 1
+-program.
+-The default is
+-.Pa /usr/X11R6/bin/xauth .
+-.El
+-.Sh PATTERNS
+-A
+-.Em pattern
+-consists of zero or more non-whitespace characters,
+-.Sq *
+-(a wildcard that matches zero or more characters),
+-or
+-.Sq ?\&
+-(a wildcard that matches exactly one character).
+-For example, to specify a set of declarations for any host in the
+-.Dq .co.uk
+-set of domains,
+-the following pattern could be used:
+-.Pp
+-.Dl Host *.co.uk
+-.Pp
+-The following pattern
+-would match any host in the 192.168.0.[0-9] network range:
+-.Pp
+-.Dl Host 192.168.0.?
+-.Pp
+-A
+-.Em pattern-list
+-is a comma-separated list of patterns.
+-Patterns within pattern-lists may be negated
+-by preceding them with an exclamation mark
+-.Pq Sq !\& .
+-For example,
+-to allow a key to be used from anywhere within an organization
+-except from the
+-.Dq dialup
+-pool,
+-the following entry (in authorized_keys) could be used:
+-.Pp
+-.Dl from=\&"!*.dialup.example.com,*.example.com\&"
+-.Sh FILES
+-.Bl -tag -width Ds
+-.It Pa ~/.ssh/config
+-This is the per-user configuration file.
+-The format of this file is described above.
+-This file is used by the SSH client.
+-Because of the potential for abuse, this file must have strict permissions:
+-read/write for the user, and not accessible by others.
+-.It Pa /etc/ssh/ssh_config
+-Systemwide configuration file.
+-This file provides defaults for those
+-values that are not specified in the user's configuration file, and
+-for those users who do not have a configuration file.
+-This file must be world-readable.
+-.El
+-.Sh SEE ALSO
+-.Xr ssh 1
+-.Sh AUTHORS
+-OpenSSH is a derivative of the original and free
+-ssh 1.2.12 release by Tatu Ylonen.
+-Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
+-Theo de Raadt and Dug Song
+-removed many bugs, re-added newer features and
+-created OpenSSH.
+-Markus Friedl contributed the support for SSH
+-protocol versions 1.5 and 2.0.
+diff --git a/sshd.1m b/sshd.1m
+new file mode 100644
+index 0000000..ada4f25
+--- /dev/null
++++ b/sshd.1m
+@@ -0,0 +1,971 @@
++.\"
++.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
++.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
++.\"                    All rights reserved
++.\"
++.\" As far as I am concerned, the code I have written for this software
++.\" can be used freely for any purpose.  Any derived versions of this
++.\" software must be clearly marked as such, and if the derived work is
++.\" incompatible with the protocol description in the RFC file, it must be
++.\" called by a name other than "ssh" or "Secure Shell".
++.\"
++.\" Copyright (c) 1999,2000 Markus Friedl.  All rights reserved.
++.\" Copyright (c) 1999 Aaron Campbell.  All rights reserved.
++.\" Copyright (c) 1999 Theo de Raadt.  All rights reserved.
++.\"
++.\" Redistribution and use in source and binary forms, with or without
++.\" modification, are permitted provided that the following conditions
++.\" are met:
++.\" 1. Redistributions of source code must retain the above copyright
++.\"    notice, this list of conditions and the following disclaimer.
++.\" 2. Redistributions in binary form must reproduce the above copyright
++.\"    notice, this list of conditions and the following disclaimer in the
++.\"    documentation and/or other materials provided with the distribution.
++.\"
++.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
++.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
++.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
++.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
++.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
++.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
++.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++.\"
++.\" $OpenBSD: sshd.8,v 1.280 2015/07/03 03:49:45 djm Exp $
++.Dd $Mdocdate: July 3 2015 $
++.Dt SSHD 1M
++.Os
++.Sh NAME
++.Nm sshd
++.Nd OpenSSH SSH daemon
++.Sh SYNOPSIS
++.Nm sshd
++.Bk -words
++.Op Fl 46DdeiqTt
++.Op Fl b Ar bits
++.Op Fl C Ar connection_spec
++.Op Fl c Ar host_certificate_file
++.Op Fl E Ar log_file
++.Op Fl f Ar config_file
++.Op Fl g Ar login_grace_time
++.Op Fl h Ar host_key_file
++.Op Fl k Ar key_gen_time
++.Op Fl o Ar option
++.Op Fl p Ar port
++.Op Fl u Ar len
++.Ek
++.Sh DESCRIPTION
++.Nm
++(OpenSSH Daemon) is the daemon program for
++.Xr ssh 1 .
++Together these programs replace rlogin and rsh,
++and provide secure encrypted communications between two untrusted hosts
++over an insecure network.
++.Pp
++.Nm
++listens for connections from clients.
++It is normally started at boot by
++.Xr smf 5 .
++It forks a new
++daemon for each incoming connection.
++The forked daemons handle
++key exchange, encryption, authentication, command execution,
++and data exchange.
++.Pp
++.Nm
++can be configured using command-line options or a configuration file
++(by default
++.Xr sshd_config 4 ) ;
++command-line options override values specified in the
++configuration file.
++.Nm
++rereads its configuration file when it receives a hangup signal,
++.Dv SIGHUP ,
++by executing itself with the name and options it was started with, e.g.\&
++.Pa /usr/sbin/sshd .
++.Pp
++The options are as follows:
++.Bl -tag -width Ds
++.It Fl 4
++Forces
++.Nm
++to use IPv4 addresses only.
++.It Fl 6
++Forces
++.Nm
++to use IPv6 addresses only.
++.It Fl b Ar bits
++Specifies the number of bits in the ephemeral protocol version 1
++server key (default 1024).
++.It Fl C Ar connection_spec
++Specify the connection parameters to use for the
++.Fl T
++extended test mode.
++If provided, any
++.Cm Match
++directives in the configuration file
++that would apply to the specified user, host, and address will be set before
++the configuration is written to standard output.
++The connection parameters are supplied as keyword=value pairs.
++The keywords are
++.Dq user ,
++.Dq host ,
++.Dq laddr ,
++.Dq lport ,
++and
++.Dq addr .
++All are required and may be supplied in any order, either with multiple
++.Fl C
++options or as a comma-separated list.
++.It Fl c Ar host_certificate_file
++Specifies a path to a certificate file to identify
++.Nm
++during key exchange.
++The certificate file must match a host key file specified using the
++.Fl h
++option or the
++.Cm HostKey
++configuration directive.
++.It Fl D
++When this option is specified,
++.Nm
++will not detach and does not become a daemon.
++This allows easy monitoring of
++.Nm sshd .
++.It Fl d
++Debug mode.
++The server sends verbose debug output to standard error,
++and does not put itself in the background.
++The server also will not fork and will only process one connection.
++This option is only intended for debugging for the server.
++Multiple
++.Fl d
++options increase the debugging level.
++Maximum is 3.
++.It Fl E Ar log_file
++Append debug logs to
++.Ar log_file
++instead of the system log.
++.It Fl e
++Write debug logs to standard error instead of the system log.
++.It Fl f Ar config_file
++Specifies the name of the configuration file.
++The default is
++.Pa /etc/ssh/sshd_config .
++.Nm
++refuses to start if there is no configuration file.
++.It Fl g Ar login_grace_time
++Gives the grace time for clients to authenticate themselves (default
++120 seconds).
++If the client fails to authenticate the user within
++this many seconds, the server disconnects and exits.
++A value of zero indicates no limit.
++.It Fl h Ar host_key_file
++Specifies a file from which a host key is read.
++This option must be given if
++.Nm
++is not run as root (as the normal
++host key files are normally not readable by anyone but root).
++The default is
++.Pa /etc/ssh/ssh_host_key
++for protocol version 1, and
++.Pa /etc/ssh/ssh_host_dsa_key ,
++.Pa /etc/ssh/ssh_host_ecdsa_key .
++.Pa /etc/ssh/ssh_host_ed25519_key
++and
++.Pa /etc/ssh/ssh_host_rsa_key
++for protocol version 2.
++It is possible to have multiple host key files for
++the different protocol versions and host key algorithms.
++.It Fl i
++Specifies that
++.Nm
++is being run from
++.Xr inetd 8 .
++If SSH protocol 1 is enabled,
++.Nm
++should not  normally be run
++from inetd because it needs to generate the server key before it can
++respond to the client, and this may take some time.
++Clients may have to wait too long if the key was regenerated every time.
++.It Fl k Ar key_gen_time
++Specifies how often the ephemeral protocol version 1 server key is
++regenerated (default 3600 seconds, or one hour).
++The motivation for regenerating the key fairly
++often is that the key is not stored anywhere, and after about an hour
++it becomes impossible to recover the key for decrypting intercepted
++communications even if the machine is cracked into or physically
++seized.
++A value of zero indicates that the key will never be regenerated.
++.It Fl o Ar option
++Can be used to give options in the format used in the configuration file.
++This is useful for specifying options for which there is no separate
++command-line flag.
++For full details of the options, and their values, see
++.Xr sshd_config 4 .
++.It Fl p Ar port
++Specifies the port on which the server listens for connections
++(default 22).
++Multiple port options are permitted.
++Ports specified in the configuration file with the
++.Cm Port
++option are ignored when a command-line port is specified.
++Ports specified using the
++.Cm ListenAddress
++option override command-line ports.
++.It Fl q
++Quiet mode.
++Nothing is sent to the system log.
++Normally the beginning,
++authentication, and termination of each connection is logged.
++.It Fl T
++Extended test mode.
++Check the validity of the configuration file, output the effective configuration
++to stdout and then exit.
++Optionally,
++.Cm Match
++rules may be applied by specifying the connection parameters using one or more
++.Fl C
++options.
++.It Fl t
++Test mode.
++Only check the validity of the configuration file and sanity of the keys.
++This is useful for updating
++.Nm
++reliably as configuration options may change.
++.It Fl u Ar len
++This option is used to specify the size of the field
++in the
++.Li utmp
++structure that holds the remote host name.
++If the resolved host name is longer than
++.Ar len ,
++the dotted decimal value will be used instead.
++This allows hosts with very long host names that
++overflow this field to still be uniquely identified.
++Specifying
++.Fl u0
++indicates that only dotted decimal addresses
++should be put into the
++.Pa utmp
++file.
++.Fl u0
++may also be used to prevent
++.Nm
++from making DNS requests unless the authentication
++mechanism or configuration requires it.
++Authentication mechanisms that may require DNS include
++.Cm RhostsRSAAuthentication ,
++.Cm HostbasedAuthentication ,
++and using a
++.Cm from="pattern-list"
++option in a key file.
++Configuration options that require DNS include using a
++USER@HOST pattern in
++.Cm AllowUsers
++or
++.Cm DenyUsers .
++.El
++.Sh AUTHENTICATION
++The OpenSSH SSH daemon supports SSH protocols 1 and 2.
++The default is to use protocol 2 only,
++though this can be changed via the
++.Cm Protocol
++option in
++.Xr sshd_config 4 .
++Protocol 2 supports DSA, ECDSA, Ed25519 and RSA keys;
++protocol 1 only supports RSA keys.
++For both protocols,
++each host has a host-specific key,
++normally 2048 bits,
++used to identify the host.
++.Pp
++Forward security for protocol 1 is provided through
++an additional server key,
++normally 1024 bits,
++generated when the server starts.
++This key is normally regenerated every hour if it has been used, and
++is never stored on disk.
++Whenever a client connects, the daemon responds with its public
++host and server keys.
++The client compares the
++RSA host key against its own database to verify that it has not changed.
++The client then generates a 256-bit random number.
++It encrypts this
++random number using both the host key and the server key, and sends
++the encrypted number to the server.
++Both sides then use this
++random number as a session key which is used to encrypt all further
++communications in the session.
++The rest of the session is encrypted
++using a conventional cipher, currently Blowfish or 3DES, with 3DES
++being used by default.
++The client selects the encryption algorithm
++to use from those offered by the server.
++.Pp
++For protocol 2,
++forward security is provided through a Diffie-Hellman key agreement.
++This key agreement results in a shared session key.
++The rest of the session is encrypted using a symmetric cipher, currently
++128-bit AES, Blowfish, 3DES, CAST128, Arcfour, 192-bit AES, or 256-bit AES.
++The client selects the encryption algorithm
++to use from those offered by the server.
++Additionally, session integrity is provided
++through a cryptographic message authentication code
++(hmac-md5, hmac-sha1, umac-64, umac-128, hmac-ripemd160,
++hmac-sha2-256 or hmac-sha2-512).
++.Pp
++Finally, the server and the client enter an authentication dialog.
++The client tries to authenticate itself using
++host-based authentication,
++public key authentication,
++challenge-response authentication,
++or password authentication.
++.Pp
++Regardless of the authentication type, the account is checked to
++ensure that it is accessible.  An account is not accessible if it is
++locked, listed in
++.Cm DenyUsers
++or its group is listed in
++.Cm DenyGroups
++\&.  The definition of a locked account is system dependant. Some platforms
++have their own account database (eg AIX) and some modify the passwd field (
++.Ql \&*LK\&*
++on Solaris and UnixWare,
++.Ql \&*
++on HP-UX, containing
++.Ql Nologin
++on Tru64,
++a leading
++.Ql \&*LOCKED\&*
++on FreeBSD and a leading
++.Ql \&!
++on most Linuxes).
++If there is a requirement to disable password authentication
++for the account while allowing still public-key, then the passwd field
++should be set to something other than these values (eg
++.Ql NP
++or
++.Ql \&*NP\&*
++).
++.Pp
++If the client successfully authenticates itself, a dialog for
++preparing the session is entered.
++At this time the client may request
++things like allocating a pseudo-tty, forwarding X11 connections,
++forwarding TCP connections, or forwarding the authentication agent
++connection over the secure channel.
++.Pp
++After this, the client either requests a shell or execution of a command.
++The sides then enter session mode.
++In this mode, either side may send
++data at any time, and such data is forwarded to/from the shell or
++command on the server side, and the user terminal in the client side.
++.Pp
++When the user program terminates and all forwarded X11 and other
++connections have been closed, the server sends command exit status to
++the client, and both sides exit.
++.Sh LOGIN PROCESS
++When a user successfully logs in,
++.Nm
++does the following:
++.Bl -enum -offset indent
++.It
++If the login is on a tty, and no command has been specified,
++prints last login time and
++.Pa /etc/motd
++(unless prevented in the configuration file or by
++.Pa ~/.hushlogin ;
++see the
++.Sx FILES
++section).
++.It
++If the login is on a tty, records login time.
++.It
++Checks
++.Pa /etc/nologin ;
++if it exists, prints contents and quits
++(unless root).
++.It
++Changes to run with normal user privileges.
++.It
++Sets up basic environment.
++.It
++Reads the file
++.Pa ~/.ssh/environment ,
++if it exists, and users are allowed to change their environment.
++See the
++.Cm PermitUserEnvironment
++option in
++.Xr sshd_config 4 .
++.It
++Changes to user's home directory.
++.It
++If
++.Pa ~/.ssh/rc
++exists and the
++.Xr sshd_config 5
++.Cm PermitUserRC
++option is set, runs it; else if
++.Pa /etc/ssh/sshrc
++exists, runs
++it; otherwise runs xauth.
++The
++.Dq rc
++files are given the X11
++authentication protocol and cookie in standard input.
++See
++.Sx SSHRC ,
++below.
++.It
++Runs user's shell or command.
++All commands are run under the user's login shell as specified in the
++system password database.
++.El
++.Sh SSHRC
++If the file
++.Pa ~/.ssh/rc
++exists,
++.Xr sh 1
++runs it after reading the
++environment files but before starting the user's shell or command.
++It must not produce any output on stdout; stderr must be used
++instead.
++If X11 forwarding is in use, it will receive the "proto cookie" pair in
++its standard input (and
++.Ev DISPLAY
++in its environment).
++The script must call
++.Xr xauth 1
++because
++.Nm
++will not run xauth automatically to add X11 cookies.
++.Pp
++The primary purpose of this file is to run any initialization routines
++which may be needed before the user's home directory becomes
++accessible; AFS is a particular example of such an environment.
++.Pp
++This file will probably contain some initialization code followed by
++something similar to:
++.Bd -literal -offset 3n
++if read proto cookie && [ -n "$DISPLAY" ]; then
++	if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then
++		# X11UseLocalhost=yes
++		echo add unix:`echo $DISPLAY |
++		    cut -c11-` $proto $cookie
++	else
++		# X11UseLocalhost=no
++		echo add $DISPLAY $proto $cookie
++	fi | xauth -q -
++fi
++.Ed
++.Pp
++If this file does not exist,
++.Pa /etc/ssh/sshrc
++is run, and if that
++does not exist either, xauth is used to add the cookie.
++.Sh AUTHORIZED_KEYS FILE FORMAT
++.Cm AuthorizedKeysFile
++specifies the files containing public keys for
++public key authentication;
++if none is specified, the default is
++.Pa ~/.ssh/authorized_keys
++and
++.Pa ~/.ssh/authorized_keys2 .
++Each line of the file contains one
++key (empty lines and lines starting with a
++.Ql #
++are ignored as
++comments).
++Protocol 1 public keys consist of the following space-separated fields:
++options, bits, exponent, modulus, comment.
++Protocol 2 public key consist of:
++options, keytype, base64-encoded key, comment.
++The options field is optional;
++its presence is determined by whether the line starts
++with a number or not (the options field never starts with a number).
++The bits, exponent, modulus, and comment fields give the RSA key for
++protocol version 1; the
++comment field is not used for anything (but may be convenient for the
++user to identify the key).
++For protocol version 2 the keytype is
++.Dq ecdsa-sha2-nistp256 ,
++.Dq ecdsa-sha2-nistp384 ,
++.Dq ecdsa-sha2-nistp521 ,
++.Dq ssh-ed25519 ,
++.Dq ssh-dss
++or
++.Dq ssh-rsa .
++.Pp
++Note that lines in this file are usually several hundred bytes long
++(because of the size of the public key encoding) up to a limit of
++8 kilobytes, which permits DSA keys up to 8 kilobits and RSA
++keys up to 16 kilobits.
++You don't want to type them in; instead, copy the
++.Pa identity.pub ,
++.Pa id_dsa.pub ,
++.Pa id_ecdsa.pub ,
++.Pa id_ed25519.pub ,
++or the
++.Pa id_rsa.pub
++file and edit it.
++.Pp
++.Nm
++enforces a minimum RSA key modulus size for protocol 1
++and protocol 2 keys of 768 bits.
++.Pp
++The options (if present) consist of comma-separated option
++specifications.
++No spaces are permitted, except within double quotes.
++The following option specifications are supported (note
++that option keywords are case-insensitive):
++.Bl -tag -width Ds
++.It Cm cert-authority
++Specifies that the listed key is a certification authority (CA) that is
++trusted to validate signed certificates for user authentication.
++.Pp
++Certificates may encode access restrictions similar to these key options.
++If both certificate restrictions and key options are present, the most
++restrictive union of the two is applied.
++.It Cm command="command"
++Specifies that the command is executed whenever this key is used for
++authentication.
++The command supplied by the user (if any) is ignored.
++The command is run on a pty if the client requests a pty;
++otherwise it is run without a tty.
++If an 8-bit clean channel is required,
++one must not request a pty or should specify
++.Cm no-pty .
++A quote may be included in the command by quoting it with a backslash.
++This option might be useful
++to restrict certain public keys to perform just a specific operation.
++An example might be a key that permits remote backups but nothing else.
++Note that the client may specify TCP and/or X11
++forwarding unless they are explicitly prohibited.
++The command originally supplied by the client is available in the
++.Ev SSH_ORIGINAL_COMMAND
++environment variable.
++Note that this option applies to shell, command or subsystem execution.
++Also note that this command may be superseded by either a
++.Xr sshd_config 4
++.Cm ForceCommand
++directive or a command embedded in a certificate.
++.It Cm environment="NAME=value"
++Specifies that the string is to be added to the environment when
++logging in using this key.
++Environment variables set this way
++override other default environment values.
++Multiple options of this type are permitted.
++Environment processing is disabled by default and is
++controlled via the
++.Cm PermitUserEnvironment
++option.
++This option is automatically disabled if
++.Cm UseLogin
++is enabled.
++.It Cm from="pattern-list"
++Specifies that in addition to public key authentication, either the canonical
++name of the remote host or its IP address must be present in the
++comma-separated list of patterns.
++See PATTERNS in
++.Xr ssh_config 4
++for more information on patterns.
++.Pp
++In addition to the wildcard matching that may be applied to hostnames or
++addresses, a
++.Cm from
++stanza may match IP addresses using CIDR address/masklen notation.
++.Pp
++The purpose of this option is to optionally increase security: public key
++authentication by itself does not trust the network or name servers or
++anything (but the key); however, if somebody somehow steals the key, the key
++permits an intruder to log in from anywhere in the world.
++This additional option makes using a stolen key more difficult (name
++servers and/or routers would have to be compromised in addition to
++just the key).
++.It Cm no-agent-forwarding
++Forbids authentication agent forwarding when this key is used for
++authentication.
++.It Cm no-port-forwarding
++Forbids TCP forwarding when this key is used for authentication.
++Any port forward requests by the client will return an error.
++This might be used, e.g. in connection with the
++.Cm command
++option.
++.It Cm no-pty
++Prevents tty allocation (a request to allocate a pty will fail).
++.It Cm no-user-rc
++Disables execution of
++.Pa ~/.ssh/rc .
++.It Cm no-X11-forwarding
++Forbids X11 forwarding when this key is used for authentication.
++Any X11 forward requests by the client will return an error.
++.It Cm permitopen="host:port"
++Limit local port forwarding with
++.Xr ssh 1
++.Fl L
++such that it may only connect to the specified host and port.
++IPv6 addresses can be specified by enclosing the address in square brackets.
++Multiple
++.Cm permitopen
++options may be applied separated by commas.
++No pattern matching is performed on the specified hostnames,
++they must be literal domains or addresses.
++A port specification of
++.Cm *
++matches any port.
++.It Cm principals="principals"
++On a
++.Cm cert-authority
++line, specifies allowed principals for certificate authentication as a
++comma-separated list.
++At least one name from the list must appear in the certificate's
++list of principals for the certificate to be accepted.
++This option is ignored for keys that are not marked as trusted certificate
++signers using the
++.Cm cert-authority
++option.
++.It Cm tunnel="n"
++Force a
++.Xr tun 4
++device on the server.
++Without this option, the next available device will be used if
++the client requests a tunnel.
++.El
++.Pp
++An example authorized_keys file:
++.Bd -literal -offset 3n
++# Comments allowed at start of line
++ssh-rsa AAAAB3Nza...LiPk== user@example.net
++from="*.sales.example.net,!pc.sales.example.net" ssh-rsa
++AAAAB2...19Q== john@example.net
++command="dump /home",no-pty,no-port-forwarding ssh-dss
++AAAAC3...51R== example.net
++permitopen="192.0.2.1:80",permitopen="192.0.2.2:25" ssh-dss
++AAAAB5...21S==
++tunnel="0",command="sh /etc/netstart tun0" ssh-rsa AAAA...==
++jane@example.net
++.Ed
++.Sh SSH_KNOWN_HOSTS FILE FORMAT
++The
++.Pa /etc/ssh/ssh_known_hosts
++and
++.Pa ~/.ssh/known_hosts
++files contain host public keys for all known hosts.
++The global file should
++be prepared by the administrator (optional), and the per-user file is
++maintained automatically: whenever the user connects from an unknown host,
++its key is added to the per-user file.
++.Pp
++Each line in these files contains the following fields: markers (optional),
++hostnames, bits, exponent, modulus, comment.
++The fields are separated by spaces.
++.Pp
++The marker is optional, but if it is present then it must be one of
++.Dq @cert-authority ,
++to indicate that the line contains a certification authority (CA) key,
++or
++.Dq @revoked ,
++to indicate that the key contained on the line is revoked and must not ever
++be accepted.
++Only one marker should be used on a key line.
++.Pp
++Hostnames is a comma-separated list of patterns
++.Pf ( Ql *
++and
++.Ql \&?
++act as
++wildcards); each pattern in turn is matched against the canonical host
++name (when authenticating a client) or against the user-supplied
++name (when authenticating a server).
++A pattern may also be preceded by
++.Ql \&!
++to indicate negation: if the host name matches a negated
++pattern, it is not accepted (by that line) even if it matched another
++pattern on the line.
++A hostname or address may optionally be enclosed within
++.Ql \&[
++and
++.Ql \&]
++brackets then followed by
++.Ql \&:
++and a non-standard port number.
++.Pp
++Alternately, hostnames may be stored in a hashed form which hides host names
++and addresses should the file's contents be disclosed.
++Hashed hostnames start with a
++.Ql |
++character.
++Only one hashed hostname may appear on a single line and none of the above
++negation or wildcard operators may be applied.
++.Pp
++Bits, exponent, and modulus are taken directly from the RSA host key; they
++can be obtained, for example, from
++.Pa /etc/ssh/ssh_host_key.pub .
++The optional comment field continues to the end of the line, and is not used.
++.Pp
++Lines starting with
++.Ql #
++and empty lines are ignored as comments.
++.Pp
++When performing host authentication, authentication is accepted if any
++matching line has the proper key; either one that matches exactly or,
++if the server has presented a certificate for authentication, the key
++of the certification authority that signed the certificate.
++For a key to be trusted as a certification authority, it must use the
++.Dq @cert-authority
++marker described above.
++.Pp
++The known hosts file also provides a facility to mark keys as revoked,
++for example when it is known that the associated private key has been
++stolen.
++Revoked keys are specified by including the
++.Dq @revoked
++marker at the beginning of the key line, and are never accepted for
++authentication or as certification authorities, but instead will
++produce a warning from
++.Xr ssh 1
++when they are encountered.
++.Pp
++It is permissible (but not
++recommended) to have several lines or different host keys for the same
++names.
++This will inevitably happen when short forms of host names
++from different domains are put in the file.
++It is possible
++that the files contain conflicting information; authentication is
++accepted if valid information can be found from either file.
++.Pp
++Note that the lines in these files are typically hundreds of characters
++long, and you definitely don't want to type in the host keys by hand.
++Rather, generate them by a script,
++.Xr ssh-keyscan 1
++or by taking
++.Pa /etc/ssh/ssh_host_key.pub
++and adding the host names at the front.
++.Xr ssh-keygen 1
++also offers some basic automated editing for
++.Pa ~/.ssh/known_hosts
++including removing hosts matching a host name and converting all host
++names to their hashed representations.
++.Pp
++An example ssh_known_hosts file:
++.Bd -literal -offset 3n
++# Comments allowed at start of line
++closenet,...,192.0.2.53 1024 37 159...93 closenet.example.net
++cvs.example.net,192.0.2.10 ssh-rsa AAAA1234.....=
++# A hashed hostname
++|1|JfKTdBh7rNbXkVAQCRp4OQoPfmI=|USECr3SWf1JUPsms5AqfD5QfxkM= ssh-rsa
++AAAA1234.....=
++# A revoked key
++@revoked * ssh-rsa AAAAB5W...
++# A CA key, accepted for any host in *.mydomain.com or *.mydomain.org
++@cert-authority *.mydomain.org,*.mydomain.com ssh-rsa AAAAB5W...
++.Ed
++.Sh FILES
++.Bl -tag -width Ds -compact
++.It Pa ~/.hushlogin
++This file is used to suppress printing the last login time and
++.Pa /etc/motd ,
++if
++.Cm PrintLastLog
++and
++.Cm PrintMotd ,
++respectively,
++are enabled.
++It does not suppress printing of the banner specified by
++.Cm Banner .
++.Pp
++.It Pa ~/.rhosts
++This file is used for host-based authentication (see
++.Xr ssh 1
++for more information).
++On some machines this file may need to be
++world-readable if the user's home directory is on an NFS partition,
++because
++.Nm
++reads it as root.
++Additionally, this file must be owned by the user,
++and must not have write permissions for anyone else.
++The recommended
++permission for most machines is read/write for the user, and not
++accessible by others.
++.Pp
++.It Pa ~/.shosts
++This file is used in exactly the same way as
++.Pa .rhosts ,
++but allows host-based authentication without permitting login with
++rlogin/rsh.
++.Pp
++.It Pa ~/.ssh/
++This directory is the default location for all user-specific configuration
++and authentication information.
++There is no general requirement to keep the entire contents of this directory
++secret, but the recommended permissions are read/write/execute for the user,
++and not accessible by others.
++.Pp
++.It Pa ~/.ssh/authorized_keys
++Lists the public keys (DSA, ECDSA, Ed25519, RSA)
++that can be used for logging in as this user.
++The format of this file is described above.
++The content of the file is not highly sensitive, but the recommended
++permissions are read/write for the user, and not accessible by others.
++.Pp
++If this file, the
++.Pa ~/.ssh
++directory, or the user's home directory are writable
++by other users, then the file could be modified or replaced by unauthorized
++users.
++In this case,
++.Nm
++will not allow it to be used unless the
++.Cm StrictModes
++option has been set to
++.Dq no .
++.Pp
++.It Pa ~/.ssh/environment
++This file is read into the environment at login (if it exists).
++It can only contain empty lines, comment lines (that start with
++.Ql # ) ,
++and assignment lines of the form name=value.
++The file should be writable
++only by the user; it need not be readable by anyone else.
++Environment processing is disabled by default and is
++controlled via the
++.Cm PermitUserEnvironment
++option.
++.Pp
++.It Pa ~/.ssh/known_hosts
++Contains a list of host keys for all hosts the user has logged into
++that are not already in the systemwide list of known host keys.
++The format of this file is described above.
++This file should be writable only by root/the owner and
++can, but need not be, world-readable.
++.Pp
++.It Pa ~/.ssh/rc
++Contains initialization routines to be run before
++the user's home directory becomes accessible.
++This file should be writable only by the user, and need not be
++readable by anyone else.
++.Pp
++.It Pa /etc/hosts.equiv
++This file is for host-based authentication (see
++.Xr ssh 1 ) .
++It should only be writable by root.
++.Pp
++.It Pa /etc/moduli
++Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange".
++The file format is described in
++.Xr moduli 4 .
++.Pp
++.It Pa /etc/motd
++See
++.Xr motd 5 .
++.Pp
++.It Pa /etc/nologin
++If this file exists,
++.Nm
++refuses to let anyone except root log in.
++The contents of the file
++are displayed to anyone trying to log in, and non-root connections are
++refused.
++The file should be world-readable.
++.Pp
++.It Pa /etc/shosts.equiv
++This file is used in exactly the same way as
++.Pa hosts.equiv ,
++but allows host-based authentication without permitting login with
++rlogin/rsh.
++.Pp
++.It Pa /etc/ssh/ssh_host_key
++.It Pa /etc/ssh/ssh_host_dsa_key
++.It Pa /etc/ssh/ssh_host_ecdsa_key
++.It Pa /etc/ssh/ssh_host_ed25519_key
++.It Pa /etc/ssh/ssh_host_rsa_key
++These files contain the private parts of the host keys.
++These files should only be owned by root, readable only by root, and not
++accessible to others.
++Note that
++.Nm
++does not start if these files are group/world-accessible.
++.Pp
++.It Pa /etc/ssh/ssh_host_key.pub
++.It Pa /etc/ssh/ssh_host_dsa_key.pub
++.It Pa /etc/ssh/ssh_host_ecdsa_key.pub
++.It Pa /etc/ssh/ssh_host_ed25519_key.pub
++.It Pa /etc/ssh/ssh_host_rsa_key.pub
++These files contain the public parts of the host keys.
++These files should be world-readable but writable only by
++root.
++Their contents should match the respective private parts.
++These files are not
++really used for anything; they are provided for the convenience of
++the user so their contents can be copied to known hosts files.
++These files are created using
++.Xr ssh-keygen 1 .
++.Pp
++.It Pa /etc/ssh/ssh_known_hosts
++Systemwide list of known host keys.
++This file should be prepared by the
++system administrator to contain the public host keys of all machines in the
++organization.
++The format of this file is described above.
++This file should be writable only by root/the owner and
++should be world-readable.
++.Pp
++.It Pa /etc/ssh/sshd_config
++Contains configuration data for
++.Nm sshd .
++The file format and configuration options are described in
++.Xr sshd_config 4 .
++.Pp
++.It Pa /etc/ssh/sshrc
++Similar to
++.Pa ~/.ssh/rc ,
++it can be used to specify
++machine-specific login-time initializations globally.
++This file should be writable only by root, and should be world-readable.
++.Pp
++.It Pa /var/empty
++.Xr chroot 2
++directory used by
++.Nm
++during privilege separation in the pre-authentication phase.
++The directory should not contain any files and must be owned by root
++and not group or world-writable.
++.Pp
++.It Pa /var/run/sshd.pid
++Contains the process ID of the
++.Nm
++listening for connections (if there are several daemons running
++concurrently for different ports, this contains the process ID of the one
++started last).
++The content of this file is not sensitive; it can be world-readable.
++.El
++.Sh SEE ALSO
++.Xr scp 1 ,
++.Xr sftp 1 ,
++.Xr ssh 1 ,
++.Xr ssh-add 1 ,
++.Xr ssh-agent 1 ,
++.Xr ssh-keygen 1 ,
++.Xr ssh-keyscan 1 ,
++.Xr chroot 2 ,
++.Xr login.conf 5 ,
++.Xr moduli 4 ,
++.Xr sshd_config 4 ,
++.Xr inetd 1M ,
++.Xr sftp-server 1M
++.Sh AUTHORS
++OpenSSH is a derivative of the original and free
++ssh 1.2.12 release by Tatu Ylonen.
++Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
++Theo de Raadt and Dug Song
++removed many bugs, re-added newer features and
++created OpenSSH.
++Markus Friedl contributed the support for SSH
++protocol versions 1.5 and 2.0.
++Niels Provos and Markus Friedl contributed support
++for privilege separation.
+diff --git a/sshd.8 b/sshd.8
+deleted file mode 100644
+index 213b5fc..0000000
+--- a/sshd.8
++++ /dev/null
+@@ -1,971 +0,0 @@
+-.\"
+-.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
+-.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
+-.\"                    All rights reserved
+-.\"
+-.\" As far as I am concerned, the code I have written for this software
+-.\" can be used freely for any purpose.  Any derived versions of this
+-.\" software must be clearly marked as such, and if the derived work is
+-.\" incompatible with the protocol description in the RFC file, it must be
+-.\" called by a name other than "ssh" or "Secure Shell".
+-.\"
+-.\" Copyright (c) 1999,2000 Markus Friedl.  All rights reserved.
+-.\" Copyright (c) 1999 Aaron Campbell.  All rights reserved.
+-.\" Copyright (c) 1999 Theo de Raadt.  All rights reserved.
+-.\"
+-.\" Redistribution and use in source and binary forms, with or without
+-.\" modification, are permitted provided that the following conditions
+-.\" are met:
+-.\" 1. Redistributions of source code must retain the above copyright
+-.\"    notice, this list of conditions and the following disclaimer.
+-.\" 2. Redistributions in binary form must reproduce the above copyright
+-.\"    notice, this list of conditions and the following disclaimer in the
+-.\"    documentation and/or other materials provided with the distribution.
+-.\"
+-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+-.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+-.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+-.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+-.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+-.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+-.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+-.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+-.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+-.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-.\"
+-.\" $OpenBSD: sshd.8,v 1.280 2015/07/03 03:49:45 djm Exp $
+-.Dd $Mdocdate: July 3 2015 $
+-.Dt SSHD 8
+-.Os
+-.Sh NAME
+-.Nm sshd
+-.Nd OpenSSH SSH daemon
+-.Sh SYNOPSIS
+-.Nm sshd
+-.Bk -words
+-.Op Fl 46DdeiqTt
+-.Op Fl b Ar bits
+-.Op Fl C Ar connection_spec
+-.Op Fl c Ar host_certificate_file
+-.Op Fl E Ar log_file
+-.Op Fl f Ar config_file
+-.Op Fl g Ar login_grace_time
+-.Op Fl h Ar host_key_file
+-.Op Fl k Ar key_gen_time
+-.Op Fl o Ar option
+-.Op Fl p Ar port
+-.Op Fl u Ar len
+-.Ek
+-.Sh DESCRIPTION
+-.Nm
+-(OpenSSH Daemon) is the daemon program for
+-.Xr ssh 1 .
+-Together these programs replace rlogin and rsh,
+-and provide secure encrypted communications between two untrusted hosts
+-over an insecure network.
+-.Pp
+-.Nm
+-listens for connections from clients.
+-It is normally started at boot from
+-.Pa /etc/rc .
+-It forks a new
+-daemon for each incoming connection.
+-The forked daemons handle
+-key exchange, encryption, authentication, command execution,
+-and data exchange.
+-.Pp
+-.Nm
+-can be configured using command-line options or a configuration file
+-(by default
+-.Xr sshd_config 5 ) ;
+-command-line options override values specified in the
+-configuration file.
+-.Nm
+-rereads its configuration file when it receives a hangup signal,
+-.Dv SIGHUP ,
+-by executing itself with the name and options it was started with, e.g.\&
+-.Pa /usr/sbin/sshd .
+-.Pp
+-The options are as follows:
+-.Bl -tag -width Ds
+-.It Fl 4
+-Forces
+-.Nm
+-to use IPv4 addresses only.
+-.It Fl 6
+-Forces
+-.Nm
+-to use IPv6 addresses only.
+-.It Fl b Ar bits
+-Specifies the number of bits in the ephemeral protocol version 1
+-server key (default 1024).
+-.It Fl C Ar connection_spec
+-Specify the connection parameters to use for the
+-.Fl T
+-extended test mode.
+-If provided, any
+-.Cm Match
+-directives in the configuration file
+-that would apply to the specified user, host, and address will be set before
+-the configuration is written to standard output.
+-The connection parameters are supplied as keyword=value pairs.
+-The keywords are
+-.Dq user ,
+-.Dq host ,
+-.Dq laddr ,
+-.Dq lport ,
+-and
+-.Dq addr .
+-All are required and may be supplied in any order, either with multiple
+-.Fl C
+-options or as a comma-separated list.
+-.It Fl c Ar host_certificate_file
+-Specifies a path to a certificate file to identify
+-.Nm
+-during key exchange.
+-The certificate file must match a host key file specified using the
+-.Fl h
+-option or the
+-.Cm HostKey
+-configuration directive.
+-.It Fl D
+-When this option is specified,
+-.Nm
+-will not detach and does not become a daemon.
+-This allows easy monitoring of
+-.Nm sshd .
+-.It Fl d
+-Debug mode.
+-The server sends verbose debug output to standard error,
+-and does not put itself in the background.
+-The server also will not fork and will only process one connection.
+-This option is only intended for debugging for the server.
+-Multiple
+-.Fl d
+-options increase the debugging level.
+-Maximum is 3.
+-.It Fl E Ar log_file
+-Append debug logs to
+-.Ar log_file
+-instead of the system log.
+-.It Fl e
+-Write debug logs to standard error instead of the system log.
+-.It Fl f Ar config_file
+-Specifies the name of the configuration file.
+-The default is
+-.Pa /etc/ssh/sshd_config .
+-.Nm
+-refuses to start if there is no configuration file.
+-.It Fl g Ar login_grace_time
+-Gives the grace time for clients to authenticate themselves (default
+-120 seconds).
+-If the client fails to authenticate the user within
+-this many seconds, the server disconnects and exits.
+-A value of zero indicates no limit.
+-.It Fl h Ar host_key_file
+-Specifies a file from which a host key is read.
+-This option must be given if
+-.Nm
+-is not run as root (as the normal
+-host key files are normally not readable by anyone but root).
+-The default is
+-.Pa /etc/ssh/ssh_host_key
+-for protocol version 1, and
+-.Pa /etc/ssh/ssh_host_dsa_key ,
+-.Pa /etc/ssh/ssh_host_ecdsa_key .
+-.Pa /etc/ssh/ssh_host_ed25519_key
+-and
+-.Pa /etc/ssh/ssh_host_rsa_key
+-for protocol version 2.
+-It is possible to have multiple host key files for
+-the different protocol versions and host key algorithms.
+-.It Fl i
+-Specifies that
+-.Nm
+-is being run from
+-.Xr inetd 8 .
+-If SSH protocol 1 is enabled,
+-.Nm
+-should not  normally be run
+-from inetd because it needs to generate the server key before it can
+-respond to the client, and this may take some time.
+-Clients may have to wait too long if the key was regenerated every time.
+-.It Fl k Ar key_gen_time
+-Specifies how often the ephemeral protocol version 1 server key is
+-regenerated (default 3600 seconds, or one hour).
+-The motivation for regenerating the key fairly
+-often is that the key is not stored anywhere, and after about an hour
+-it becomes impossible to recover the key for decrypting intercepted
+-communications even if the machine is cracked into or physically
+-seized.
+-A value of zero indicates that the key will never be regenerated.
+-.It Fl o Ar option
+-Can be used to give options in the format used in the configuration file.
+-This is useful for specifying options for which there is no separate
+-command-line flag.
+-For full details of the options, and their values, see
+-.Xr sshd_config 5 .
+-.It Fl p Ar port
+-Specifies the port on which the server listens for connections
+-(default 22).
+-Multiple port options are permitted.
+-Ports specified in the configuration file with the
+-.Cm Port
+-option are ignored when a command-line port is specified.
+-Ports specified using the
+-.Cm ListenAddress
+-option override command-line ports.
+-.It Fl q
+-Quiet mode.
+-Nothing is sent to the system log.
+-Normally the beginning,
+-authentication, and termination of each connection is logged.
+-.It Fl T
+-Extended test mode.
+-Check the validity of the configuration file, output the effective configuration
+-to stdout and then exit.
+-Optionally,
+-.Cm Match
+-rules may be applied by specifying the connection parameters using one or more
+-.Fl C
+-options.
+-.It Fl t
+-Test mode.
+-Only check the validity of the configuration file and sanity of the keys.
+-This is useful for updating
+-.Nm
+-reliably as configuration options may change.
+-.It Fl u Ar len
+-This option is used to specify the size of the field
+-in the
+-.Li utmp
+-structure that holds the remote host name.
+-If the resolved host name is longer than
+-.Ar len ,
+-the dotted decimal value will be used instead.
+-This allows hosts with very long host names that
+-overflow this field to still be uniquely identified.
+-Specifying
+-.Fl u0
+-indicates that only dotted decimal addresses
+-should be put into the
+-.Pa utmp
+-file.
+-.Fl u0
+-may also be used to prevent
+-.Nm
+-from making DNS requests unless the authentication
+-mechanism or configuration requires it.
+-Authentication mechanisms that may require DNS include
+-.Cm RhostsRSAAuthentication ,
+-.Cm HostbasedAuthentication ,
+-and using a
+-.Cm from="pattern-list"
+-option in a key file.
+-Configuration options that require DNS include using a
+-USER@HOST pattern in
+-.Cm AllowUsers
+-or
+-.Cm DenyUsers .
+-.El
+-.Sh AUTHENTICATION
+-The OpenSSH SSH daemon supports SSH protocols 1 and 2.
+-The default is to use protocol 2 only,
+-though this can be changed via the
+-.Cm Protocol
+-option in
+-.Xr sshd_config 5 .
+-Protocol 2 supports DSA, ECDSA, Ed25519 and RSA keys;
+-protocol 1 only supports RSA keys.
+-For both protocols,
+-each host has a host-specific key,
+-normally 2048 bits,
+-used to identify the host.
+-.Pp
+-Forward security for protocol 1 is provided through
+-an additional server key,
+-normally 1024 bits,
+-generated when the server starts.
+-This key is normally regenerated every hour if it has been used, and
+-is never stored on disk.
+-Whenever a client connects, the daemon responds with its public
+-host and server keys.
+-The client compares the
+-RSA host key against its own database to verify that it has not changed.
+-The client then generates a 256-bit random number.
+-It encrypts this
+-random number using both the host key and the server key, and sends
+-the encrypted number to the server.
+-Both sides then use this
+-random number as a session key which is used to encrypt all further
+-communications in the session.
+-The rest of the session is encrypted
+-using a conventional cipher, currently Blowfish or 3DES, with 3DES
+-being used by default.
+-The client selects the encryption algorithm
+-to use from those offered by the server.
+-.Pp
+-For protocol 2,
+-forward security is provided through a Diffie-Hellman key agreement.
+-This key agreement results in a shared session key.
+-The rest of the session is encrypted using a symmetric cipher, currently
+-128-bit AES, Blowfish, 3DES, CAST128, Arcfour, 192-bit AES, or 256-bit AES.
+-The client selects the encryption algorithm
+-to use from those offered by the server.
+-Additionally, session integrity is provided
+-through a cryptographic message authentication code
+-(hmac-md5, hmac-sha1, umac-64, umac-128, hmac-ripemd160,
+-hmac-sha2-256 or hmac-sha2-512).
+-.Pp
+-Finally, the server and the client enter an authentication dialog.
+-The client tries to authenticate itself using
+-host-based authentication,
+-public key authentication,
+-challenge-response authentication,
+-or password authentication.
+-.Pp
+-Regardless of the authentication type, the account is checked to
+-ensure that it is accessible.  An account is not accessible if it is
+-locked, listed in
+-.Cm DenyUsers
+-or its group is listed in
+-.Cm DenyGroups
+-\&.  The definition of a locked account is system dependant. Some platforms
+-have their own account database (eg AIX) and some modify the passwd field (
+-.Ql \&*LK\&*
+-on Solaris and UnixWare,
+-.Ql \&*
+-on HP-UX, containing
+-.Ql Nologin
+-on Tru64,
+-a leading
+-.Ql \&*LOCKED\&*
+-on FreeBSD and a leading
+-.Ql \&!
+-on most Linuxes).
+-If there is a requirement to disable password authentication
+-for the account while allowing still public-key, then the passwd field
+-should be set to something other than these values (eg
+-.Ql NP
+-or
+-.Ql \&*NP\&*
+-).
+-.Pp
+-If the client successfully authenticates itself, a dialog for
+-preparing the session is entered.
+-At this time the client may request
+-things like allocating a pseudo-tty, forwarding X11 connections,
+-forwarding TCP connections, or forwarding the authentication agent
+-connection over the secure channel.
+-.Pp
+-After this, the client either requests a shell or execution of a command.
+-The sides then enter session mode.
+-In this mode, either side may send
+-data at any time, and such data is forwarded to/from the shell or
+-command on the server side, and the user terminal in the client side.
+-.Pp
+-When the user program terminates and all forwarded X11 and other
+-connections have been closed, the server sends command exit status to
+-the client, and both sides exit.
+-.Sh LOGIN PROCESS
+-When a user successfully logs in,
+-.Nm
+-does the following:
+-.Bl -enum -offset indent
+-.It
+-If the login is on a tty, and no command has been specified,
+-prints last login time and
+-.Pa /etc/motd
+-(unless prevented in the configuration file or by
+-.Pa ~/.hushlogin ;
+-see the
+-.Sx FILES
+-section).
+-.It
+-If the login is on a tty, records login time.
+-.It
+-Checks
+-.Pa /etc/nologin ;
+-if it exists, prints contents and quits
+-(unless root).
+-.It
+-Changes to run with normal user privileges.
+-.It
+-Sets up basic environment.
+-.It
+-Reads the file
+-.Pa ~/.ssh/environment ,
+-if it exists, and users are allowed to change their environment.
+-See the
+-.Cm PermitUserEnvironment
+-option in
+-.Xr sshd_config 5 .
+-.It
+-Changes to user's home directory.
+-.It
+-If
+-.Pa ~/.ssh/rc
+-exists and the
+-.Xr sshd_config 5
+-.Cm PermitUserRC
+-option is set, runs it; else if
+-.Pa /etc/ssh/sshrc
+-exists, runs
+-it; otherwise runs xauth.
+-The
+-.Dq rc
+-files are given the X11
+-authentication protocol and cookie in standard input.
+-See
+-.Sx SSHRC ,
+-below.
+-.It
+-Runs user's shell or command.
+-All commands are run under the user's login shell as specified in the
+-system password database.
+-.El
+-.Sh SSHRC
+-If the file
+-.Pa ~/.ssh/rc
+-exists,
+-.Xr sh 1
+-runs it after reading the
+-environment files but before starting the user's shell or command.
+-It must not produce any output on stdout; stderr must be used
+-instead.
+-If X11 forwarding is in use, it will receive the "proto cookie" pair in
+-its standard input (and
+-.Ev DISPLAY
+-in its environment).
+-The script must call
+-.Xr xauth 1
+-because
+-.Nm
+-will not run xauth automatically to add X11 cookies.
+-.Pp
+-The primary purpose of this file is to run any initialization routines
+-which may be needed before the user's home directory becomes
+-accessible; AFS is a particular example of such an environment.
+-.Pp
+-This file will probably contain some initialization code followed by
+-something similar to:
+-.Bd -literal -offset 3n
+-if read proto cookie && [ -n "$DISPLAY" ]; then
+-	if [ `echo $DISPLAY | cut -c1-10` = 'localhost:' ]; then
+-		# X11UseLocalhost=yes
+-		echo add unix:`echo $DISPLAY |
+-		    cut -c11-` $proto $cookie
+-	else
+-		# X11UseLocalhost=no
+-		echo add $DISPLAY $proto $cookie
+-	fi | xauth -q -
+-fi
+-.Ed
+-.Pp
+-If this file does not exist,
+-.Pa /etc/ssh/sshrc
+-is run, and if that
+-does not exist either, xauth is used to add the cookie.
+-.Sh AUTHORIZED_KEYS FILE FORMAT
+-.Cm AuthorizedKeysFile
+-specifies the files containing public keys for
+-public key authentication;
+-if none is specified, the default is
+-.Pa ~/.ssh/authorized_keys
+-and
+-.Pa ~/.ssh/authorized_keys2 .
+-Each line of the file contains one
+-key (empty lines and lines starting with a
+-.Ql #
+-are ignored as
+-comments).
+-Protocol 1 public keys consist of the following space-separated fields:
+-options, bits, exponent, modulus, comment.
+-Protocol 2 public key consist of:
+-options, keytype, base64-encoded key, comment.
+-The options field is optional;
+-its presence is determined by whether the line starts
+-with a number or not (the options field never starts with a number).
+-The bits, exponent, modulus, and comment fields give the RSA key for
+-protocol version 1; the
+-comment field is not used for anything (but may be convenient for the
+-user to identify the key).
+-For protocol version 2 the keytype is
+-.Dq ecdsa-sha2-nistp256 ,
+-.Dq ecdsa-sha2-nistp384 ,
+-.Dq ecdsa-sha2-nistp521 ,
+-.Dq ssh-ed25519 ,
+-.Dq ssh-dss
+-or
+-.Dq ssh-rsa .
+-.Pp
+-Note that lines in this file are usually several hundred bytes long
+-(because of the size of the public key encoding) up to a limit of
+-8 kilobytes, which permits DSA keys up to 8 kilobits and RSA
+-keys up to 16 kilobits.
+-You don't want to type them in; instead, copy the
+-.Pa identity.pub ,
+-.Pa id_dsa.pub ,
+-.Pa id_ecdsa.pub ,
+-.Pa id_ed25519.pub ,
+-or the
+-.Pa id_rsa.pub
+-file and edit it.
+-.Pp
+-.Nm
+-enforces a minimum RSA key modulus size for protocol 1
+-and protocol 2 keys of 768 bits.
+-.Pp
+-The options (if present) consist of comma-separated option
+-specifications.
+-No spaces are permitted, except within double quotes.
+-The following option specifications are supported (note
+-that option keywords are case-insensitive):
+-.Bl -tag -width Ds
+-.It Cm cert-authority
+-Specifies that the listed key is a certification authority (CA) that is
+-trusted to validate signed certificates for user authentication.
+-.Pp
+-Certificates may encode access restrictions similar to these key options.
+-If both certificate restrictions and key options are present, the most
+-restrictive union of the two is applied.
+-.It Cm command="command"
+-Specifies that the command is executed whenever this key is used for
+-authentication.
+-The command supplied by the user (if any) is ignored.
+-The command is run on a pty if the client requests a pty;
+-otherwise it is run without a tty.
+-If an 8-bit clean channel is required,
+-one must not request a pty or should specify
+-.Cm no-pty .
+-A quote may be included in the command by quoting it with a backslash.
+-This option might be useful
+-to restrict certain public keys to perform just a specific operation.
+-An example might be a key that permits remote backups but nothing else.
+-Note that the client may specify TCP and/or X11
+-forwarding unless they are explicitly prohibited.
+-The command originally supplied by the client is available in the
+-.Ev SSH_ORIGINAL_COMMAND
+-environment variable.
+-Note that this option applies to shell, command or subsystem execution.
+-Also note that this command may be superseded by either a
+-.Xr sshd_config 5
+-.Cm ForceCommand
+-directive or a command embedded in a certificate.
+-.It Cm environment="NAME=value"
+-Specifies that the string is to be added to the environment when
+-logging in using this key.
+-Environment variables set this way
+-override other default environment values.
+-Multiple options of this type are permitted.
+-Environment processing is disabled by default and is
+-controlled via the
+-.Cm PermitUserEnvironment
+-option.
+-This option is automatically disabled if
+-.Cm UseLogin
+-is enabled.
+-.It Cm from="pattern-list"
+-Specifies that in addition to public key authentication, either the canonical
+-name of the remote host or its IP address must be present in the
+-comma-separated list of patterns.
+-See PATTERNS in
+-.Xr ssh_config 5
+-for more information on patterns.
+-.Pp
+-In addition to the wildcard matching that may be applied to hostnames or
+-addresses, a
+-.Cm from
+-stanza may match IP addresses using CIDR address/masklen notation.
+-.Pp
+-The purpose of this option is to optionally increase security: public key
+-authentication by itself does not trust the network or name servers or
+-anything (but the key); however, if somebody somehow steals the key, the key
+-permits an intruder to log in from anywhere in the world.
+-This additional option makes using a stolen key more difficult (name
+-servers and/or routers would have to be compromised in addition to
+-just the key).
+-.It Cm no-agent-forwarding
+-Forbids authentication agent forwarding when this key is used for
+-authentication.
+-.It Cm no-port-forwarding
+-Forbids TCP forwarding when this key is used for authentication.
+-Any port forward requests by the client will return an error.
+-This might be used, e.g. in connection with the
+-.Cm command
+-option.
+-.It Cm no-pty
+-Prevents tty allocation (a request to allocate a pty will fail).
+-.It Cm no-user-rc
+-Disables execution of
+-.Pa ~/.ssh/rc .
+-.It Cm no-X11-forwarding
+-Forbids X11 forwarding when this key is used for authentication.
+-Any X11 forward requests by the client will return an error.
+-.It Cm permitopen="host:port"
+-Limit local port forwarding with
+-.Xr ssh 1
+-.Fl L
+-such that it may only connect to the specified host and port.
+-IPv6 addresses can be specified by enclosing the address in square brackets.
+-Multiple
+-.Cm permitopen
+-options may be applied separated by commas.
+-No pattern matching is performed on the specified hostnames,
+-they must be literal domains or addresses.
+-A port specification of
+-.Cm *
+-matches any port.
+-.It Cm principals="principals"
+-On a
+-.Cm cert-authority
+-line, specifies allowed principals for certificate authentication as a
+-comma-separated list.
+-At least one name from the list must appear in the certificate's
+-list of principals for the certificate to be accepted.
+-This option is ignored for keys that are not marked as trusted certificate
+-signers using the
+-.Cm cert-authority
+-option.
+-.It Cm tunnel="n"
+-Force a
+-.Xr tun 4
+-device on the server.
+-Without this option, the next available device will be used if
+-the client requests a tunnel.
+-.El
+-.Pp
+-An example authorized_keys file:
+-.Bd -literal -offset 3n
+-# Comments allowed at start of line
+-ssh-rsa AAAAB3Nza...LiPk== user@example.net
+-from="*.sales.example.net,!pc.sales.example.net" ssh-rsa
+-AAAAB2...19Q== john@example.net
+-command="dump /home",no-pty,no-port-forwarding ssh-dss
+-AAAAC3...51R== example.net
+-permitopen="192.0.2.1:80",permitopen="192.0.2.2:25" ssh-dss
+-AAAAB5...21S==
+-tunnel="0",command="sh /etc/netstart tun0" ssh-rsa AAAA...==
+-jane@example.net
+-.Ed
+-.Sh SSH_KNOWN_HOSTS FILE FORMAT
+-The
+-.Pa /etc/ssh/ssh_known_hosts
+-and
+-.Pa ~/.ssh/known_hosts
+-files contain host public keys for all known hosts.
+-The global file should
+-be prepared by the administrator (optional), and the per-user file is
+-maintained automatically: whenever the user connects from an unknown host,
+-its key is added to the per-user file.
+-.Pp
+-Each line in these files contains the following fields: markers (optional),
+-hostnames, bits, exponent, modulus, comment.
+-The fields are separated by spaces.
+-.Pp
+-The marker is optional, but if it is present then it must be one of
+-.Dq @cert-authority ,
+-to indicate that the line contains a certification authority (CA) key,
+-or
+-.Dq @revoked ,
+-to indicate that the key contained on the line is revoked and must not ever
+-be accepted.
+-Only one marker should be used on a key line.
+-.Pp
+-Hostnames is a comma-separated list of patterns
+-.Pf ( Ql *
+-and
+-.Ql \&?
+-act as
+-wildcards); each pattern in turn is matched against the canonical host
+-name (when authenticating a client) or against the user-supplied
+-name (when authenticating a server).
+-A pattern may also be preceded by
+-.Ql \&!
+-to indicate negation: if the host name matches a negated
+-pattern, it is not accepted (by that line) even if it matched another
+-pattern on the line.
+-A hostname or address may optionally be enclosed within
+-.Ql \&[
+-and
+-.Ql \&]
+-brackets then followed by
+-.Ql \&:
+-and a non-standard port number.
+-.Pp
+-Alternately, hostnames may be stored in a hashed form which hides host names
+-and addresses should the file's contents be disclosed.
+-Hashed hostnames start with a
+-.Ql |
+-character.
+-Only one hashed hostname may appear on a single line and none of the above
+-negation or wildcard operators may be applied.
+-.Pp
+-Bits, exponent, and modulus are taken directly from the RSA host key; they
+-can be obtained, for example, from
+-.Pa /etc/ssh/ssh_host_key.pub .
+-The optional comment field continues to the end of the line, and is not used.
+-.Pp
+-Lines starting with
+-.Ql #
+-and empty lines are ignored as comments.
+-.Pp
+-When performing host authentication, authentication is accepted if any
+-matching line has the proper key; either one that matches exactly or,
+-if the server has presented a certificate for authentication, the key
+-of the certification authority that signed the certificate.
+-For a key to be trusted as a certification authority, it must use the
+-.Dq @cert-authority
+-marker described above.
+-.Pp
+-The known hosts file also provides a facility to mark keys as revoked,
+-for example when it is known that the associated private key has been
+-stolen.
+-Revoked keys are specified by including the
+-.Dq @revoked
+-marker at the beginning of the key line, and are never accepted for
+-authentication or as certification authorities, but instead will
+-produce a warning from
+-.Xr ssh 1
+-when they are encountered.
+-.Pp
+-It is permissible (but not
+-recommended) to have several lines or different host keys for the same
+-names.
+-This will inevitably happen when short forms of host names
+-from different domains are put in the file.
+-It is possible
+-that the files contain conflicting information; authentication is
+-accepted if valid information can be found from either file.
+-.Pp
+-Note that the lines in these files are typically hundreds of characters
+-long, and you definitely don't want to type in the host keys by hand.
+-Rather, generate them by a script,
+-.Xr ssh-keyscan 1
+-or by taking
+-.Pa /etc/ssh/ssh_host_key.pub
+-and adding the host names at the front.
+-.Xr ssh-keygen 1
+-also offers some basic automated editing for
+-.Pa ~/.ssh/known_hosts
+-including removing hosts matching a host name and converting all host
+-names to their hashed representations.
+-.Pp
+-An example ssh_known_hosts file:
+-.Bd -literal -offset 3n
+-# Comments allowed at start of line
+-closenet,...,192.0.2.53 1024 37 159...93 closenet.example.net
+-cvs.example.net,192.0.2.10 ssh-rsa AAAA1234.....=
+-# A hashed hostname
+-|1|JfKTdBh7rNbXkVAQCRp4OQoPfmI=|USECr3SWf1JUPsms5AqfD5QfxkM= ssh-rsa
+-AAAA1234.....=
+-# A revoked key
+-@revoked * ssh-rsa AAAAB5W...
+-# A CA key, accepted for any host in *.mydomain.com or *.mydomain.org
+-@cert-authority *.mydomain.org,*.mydomain.com ssh-rsa AAAAB5W...
+-.Ed
+-.Sh FILES
+-.Bl -tag -width Ds -compact
+-.It Pa ~/.hushlogin
+-This file is used to suppress printing the last login time and
+-.Pa /etc/motd ,
+-if
+-.Cm PrintLastLog
+-and
+-.Cm PrintMotd ,
+-respectively,
+-are enabled.
+-It does not suppress printing of the banner specified by
+-.Cm Banner .
+-.Pp
+-.It Pa ~/.rhosts
+-This file is used for host-based authentication (see
+-.Xr ssh 1
+-for more information).
+-On some machines this file may need to be
+-world-readable if the user's home directory is on an NFS partition,
+-because
+-.Nm
+-reads it as root.
+-Additionally, this file must be owned by the user,
+-and must not have write permissions for anyone else.
+-The recommended
+-permission for most machines is read/write for the user, and not
+-accessible by others.
+-.Pp
+-.It Pa ~/.shosts
+-This file is used in exactly the same way as
+-.Pa .rhosts ,
+-but allows host-based authentication without permitting login with
+-rlogin/rsh.
+-.Pp
+-.It Pa ~/.ssh/
+-This directory is the default location for all user-specific configuration
+-and authentication information.
+-There is no general requirement to keep the entire contents of this directory
+-secret, but the recommended permissions are read/write/execute for the user,
+-and not accessible by others.
+-.Pp
+-.It Pa ~/.ssh/authorized_keys
+-Lists the public keys (DSA, ECDSA, Ed25519, RSA)
+-that can be used for logging in as this user.
+-The format of this file is described above.
+-The content of the file is not highly sensitive, but the recommended
+-permissions are read/write for the user, and not accessible by others.
+-.Pp
+-If this file, the
+-.Pa ~/.ssh
+-directory, or the user's home directory are writable
+-by other users, then the file could be modified or replaced by unauthorized
+-users.
+-In this case,
+-.Nm
+-will not allow it to be used unless the
+-.Cm StrictModes
+-option has been set to
+-.Dq no .
+-.Pp
+-.It Pa ~/.ssh/environment
+-This file is read into the environment at login (if it exists).
+-It can only contain empty lines, comment lines (that start with
+-.Ql # ) ,
+-and assignment lines of the form name=value.
+-The file should be writable
+-only by the user; it need not be readable by anyone else.
+-Environment processing is disabled by default and is
+-controlled via the
+-.Cm PermitUserEnvironment
+-option.
+-.Pp
+-.It Pa ~/.ssh/known_hosts
+-Contains a list of host keys for all hosts the user has logged into
+-that are not already in the systemwide list of known host keys.
+-The format of this file is described above.
+-This file should be writable only by root/the owner and
+-can, but need not be, world-readable.
+-.Pp
+-.It Pa ~/.ssh/rc
+-Contains initialization routines to be run before
+-the user's home directory becomes accessible.
+-This file should be writable only by the user, and need not be
+-readable by anyone else.
+-.Pp
+-.It Pa /etc/hosts.equiv
+-This file is for host-based authentication (see
+-.Xr ssh 1 ) .
+-It should only be writable by root.
+-.Pp
+-.It Pa /etc/moduli
+-Contains Diffie-Hellman groups used for the "Diffie-Hellman Group Exchange".
+-The file format is described in
+-.Xr moduli 5 .
+-.Pp
+-.It Pa /etc/motd
+-See
+-.Xr motd 5 .
+-.Pp
+-.It Pa /etc/nologin
+-If this file exists,
+-.Nm
+-refuses to let anyone except root log in.
+-The contents of the file
+-are displayed to anyone trying to log in, and non-root connections are
+-refused.
+-The file should be world-readable.
+-.Pp
+-.It Pa /etc/shosts.equiv
+-This file is used in exactly the same way as
+-.Pa hosts.equiv ,
+-but allows host-based authentication without permitting login with
+-rlogin/rsh.
+-.Pp
+-.It Pa /etc/ssh/ssh_host_key
+-.It Pa /etc/ssh/ssh_host_dsa_key
+-.It Pa /etc/ssh/ssh_host_ecdsa_key
+-.It Pa /etc/ssh/ssh_host_ed25519_key
+-.It Pa /etc/ssh/ssh_host_rsa_key
+-These files contain the private parts of the host keys.
+-These files should only be owned by root, readable only by root, and not
+-accessible to others.
+-Note that
+-.Nm
+-does not start if these files are group/world-accessible.
+-.Pp
+-.It Pa /etc/ssh/ssh_host_key.pub
+-.It Pa /etc/ssh/ssh_host_dsa_key.pub
+-.It Pa /etc/ssh/ssh_host_ecdsa_key.pub
+-.It Pa /etc/ssh/ssh_host_ed25519_key.pub
+-.It Pa /etc/ssh/ssh_host_rsa_key.pub
+-These files contain the public parts of the host keys.
+-These files should be world-readable but writable only by
+-root.
+-Their contents should match the respective private parts.
+-These files are not
+-really used for anything; they are provided for the convenience of
+-the user so their contents can be copied to known hosts files.
+-These files are created using
+-.Xr ssh-keygen 1 .
+-.Pp
+-.It Pa /etc/ssh/ssh_known_hosts
+-Systemwide list of known host keys.
+-This file should be prepared by the
+-system administrator to contain the public host keys of all machines in the
+-organization.
+-The format of this file is described above.
+-This file should be writable only by root/the owner and
+-should be world-readable.
+-.Pp
+-.It Pa /etc/ssh/sshd_config
+-Contains configuration data for
+-.Nm sshd .
+-The file format and configuration options are described in
+-.Xr sshd_config 5 .
+-.Pp
+-.It Pa /etc/ssh/sshrc
+-Similar to
+-.Pa ~/.ssh/rc ,
+-it can be used to specify
+-machine-specific login-time initializations globally.
+-This file should be writable only by root, and should be world-readable.
+-.Pp
+-.It Pa /var/empty
+-.Xr chroot 2
+-directory used by
+-.Nm
+-during privilege separation in the pre-authentication phase.
+-The directory should not contain any files and must be owned by root
+-and not group or world-writable.
+-.Pp
+-.It Pa /var/run/sshd.pid
+-Contains the process ID of the
+-.Nm
+-listening for connections (if there are several daemons running
+-concurrently for different ports, this contains the process ID of the one
+-started last).
+-The content of this file is not sensitive; it can be world-readable.
+-.El
+-.Sh SEE ALSO
+-.Xr scp 1 ,
+-.Xr sftp 1 ,
+-.Xr ssh 1 ,
+-.Xr ssh-add 1 ,
+-.Xr ssh-agent 1 ,
+-.Xr ssh-keygen 1 ,
+-.Xr ssh-keyscan 1 ,
+-.Xr chroot 2 ,
+-.Xr login.conf 5 ,
+-.Xr moduli 5 ,
+-.Xr sshd_config 5 ,
+-.Xr inetd 8 ,
+-.Xr sftp-server 8
+-.Sh AUTHORS
+-OpenSSH is a derivative of the original and free
+-ssh 1.2.12 release by Tatu Ylonen.
+-Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
+-Theo de Raadt and Dug Song
+-removed many bugs, re-added newer features and
+-created OpenSSH.
+-Markus Friedl contributed the support for SSH
+-protocol versions 1.5 and 2.0.
+-Niels Provos and Markus Friedl contributed support
+-for privilege separation.
+diff --git a/sshd_config.4 b/sshd_config.4
+new file mode 100644
+index 0000000..ba4d79a
+--- /dev/null
++++ b/sshd_config.4
+@@ -0,0 +1,1736 @@
++.\"
++.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
++.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
++.\"                    All rights reserved
++.\"
++.\" As far as I am concerned, the code I have written for this software
++.\" can be used freely for any purpose.  Any derived versions of this
++.\" software must be clearly marked as such, and if the derived work is
++.\" incompatible with the protocol description in the RFC file, it must be
++.\" called by a name other than "ssh" or "Secure Shell".
++.\"
++.\" Copyright (c) 1999,2000 Markus Friedl.  All rights reserved.
++.\" Copyright (c) 1999 Aaron Campbell.  All rights reserved.
++.\" Copyright (c) 1999 Theo de Raadt.  All rights reserved.
++.\"
++.\" Redistribution and use in source and binary forms, with or without
++.\" modification, are permitted provided that the following conditions
++.\" are met:
++.\" 1. Redistributions of source code must retain the above copyright
++.\"    notice, this list of conditions and the following disclaimer.
++.\" 2. Redistributions in binary form must reproduce the above copyright
++.\"    notice, this list of conditions and the following disclaimer in the
++.\"    documentation and/or other materials provided with the distribution.
++.\"
++.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
++.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
++.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
++.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
++.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
++.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
++.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++.\"
++.\" $OpenBSD: sshd_config.5,v 1.211 2015/08/14 15:32:41 jmc Exp $
++.Dd $Mdocdate: August 14 2015 $
++.Dt SSHD_CONFIG 4
++.Os
++.Sh NAME
++.Nm sshd_config
++.Nd OpenSSH SSH daemon configuration file
++.Sh SYNOPSIS
++.Nm /etc/ssh/sshd_config
++.Sh DESCRIPTION
++.Xr sshd 1M
++reads configuration data from
++.Pa /etc/ssh/sshd_config
++(or the file specified with
++.Fl f
++on the command line).
++The file contains keyword-argument pairs, one per line.
++Lines starting with
++.Ql #
++and empty lines are interpreted as comments.
++Arguments may optionally be enclosed in double quotes
++.Pq \&"
++in order to represent arguments containing spaces.
++.Pp
++The possible
++keywords and their meanings are as follows (note that
++keywords are case-insensitive and arguments are case-sensitive):
++.Bl -tag -width Ds
++.It Cm AcceptEnv
++Specifies what environment variables sent by the client will be copied into
++the session's
++.Xr environ 7 .
++See
++.Cm SendEnv
++in
++.Xr ssh_config 4
++for how to configure the client.
++Note that environment passing is only supported for protocol 2, and
++that the
++.Ev TERM
++environment variable is always sent whenever the client
++requests a pseudo-terminal as it is required by the protocol.
++Variables are specified by name, which may contain the wildcard characters
++.Ql *
++and
++.Ql \&? .
++Multiple environment variables may be separated by whitespace or spread
++across multiple
++.Cm AcceptEnv
++directives.
++Be warned that some environment variables could be used to bypass restricted
++user environments.
++For this reason, care should be taken in the use of this directive.
++The default is not to accept any environment variables.
++.It Cm AddressFamily
++Specifies which address family should be used by
++.Xr sshd 1M .
++Valid arguments are
++.Dq any ,
++.Dq inet
++(use IPv4 only), or
++.Dq inet6
++(use IPv6 only).
++The default is
++.Dq any .
++.It Cm AllowAgentForwarding
++Specifies whether
++.Xr ssh-agent 1
++forwarding is permitted.
++The default is
++.Dq yes .
++Note that disabling agent forwarding does not improve security
++unless users are also denied shell access, as they can always install
++their own forwarders.
++.It Cm AllowGroups
++This keyword can be followed by a list of group name patterns, separated
++by spaces.
++If specified, login is allowed only for users whose primary
++group or supplementary group list matches one of the patterns.
++Only group names are valid; a numerical group ID is not recognized.
++By default, login is allowed for all groups.
++The allow/deny directives are processed in the following order:
++.Cm DenyUsers ,
++.Cm AllowUsers ,
++.Cm DenyGroups ,
++and finally
++.Cm AllowGroups .
++.Pp
++See PATTERNS in
++.Xr ssh_config 4
++for more information on patterns.
++.It Cm AllowTcpForwarding
++Specifies whether TCP forwarding is permitted.
++The available options are
++.Dq yes
++or
++.Dq all
++to allow TCP forwarding,
++.Dq no
++to prevent all TCP forwarding,
++.Dq local
++to allow local (from the perspective of
++.Xr ssh 1 )
++forwarding only or
++.Dq remote
++to allow remote forwarding only.
++The default is
++.Dq yes .
++Note that disabling TCP forwarding does not improve security unless
++users are also denied shell access, as they can always install their
++own forwarders.
++.It Cm AllowStreamLocalForwarding
++Specifies whether StreamLocal (Unix-domain socket) forwarding is permitted.
++The available options are
++.Dq yes
++or
++.Dq all
++to allow StreamLocal forwarding,
++.Dq no
++to prevent all StreamLocal forwarding,
++.Dq local
++to allow local (from the perspective of
++.Xr ssh 1 )
++forwarding only or
++.Dq remote
++to allow remote forwarding only.
++The default is
++.Dq yes .
++Note that disabling StreamLocal forwarding does not improve security unless
++users are also denied shell access, as they can always install their
++own forwarders.
++.It Cm AllowUsers
++This keyword can be followed by a list of user name patterns, separated
++by spaces.
++If specified, login is allowed only for user names that
++match one of the patterns.
++Only user names are valid; a numerical user ID is not recognized.
++By default, login is allowed for all users.
++If the pattern takes the form USER@HOST then USER and HOST
++are separately checked, restricting logins to particular
++users from particular hosts.
++The allow/deny directives are processed in the following order:
++.Cm DenyUsers ,
++.Cm AllowUsers ,
++.Cm DenyGroups ,
++and finally
++.Cm AllowGroups .
++.Pp
++See PATTERNS in
++.Xr ssh_config 4
++for more information on patterns.
++.It Cm AuthenticationMethods
++Specifies the authentication methods that must be successfully completed
++for a user to be granted access.
++This option must be followed by one or more comma-separated lists of
++authentication method names.
++Successful authentication requires completion of every method in at least
++one of these lists.
++.Pp
++For example, an argument of
++.Dq publickey,password publickey,keyboard-interactive
++would require the user to complete public key authentication, followed by
++either password or keyboard interactive authentication.
++Only methods that are next in one or more lists are offered at each stage,
++so for this example, it would not be possible to attempt password or
++keyboard-interactive authentication before public key.
++.Pp
++For keyboard interactive authentication it is also possible to
++restrict authentication to a specific device by appending a
++colon followed by the device identifier
++.Dq bsdauth ,
++.Dq pam ,
++or
++.Dq skey ,
++depending on the server configuration.
++For example,
++.Dq keyboard-interactive:bsdauth
++would restrict keyboard interactive authentication to the
++.Dq bsdauth
++device.
++.Pp
++If the
++.Dq publickey
++method is listed more than once,
++.Xr sshd 8
++verifies that keys that have been used successfully are not reused for
++subsequent authentications.
++For example, an
++.Cm AuthenticationMethods
++of
++.Dq publickey,publickey
++will require successful authentication using two different public keys.
++.Pp
++This option is only available for SSH protocol 2 and will yield a fatal
++error if enabled if protocol 1 is also enabled.
++Note that each authentication method listed should also be explicitly enabled
++in the configuration.
++The default is not to require multiple authentication; successful completion
++of a single authentication method is sufficient.
++.It Cm AuthorizedKeysCommand
++Specifies a program to be used to look up the user's public keys.
++The program must be owned by root, not writable by group or others and
++specified by an absolute path.
++.Pp
++Arguments to
++.Cm AuthorizedKeysCommand
++may be provided using the following tokens, which will be expanded
++at runtime: %% is replaced by a literal '%', %u is replaced by the
++username being authenticated, %h is replaced by the home directory
++of the user being authenticated, %t is replaced with the key type
++offered for authentication, %f is replaced with the fingerprint of
++the key, and %k is replaced with the key being offered for authentication.
++If no arguments are specified then the username of the target user
++will be supplied.
++.Pp
++The program should produce on standard output zero or
++more lines of authorized_keys output (see AUTHORIZED_KEYS in
++.Xr sshd 1M ) .
++If a key supplied by AuthorizedKeysCommand does not successfully authenticate
++and authorize the user then public key authentication continues using the usual
++.Cm AuthorizedKeysFile
++files.
++By default, no AuthorizedKeysCommand is run.
++.It Cm AuthorizedKeysCommandUser
++Specifies the user under whose account the AuthorizedKeysCommand is run.
++It is recommended to use a dedicated user that has no other role on the host
++than running authorized keys commands.
++If
++.Cm AuthorizedKeysCommand
++is specified but
++.Cm AuthorizedKeysCommandUser
++is not, then
++.Xr sshd 8
++will refuse to start.
++.It Cm AuthorizedKeysFile
++Specifies the file that contains the public keys that can be used
++for user authentication.
++The format is described in the
++AUTHORIZED_KEYS FILE FORMAT
++section of
++.Xr sshd 1M .
++.Cm AuthorizedKeysFile
++may contain tokens of the form %T which are substituted during connection
++setup.
++The following tokens are defined: %% is replaced by a literal '%',
++%h is replaced by the home directory of the user being authenticated, and
++%u is replaced by the username of that user.
++After expansion,
++.Cm AuthorizedKeysFile
++is taken to be an absolute path or one relative to the user's home
++directory.
++Multiple files may be listed, separated by whitespace.
++The default is
++.Dq .ssh/authorized_keys .ssh/authorized_keys2 .
++.It Cm AuthorizedPrincipalsCommand
++Specifies a program to be used to generate the list of allowed
++certificate principals as per
++.Cm AuthorizedPrincipalsFile .
++The program must be owned by root, not writable by group or others and
++specified by an absolute path.
++.Pp
++Arguments to
++.Cm AuthorizedPrincipalsCommand
++may be provided using the following tokens, which will be expanded
++at runtime: %% is replaced by a literal '%', %u is replaced by the
++username being authenticated and %h is replaced by the home directory
++of the user being authenticated.
++.Pp
++The program should produce on standard output zero or
++more lines of
++.Cm AuthorizedPrincipalsFile
++output.
++If either
++.Cm AuthorizedPrincipalsCommand
++or
++.Cm AuthorizedPrincipalsFile
++is specified, then certificates offered by the client for authentication
++must contain a principal that is listed.
++By default, no AuthorizedPrincipalsCommand is run.
++.It Cm AuthorizedPrincipalsCommandUser
++Specifies the user under whose account the AuthorizedPrincipalsCommand is run.
++It is recommended to use a dedicated user that has no other role on the host
++than running authorized principals commands.
++If
++.Cm AuthorizedPrincipalsCommand
++is specified but
++.Cm AuthorizedPrincipalsCommandUser
++is not, then
++.Xr sshd 8
++will refuse to start.
++.It Cm AuthorizedPrincipalsFile
++Specifies a file that lists principal names that are accepted for
++certificate authentication.
++When using certificates signed by a key listed in
++.Cm TrustedUserCAKeys ,
++this file lists names, one of which must appear in the certificate for it
++to be accepted for authentication.
++Names are listed one per line preceded by key options (as described
++in AUTHORIZED_KEYS FILE FORMAT in
++.Xr sshd 1M ) .
++Empty lines and comments starting with
++.Ql #
++are ignored.
++.Pp
++.Cm AuthorizedPrincipalsFile
++may contain tokens of the form %T which are substituted during connection
++setup.
++The following tokens are defined: %% is replaced by a literal '%',
++%h is replaced by the home directory of the user being authenticated, and
++%u is replaced by the username of that user.
++After expansion,
++.Cm AuthorizedPrincipalsFile
++is taken to be an absolute path or one relative to the user's home
++directory.
++.Pp
++The default is
++.Dq none ,
++i.e. not to use a principals file \(en in this case, the username
++of the user must appear in a certificate's principals list for it to be
++accepted.
++Note that
++.Cm AuthorizedPrincipalsFile
++is only used when authentication proceeds using a CA listed in
++.Cm TrustedUserCAKeys
++and is not consulted for certification authorities trusted via
++.Pa ~/.ssh/authorized_keys ,
++though the
++.Cm principals=
++key option offers a similar facility (see
++.Xr sshd 1M
++for details).
++.It Cm Banner
++The contents of the specified file are sent to the remote user before
++authentication is allowed.
++If the argument is
++.Dq none
++then no banner is displayed.
++This option is only available for protocol version 2.
++By default, no banner is displayed.
++.It Cm ChallengeResponseAuthentication
++Specifies whether challenge-response authentication is allowed (e.g. via
++PAM or through authentication styles supported in
++.Xr login.conf 5 )
++The default is
++.Dq yes .
++.It Cm ChrootDirectory
++Specifies the pathname of a directory to
++.Xr chroot 2
++to after authentication.
++At session startup
++.Xr sshd 8
++checks that all components of the pathname are root-owned directories
++which are not writable by any other user or group.
++After the chroot,
++.Xr sshd 1M
++changes the working directory to the user's home directory.
++.Pp
++The pathname may contain the following tokens that are expanded at runtime once
++the connecting user has been authenticated: %% is replaced by a literal '%',
++%h is replaced by the home directory of the user being authenticated, and
++%u is replaced by the username of that user.
++.Pp
++The
++.Cm ChrootDirectory
++must contain the necessary files and directories to support the
++user's session.
++For an interactive session this requires at least a shell, typically
++.Xr sh 1 ,
++and basic
++.Pa /dev
++nodes such as
++.Xr null 4 ,
++.Xr zero 4 ,
++.Xr stdin 4 ,
++.Xr stdout 4 ,
++.Xr stderr 4 ,
++and
++.Xr tty 4
++devices.
++For file transfer sessions using
++.Dq sftp ,
++no additional configuration of the environment is necessary if the
++in-process sftp server is used,
++though sessions which use logging may require
++.Pa /dev/log
++inside the chroot directory on some operating systems (see
++.Xr sftp-server 8
++for details).
++.Pp
++For safety, it is very important that the directory hierarchy be
++prevented from modification by other processes on the system (especially
++those outside the jail).
++Misconfiguration can lead to unsafe environments which
++.Xr sshd 8
++cannot detect.
++.Pp
++The default is not to
++.Xr chroot 2 .
++.It Cm Ciphers
++Specifies the ciphers allowed for protocol version 2.
++Multiple ciphers must be comma-separated.
++If the specified value begins with a
++.Sq +
++character, then the specified ciphers will be appended to the default set
++instead of replacing them.
++.Pp
++The supported ciphers are:
++.Pp
++.Bl -item -compact -offset indent
++.It
++3des-cbc
++.It
++aes128-cbc
++.It
++aes192-cbc
++.It
++aes256-cbc
++.It
++aes128-ctr
++.It
++aes192-ctr
++.It
++aes256-ctr
++.It
++aes128-gcm@openssh.com
++.It
++aes256-gcm@openssh.com
++.It
++arcfour
++.It
++arcfour128
++.It
++arcfour256
++.It
++blowfish-cbc
++.It
++cast128-cbc
++.It
++chacha20-poly1305@openssh.com
++.El
++.Pp
++The default is:
++.Bd -literal -offset indent
++chacha20-poly1305@openssh.com,
++aes128-ctr,aes192-ctr,aes256-ctr,
++aes128-gcm@openssh.com,aes256-gcm@openssh.com
++.Ed
++.Pp
++The list of available ciphers may also be obtained using the
++.Fl Q
++option of
++.Xr ssh 1
++with an argument of
++.Dq cipher .
++.It Cm ClientAliveCountMax
++Sets the number of client alive messages (see below) which may be
++sent without
++.Xr sshd 1M
++receiving any messages back from the client.
++If this threshold is reached while client alive messages are being sent,
++sshd will disconnect the client, terminating the session.
++It is important to note that the use of client alive messages is very
++different from
++.Cm TCPKeepAlive
++(below).
++The client alive messages are sent through the encrypted channel
++and therefore will not be spoofable.
++The TCP keepalive option enabled by
++.Cm TCPKeepAlive
++is spoofable.
++The client alive mechanism is valuable when the client or
++server depend on knowing when a connection has become inactive.
++.Pp
++The default value is 3.
++If
++.Cm ClientAliveInterval
++(see below) is set to 15, and
++.Cm ClientAliveCountMax
++is left at the default, unresponsive SSH clients
++will be disconnected after approximately 45 seconds.
++This option applies to protocol version 2 only.
++.It Cm ClientAliveInterval
++Sets a timeout interval in seconds after which if no data has been received
++from the client,
++.Xr sshd 1M
++will send a message through the encrypted
++channel to request a response from the client.
++The default
++is 0, indicating that these messages will not be sent to the client.
++This option applies to protocol version 2 only.
++.It Cm Compression
++Specifies whether compression is allowed, or delayed until
++the user has authenticated successfully.
++The argument must be
++.Dq yes ,
++.Dq delayed ,
++or
++.Dq no .
++The default is
++.Dq delayed .
++.It Cm DenyGroups
++This keyword can be followed by a list of group name patterns, separated
++by spaces.
++Login is disallowed for users whose primary group or supplementary
++group list matches one of the patterns.
++Only group names are valid; a numerical group ID is not recognized.
++By default, login is allowed for all groups.
++The allow/deny directives are processed in the following order:
++.Cm DenyUsers ,
++.Cm AllowUsers ,
++.Cm DenyGroups ,
++and finally
++.Cm AllowGroups .
++.Pp
++See PATTERNS in
++.Xr ssh_config 4
++for more information on patterns.
++.It Cm DenyUsers
++This keyword can be followed by a list of user name patterns, separated
++by spaces.
++Login is disallowed for user names that match one of the patterns.
++Only user names are valid; a numerical user ID is not recognized.
++By default, login is allowed for all users.
++If the pattern takes the form USER@HOST then USER and HOST
++are separately checked, restricting logins to particular
++users from particular hosts.
++The allow/deny directives are processed in the following order:
++.Cm DenyUsers ,
++.Cm AllowUsers ,
++.Cm DenyGroups ,
++and finally
++.Cm AllowGroups .
++.Pp
++See PATTERNS in
++.Xr ssh_config 4
++for more information on patterns.
++.It Cm FingerprintHash
++Specifies the hash algorithm used when logging key fingerprints.
++Valid options are:
++.Dq md5
++and
++.Dq sha256 .
++The default is
++.Dq sha256 .
++.It Cm ForceCommand
++Forces the execution of the command specified by
++.Cm ForceCommand ,
++ignoring any command supplied by the client and
++.Pa ~/.ssh/rc
++if present.
++The command is invoked by using the user's login shell with the -c option.
++This applies to shell, command, or subsystem execution.
++It is most useful inside a
++.Cm Match
++block.
++The command originally supplied by the client is available in the
++.Ev SSH_ORIGINAL_COMMAND
++environment variable.
++Specifying a command of
++.Dq internal-sftp
++will force the use of an in-process sftp server that requires no support
++files when used with
++.Cm ChrootDirectory .
++.It Cm GatewayPorts
++Specifies whether remote hosts are allowed to connect to ports
++forwarded for the client.
++By default,
++.Xr sshd 1M
++binds remote port forwardings to the loopback address.
++This prevents other remote hosts from connecting to forwarded ports.
++.Cm GatewayPorts
++can be used to specify that sshd
++should allow remote port forwardings to bind to non-loopback addresses, thus
++allowing other hosts to connect.
++The argument may be
++.Dq no
++to force remote port forwardings to be available to the local host only,
++.Dq yes
++to force remote port forwardings to bind to the wildcard address, or
++.Dq clientspecified
++to allow the client to select the address to which the forwarding is bound.
++The default is
++.Dq no .
++.It Cm GSSAPIAuthentication
++Specifies whether user authentication based on GSSAPI is allowed.
++The default is
++.Dq no .
++Note that this option applies to protocol version 2 only.
++.It Cm GSSAPICleanupCredentials
++Specifies whether to automatically destroy the user's credentials cache
++on logout.
++The default is
++.Dq yes .
++Note that this option applies to protocol version 2 only.
++.It Cm GSSAPIStrictAcceptorCheck
++Determines whether to be strict about the identity of the GSSAPI acceptor
++a client authenticates against.
++If set to
++.Dq yes
++then the client must authenticate against the
++.Pa host
++service on the current hostname.
++If set to
++.Dq no
++then the client may authenticate against any service key stored in the
++machine's default store.
++This facility is provided to assist with operation on multi homed machines.
++The default is
++.Dq yes .
++.It Cm HostbasedAcceptedKeyTypes
++Specifies the key types that will be accepted for hostbased authentication
++as a comma-separated pattern list.
++Alternately if the specified value begins with a
++.Sq +
++character, then the specified key types will be appended to the default set
++instead of replacing them.
++The default for this option is:
++.Bd -literal -offset 3n
++ecdsa-sha2-nistp256-cert-v01@openssh.com,
++ecdsa-sha2-nistp384-cert-v01@openssh.com,
++ecdsa-sha2-nistp521-cert-v01@openssh.com,
++ssh-ed25519-cert-v01@openssh.com,
++ssh-rsa-cert-v01@openssh.com,
++ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
++ssh-ed25519,ssh-rsa
++.Ed
++.Pp
++The
++.Fl Q
++option of
++.Xr ssh 1
++may be used to list supported key types.
++.It Cm HostbasedAuthentication
++Specifies whether rhosts or /etc/hosts.equiv authentication together
++with successful public key client host authentication is allowed
++(host-based authentication).
++This option is similar to
++.Cm RhostsRSAAuthentication
++and applies to protocol version 2 only.
++The default is
++.Dq no .
++.It Cm HostbasedUsesNameFromPacketOnly
++Specifies whether or not the server will attempt to perform a reverse
++name lookup when matching the name in the
++.Pa ~/.shosts ,
++.Pa ~/.rhosts ,
++and
++.Pa /etc/hosts.equiv
++files during
++.Cm HostbasedAuthentication .
++A setting of
++.Dq yes
++means that
++.Xr sshd 1M
++uses the name supplied by the client rather than
++attempting to resolve the name from the TCP connection itself.
++The default is
++.Dq no .
++.It Cm HostCertificate
++Specifies a file containing a public host certificate.
++The certificate's public key must match a private host key already specified
++by
++.Cm HostKey .
++The default behaviour of
++.Xr sshd 1M
++is not to load any certificates.
++.It Cm HostKey
++Specifies a file containing a private host key
++used by SSH.
++The default is
++.Pa /etc/ssh/ssh_host_key
++for protocol version 1, and
++.Pa /etc/ssh/ssh_host_dsa_key ,
++.Pa /etc/ssh/ssh_host_ecdsa_key ,
++.Pa /etc/ssh/ssh_host_ed25519_key
++and
++.Pa /etc/ssh/ssh_host_rsa_key
++for protocol version 2.
++.Pp
++Note that
++.Xr sshd 1M
++will refuse to use a file if it is group/world-accessible
++and that the
++.Cm HostKeyAlgorithms
++option restricts which of the keys are actually used by
++.Xr sshd 1M .
++.Pp
++It is possible to have multiple host key files.
++.Dq rsa1
++keys are used for version 1 and
++.Dq dsa ,
++.Dq ecdsa ,
++.Dq ed25519
++or
++.Dq rsa
++are used for version 2 of the SSH protocol.
++It is also possible to specify public host key files instead.
++In this case operations on the private key will be delegated
++to an
++.Xr ssh-agent 1 .
++.It Cm HostKeyAgent
++Identifies the UNIX-domain socket used to communicate
++with an agent that has access to the private host keys.
++If
++.Dq SSH_AUTH_SOCK
++is specified, the location of the socket will be read from the
++.Ev SSH_AUTH_SOCK
++environment variable.
++.It Cm HostKeyAlgorithms
++Specifies the protocol version 2 host key algorithms
++that the server offers.
++The default for this option is:
++.Bd -literal -offset 3n
++ecdsa-sha2-nistp256-cert-v01@openssh.com,
++ecdsa-sha2-nistp384-cert-v01@openssh.com,
++ecdsa-sha2-nistp521-cert-v01@openssh.com,
++ssh-ed25519-cert-v01@openssh.com,
++ssh-rsa-cert-v01@openssh.com,
++ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
++ssh-ed25519,ssh-rsa
++.Ed
++.Pp
++The list of available key types may also be obtained using the
++.Fl Q
++option of
++.Xr ssh 1
++with an argument of
++.Dq key .
++.It Cm IgnoreRhosts
++Specifies that
++.Pa .rhosts
++and
++.Pa .shosts
++files will not be used in
++.Cm RhostsRSAAuthentication
++or
++.Cm HostbasedAuthentication .
++.Pp
++.Pa /etc/hosts.equiv
++and
++.Pa /etc/shosts.equiv
++are still used.
++The default is
++.Dq yes .
++.It Cm IgnoreUserKnownHosts
++Specifies whether
++.Xr sshd 1M
++should ignore the user's
++.Pa ~/.ssh/known_hosts
++during
++.Cm RhostsRSAAuthentication
++or
++.Cm HostbasedAuthentication .
++The default is
++.Dq no .
++.It Cm IPQoS
++Specifies the IPv4 type-of-service or DSCP class for the connection.
++Accepted values are
++.Dq af11 ,
++.Dq af12 ,
++.Dq af13 ,
++.Dq af21 ,
++.Dq af22 ,
++.Dq af23 ,
++.Dq af31 ,
++.Dq af32 ,
++.Dq af33 ,
++.Dq af41 ,
++.Dq af42 ,
++.Dq af43 ,
++.Dq cs0 ,
++.Dq cs1 ,
++.Dq cs2 ,
++.Dq cs3 ,
++.Dq cs4 ,
++.Dq cs5 ,
++.Dq cs6 ,
++.Dq cs7 ,
++.Dq ef ,
++.Dq lowdelay ,
++.Dq throughput ,
++.Dq reliability ,
++or a numeric value.
++This option may take one or two arguments, separated by whitespace.
++If one argument is specified, it is used as the packet class unconditionally.
++If two values are specified, the first is automatically selected for
++interactive sessions and the second for non-interactive sessions.
++The default is
++.Dq lowdelay
++for interactive sessions and
++.Dq throughput
++for non-interactive sessions.
++.It Cm KbdInteractiveAuthentication
++Specifies whether to allow keyboard-interactive authentication.
++The argument to this keyword must be
++.Dq yes
++or
++.Dq no .
++The default is to use whatever value
++.Cm ChallengeResponseAuthentication
++is set to
++(by default
++.Dq yes ) .
++.It Cm KerberosAuthentication
++Specifies whether the password provided by the user for
++.Cm PasswordAuthentication
++will be validated through the Kerberos KDC.
++To use this option, the server needs a
++Kerberos servtab which allows the verification of the KDC's identity.
++The default is
++.Dq no .
++.It Cm KerberosGetAFSToken
++If AFS is active and the user has a Kerberos 5 TGT, attempt to acquire
++an AFS token before accessing the user's home directory.
++The default is
++.Dq no .
++.It Cm KerberosOrLocalPasswd
++If password authentication through Kerberos fails then
++the password will be validated via any additional local mechanism
++such as
++.Pa /etc/passwd .
++The default is
++.Dq yes .
++.It Cm KerberosTicketCleanup
++Specifies whether to automatically destroy the user's ticket cache
++file on logout.
++The default is
++.Dq yes .
++.It Cm KexAlgorithms
++Specifies the available KEX (Key Exchange) algorithms.
++Multiple algorithms must be comma-separated.
++Alternately if the specified value begins with a
++.Sq +
++character, then the specified methods will be appended to the default set
++instead of replacing them.
++The supported algorithms are:
++.Pp
++.Bl -item -compact -offset indent
++.It
++curve25519-sha256@libssh.org
++.It
++diffie-hellman-group1-sha1
++.It
++diffie-hellman-group14-sha1
++.It
++diffie-hellman-group-exchange-sha1
++.It
++diffie-hellman-group-exchange-sha256
++.It
++ecdh-sha2-nistp256
++.It
++ecdh-sha2-nistp384
++.It
++ecdh-sha2-nistp521
++.El
++.Pp
++The default is:
++.Bd -literal -offset indent
++curve25519-sha256@libssh.org,
++ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,
++diffie-hellman-group-exchange-sha256,
++diffie-hellman-group14-sha1
++.Ed
++.Pp
++The list of available key exchange algorithms may also be obtained using the
++.Fl Q
++option of
++.Xr ssh 1
++with an argument of
++.Dq kex .
++.It Cm KeyRegenerationInterval
++In protocol version 1, the ephemeral server key is automatically regenerated
++after this many seconds (if it has been used).
++The purpose of regeneration is to prevent
++decrypting captured sessions by later breaking into the machine and
++stealing the keys.
++The key is never stored anywhere.
++If the value is 0, the key is never regenerated.
++The default is 3600 (seconds).
++.It Cm ListenAddress
++Specifies the local addresses
++.Xr sshd 1M
++should listen on.
++The following forms may be used:
++.Pp
++.Bl -item -offset indent -compact
++.It
++.Cm ListenAddress
++.Sm off
++.Ar host | Ar IPv4_addr | Ar IPv6_addr
++.Sm on
++.It
++.Cm ListenAddress
++.Sm off
++.Ar host | Ar IPv4_addr : Ar port
++.Sm on
++.It
++.Cm ListenAddress
++.Sm off
++.Oo
++.Ar host | Ar IPv6_addr Oc : Ar port
++.Sm on
++.El
++.Pp
++If
++.Ar port
++is not specified,
++sshd will listen on the address and all
++.Cm Port
++options specified.
++The default is to listen on all local addresses.
++Multiple
++.Cm ListenAddress
++options are permitted.
++.It Cm LoginGraceTime
++The server disconnects after this time if the user has not
++successfully logged in.
++If the value is 0, there is no time limit.
++The default is 120 seconds.
++.It Cm LogLevel
++Gives the verbosity level that is used when logging messages from
++.Xr sshd 1M .
++The possible values are:
++QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3.
++The default is INFO.
++DEBUG and DEBUG1 are equivalent.
++DEBUG2 and DEBUG3 each specify higher levels of debugging output.
++Logging with a DEBUG level violates the privacy of users and is not recommended.
++.It Cm MACs
++Specifies the available MAC (message authentication code) algorithms.
++The MAC algorithm is used in protocol version 2
++for data integrity protection.
++Multiple algorithms must be comma-separated.
++If the specified value begins with a
++.Sq +
++character, then the specified algorithms will be appended to the default set
++instead of replacing them.
++.Pp
++The algorithms that contain
++.Dq -etm
++calculate the MAC after encryption (encrypt-then-mac).
++These are considered safer and their use recommended.
++The supported MACs are:
++.Pp
++.Bl -item -compact -offset indent
++.It
++hmac-md5
++.It
++hmac-md5-96
++.It
++hmac-ripemd160
++.It
++hmac-sha1
++.It
++hmac-sha1-96
++.It
++hmac-sha2-256
++.It
++hmac-sha2-512
++.It
++umac-64@openssh.com
++.It
++umac-128@openssh.com
++.It
++hmac-md5-etm@openssh.com
++.It
++hmac-md5-96-etm@openssh.com
++.It
++hmac-ripemd160-etm@openssh.com
++.It
++hmac-sha1-etm@openssh.com
++.It
++hmac-sha1-96-etm@openssh.com
++.It
++hmac-sha2-256-etm@openssh.com
++.It
++hmac-sha2-512-etm@openssh.com
++.It
++umac-64-etm@openssh.com
++.It
++umac-128-etm@openssh.com
++.El
++.Pp
++The default is:
++.Bd -literal -offset indent
++umac-64-etm@openssh.com,umac-128-etm@openssh.com,
++hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,
++umac-64@openssh.com,umac-128@openssh.com,
++hmac-sha2-256,hmac-sha2-512
++.Ed
++.Pp
++The list of available MAC algorithms may also be obtained using the
++.Fl Q
++option of
++.Xr ssh 1
++with an argument of
++.Dq mac .
++.It Cm Match
++Introduces a conditional block.
++If all of the criteria on the
++.Cm Match
++line are satisfied, the keywords on the following lines override those
++set in the global section of the config file, until either another
++.Cm Match
++line or the end of the file.
++If a keyword appears in multiple
++.Cm Match
++blocks that are satisfied, only the first instance of the keyword is
++applied.
++.Pp
++The arguments to
++.Cm Match
++are one or more criteria-pattern pairs or the single token
++.Cm All
++which matches all criteria.
++The available criteria are
++.Cm User ,
++.Cm Group ,
++.Cm Host ,
++.Cm LocalAddress ,
++.Cm LocalPort ,
++and
++.Cm Address .
++The match patterns may consist of single entries or comma-separated
++lists and may use the wildcard and negation operators described in the
++PATTERNS section of
++.Xr ssh_config 4 .
++.Pp
++The patterns in an
++.Cm Address
++criteria may additionally contain addresses to match in CIDR
++address/masklen format, e.g.\&
++.Dq 192.0.2.0/24
++or
++.Dq 3ffe:ffff::/32 .
++Note that the mask length provided must be consistent with the address -
++it is an error to specify a mask length that is too long for the address
++or one with bits set in this host portion of the address.
++For example,
++.Dq 192.0.2.0/33
++and
++.Dq 192.0.2.0/8
++respectively.
++.Pp
++Only a subset of keywords may be used on the lines following a
++.Cm Match
++keyword.
++Available keywords are
++.Cm AcceptEnv ,
++.Cm AllowAgentForwarding ,
++.Cm AllowGroups ,
++.Cm AllowStreamLocalForwarding ,
++.Cm AllowTcpForwarding ,
++.Cm AllowUsers ,
++.Cm AuthenticationMethods ,
++.Cm AuthorizedKeysCommand ,
++.Cm AuthorizedKeysCommandUser ,
++.Cm AuthorizedKeysFile ,
++.Cm AuthorizedPrincipalsFile ,
++.Cm Banner ,
++.Cm ChrootDirectory ,
++.Cm DenyGroups ,
++.Cm DenyUsers ,
++.Cm ForceCommand ,
++.Cm GatewayPorts ,
++.Cm GSSAPIAuthentication ,
++.Cm HostbasedAcceptedKeyTypes ,
++.Cm HostbasedAuthentication ,
++.Cm HostbasedUsesNameFromPacketOnly ,
++.Cm IPQoS ,
++.Cm KbdInteractiveAuthentication ,
++.Cm KerberosAuthentication ,
++.Cm MaxAuthTries ,
++.Cm MaxSessions ,
++.Cm PasswordAuthentication ,
++.Cm PermitEmptyPasswords ,
++.Cm PermitOpen ,
++.Cm PermitRootLogin ,
++.Cm PermitTTY ,
++.Cm PermitTunnel ,
++.Cm PermitUserRC ,
++.Cm PubkeyAcceptedKeyTypes ,
++.Cm PubkeyAuthentication ,
++.Cm RekeyLimit ,
++.Cm RevokedKeys ,
++.Cm RhostsRSAAuthentication ,
++.Cm RSAAuthentication ,
++.Cm StreamLocalBindMask ,
++.Cm StreamLocalBindUnlink ,
++.Cm TrustedUserCAKeys ,
++.Cm X11DisplayOffset ,
++.Cm X11Forwarding
++and
++.Cm X11UseLocalHost .
++.It Cm MaxAuthTries
++Specifies the maximum number of authentication attempts permitted per
++connection.
++Once the number of failures reaches half this value,
++additional failures are logged.
++The default is 6.
++.It Cm MaxSessions
++Specifies the maximum number of open sessions permitted per network connection.
++The default is 10.
++.It Cm MaxStartups
++Specifies the maximum number of concurrent unauthenticated connections to the
++SSH daemon.
++Additional connections will be dropped until authentication succeeds or the
++.Cm LoginGraceTime
++expires for a connection.
++The default is 10:30:100.
++.Pp
++Alternatively, random early drop can be enabled by specifying
++the three colon separated values
++.Dq start:rate:full
++(e.g. "10:30:60").
++.Xr sshd 1M
++will refuse connection attempts with a probability of
++.Dq rate/100
++(30%)
++if there are currently
++.Dq start
++(10)
++unauthenticated connections.
++The probability increases linearly and all connection attempts
++are refused if the number of unauthenticated connections reaches
++.Dq full
++(60).
++.It Cm PasswordAuthentication
++Specifies whether password authentication is allowed.
++The default is
++.Dq yes .
++.It Cm PermitEmptyPasswords
++When password authentication is allowed, it specifies whether the
++server allows login to accounts with empty password strings.
++The default is
++.Dq no .
++.It Cm PermitOpen
++Specifies the destinations to which TCP port forwarding is permitted.
++The forwarding specification must be one of the following forms:
++.Pp
++.Bl -item -offset indent -compact
++.It
++.Cm PermitOpen
++.Sm off
++.Ar host : port
++.Sm on
++.It
++.Cm PermitOpen
++.Sm off
++.Ar IPv4_addr : port
++.Sm on
++.It
++.Cm PermitOpen
++.Sm off
++.Ar \&[ IPv6_addr \&] : port
++.Sm on
++.El
++.Pp
++Multiple forwards may be specified by separating them with whitespace.
++An argument of
++.Dq any
++can be used to remove all restrictions and permit any forwarding requests.
++An argument of
++.Dq none
++can be used to prohibit all forwarding requests.
++By default all port forwarding requests are permitted.
++.It Cm PermitRootLogin
++Specifies whether root can log in using
++.Xr ssh 1 .
++The argument must be
++.Dq yes ,
++.Dq prohibit-password ,
++.Dq without-password ,
++.Dq forced-commands-only ,
++or
++.Dq no .
++The default is
++.Dq prohibit-password .
++.Pp
++If this option is set to
++.Dq prohibit-password
++or
++.Dq without-password ,
++password and keyboard-interactive authentication are disabled for root.
++.Pp
++If this option is set to
++.Dq forced-commands-only ,
++root login with public key authentication will be allowed,
++but only if the
++.Ar command
++option has been specified
++(which may be useful for taking remote backups even if root login is
++normally not allowed).
++All other authentication methods are disabled for root.
++.Pp
++If this option is set to
++.Dq no ,
++root is not allowed to log in.
++.It Cm PermitTunnel
++Specifies whether
++.Xr tun 4
++device forwarding is allowed.
++The argument must be
++.Dq yes ,
++.Dq point-to-point
++(layer 3),
++.Dq ethernet
++(layer 2), or
++.Dq no .
++Specifying
++.Dq yes
++permits both
++.Dq point-to-point
++and
++.Dq ethernet .
++The default is
++.Dq no .
++.Pp
++Independent of this setting, the permissions of the selected
++.Xr tun 4
++device must allow access to the user.
++.It Cm PermitTTY
++Specifies whether
++.Xr pty 4
++allocation is permitted.
++The default is
++.Dq yes .
++.It Cm PermitUserEnvironment
++Specifies whether
++.Pa ~/.ssh/environment
++and
++.Cm environment=
++options in
++.Pa ~/.ssh/authorized_keys
++are processed by
++.Xr sshd 1M .
++The default is
++.Dq no .
++Enabling environment processing may enable users to bypass access
++restrictions in some configurations using mechanisms such as
++.Ev LD_PRELOAD .
++.It Cm PermitUserRC
++Specifies whether any
++.Pa ~/.ssh/rc
++file is executed.
++The default is
++.Dq yes .
++.It Cm PidFile
++Specifies the file that contains the process ID of the
++SSH daemon, or
++.Dq none
++to not write one.
++The default is
++.Pa /var/run/sshd.pid .
++.It Cm Port
++Specifies the port number that
++.Xr sshd 1M
++listens on.
++The default is 22.
++Multiple options of this type are permitted.
++See also
++.Cm ListenAddress .
++.It Cm PrintLastLog
++Specifies whether
++.Xr sshd 1M
++should print the date and time of the last user login when a user logs
++in interactively.
++On Solaris this option is always ignored since pam_unix_session(5)
++reports the last login time.
++.It Cm PrintMotd
++Specifies whether
++.Xr sshd 1M
++should print
++.Pa /etc/motd
++when a user logs in interactively.
++(On some systems it is also printed by the shell,
++.Pa /etc/profile ,
++or equivalent.)
++The default is
++.Dq yes .
++.It Cm Protocol
++Specifies the protocol versions
++.Xr sshd 1M
++supports.
++The possible values are
++.Sq 1
++and
++.Sq 2 .
++Multiple versions must be comma-separated.
++The default is
++.Sq 2 .
++Note that the order of the protocol list does not indicate preference,
++because the client selects among multiple protocol versions offered
++by the server.
++Specifying
++.Dq 2,1
++is identical to
++.Dq 1,2 .
++.It Cm PubkeyAcceptedKeyTypes
++Specifies the key types that will be accepted for public key authentication
++as a comma-separated pattern list.
++Alternately if the specified value begins with a
++.Sq +
++character, then the specified key types will be appended to the default set
++instead of replacing them.
++The default for this option is:
++.Bd -literal -offset 3n
++ecdsa-sha2-nistp256-cert-v01@openssh.com,
++ecdsa-sha2-nistp384-cert-v01@openssh.com,
++ecdsa-sha2-nistp521-cert-v01@openssh.com,
++ssh-ed25519-cert-v01@openssh.com,
++ssh-rsa-cert-v01@openssh.com,
++ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
++ssh-ed25519,ssh-rsa
++.Ed
++.Pp
++The
++.Fl Q
++option of
++.Xr ssh 1
++may be used to list supported key types.
++.It Cm PubkeyAuthentication
++Specifies whether public key authentication is allowed.
++The default is
++.Dq yes .
++Note that this option applies to protocol version 2 only.
++.It Cm RekeyLimit
++Specifies the maximum amount of data that may be transmitted before the
++session key is renegotiated, optionally followed a maximum amount of
++time that may pass before the session key is renegotiated.
++The first argument is specified in bytes and may have a suffix of
++.Sq K ,
++.Sq M ,
++or
++.Sq G
++to indicate Kilobytes, Megabytes, or Gigabytes, respectively.
++The default is between
++.Sq 1G
++and
++.Sq 4G ,
++depending on the cipher.
++The optional second value is specified in seconds and may use any of the
++units documented in the
++.Sx TIME FORMATS
++section.
++The default value for
++.Cm RekeyLimit
++is
++.Dq default none ,
++which means that rekeying is performed after the cipher's default amount
++of data has been sent or received and no time based rekeying is done.
++This option applies to protocol version 2 only.
++.It Cm RevokedKeys
++Specifies revoked public keys file, or
++.Dq none
++to not use one.
++Keys listed in this file will be refused for public key authentication.
++Note that if this file is not readable, then public key authentication will
++be refused for all users.
++Keys may be specified as a text file, listing one public key per line, or as
++an OpenSSH Key Revocation List (KRL) as generated by
++.Xr ssh-keygen 1 .
++For more information on KRLs, see the KEY REVOCATION LISTS section in
++.Xr ssh-keygen 1 .
++.It Cm RhostsRSAAuthentication
++Specifies whether rhosts or /etc/hosts.equiv authentication together
++with successful RSA host authentication is allowed.
++The default is
++.Dq no .
++This option applies to protocol version 1 only.
++.It Cm RSAAuthentication
++Specifies whether pure RSA authentication is allowed.
++The default is
++.Dq yes .
++This option applies to protocol version 1 only.
++.It Cm ServerKeyBits
++Defines the number of bits in the ephemeral protocol version 1 server key.
++The default and minimum value is 1024.
++.It Cm StreamLocalBindMask
++Sets the octal file creation mode mask
++.Pq umask
++used when creating a Unix-domain socket file for local or remote
++port forwarding.
++This option is only used for port forwarding to a Unix-domain socket file.
++.Pp
++The default value is 0177, which creates a Unix-domain socket file that is
++readable and writable only by the owner.
++Note that not all operating systems honor the file mode on Unix-domain
++socket files.
++.It Cm StreamLocalBindUnlink
++Specifies whether to remove an existing Unix-domain socket file for local
++or remote port forwarding before creating a new one.
++If the socket file already exists and
++.Cm StreamLocalBindUnlink
++is not enabled,
++.Nm sshd
++will be unable to forward the port to the Unix-domain socket file.
++This option is only used for port forwarding to a Unix-domain socket file.
++.Pp
++The argument must be
++.Dq yes
++or
++.Dq no .
++The default is
++.Dq no .
++.It Cm StrictModes
++Specifies whether
++.Xr sshd 1M
++should check file modes and ownership of the
++user's files and home directory before accepting login.
++This is normally desirable because novices sometimes accidentally leave their
++directory or files world-writable.
++The default is
++.Dq yes .
++Note that this does not apply to
++.Cm ChrootDirectory ,
++whose permissions and ownership are checked unconditionally.
++.It Cm Subsystem
++Configures an external subsystem (e.g. file transfer daemon).
++Arguments should be a subsystem name and a command (with optional arguments)
++to execute upon subsystem request.
++.Pp
++The command
++.Xr sftp-server 8
++implements the
++.Dq sftp
++file transfer subsystem.
++.Pp
++Alternately the name
++.Dq internal-sftp
++implements an in-process
++.Dq sftp
++server.
++This may simplify configurations using
++.Cm ChrootDirectory
++to force a different filesystem root on clients.
++.Pp
++By default no subsystems are defined.
++Note that this option applies to protocol version 2 only.
++.It Cm SyslogFacility
++Gives the facility code that is used when logging messages from
++.Xr sshd 1M .
++The possible values are: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2,
++LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7.
++The default is AUTH.
++.It Cm TCPKeepAlive
++Specifies whether the system should send TCP keepalive messages to the
++other side.
++If they are sent, death of the connection or crash of one
++of the machines will be properly noticed.
++However, this means that
++connections will die if the route is down temporarily, and some people
++find it annoying.
++On the other hand, if TCP keepalives are not sent,
++sessions may hang indefinitely on the server, leaving
++.Dq ghost
++users and consuming server resources.
++.Pp
++The default is
++.Dq yes
++(to send TCP keepalive messages), and the server will notice
++if the network goes down or the client host crashes.
++This avoids infinitely hanging sessions.
++.Pp
++To disable TCP keepalive messages, the value should be set to
++.Dq no .
++.It Cm TrustedUserCAKeys
++Specifies a file containing public keys of certificate authorities that are
++trusted to sign user certificates for authentication, or
++.Dq none
++to not use one.
++Keys are listed one per line; empty lines and comments starting with
++.Ql #
++are allowed.
++If a certificate is presented for authentication and has its signing CA key
++listed in this file, then it may be used for authentication for any user
++listed in the certificate's principals list.
++Note that certificates that lack a list of principals will not be permitted
++for authentication using
++.Cm TrustedUserCAKeys .
++For more details on certificates, see the CERTIFICATES section in
++.Xr ssh-keygen 1 .
++.It Cm UseDNS
++Specifies whether
++.Xr sshd 1M
++should look up the remote host name, and to check that
++the resolved host name for the remote IP address maps back to the
++very same IP address.
++.Pp
++If this option is set to
++.Dq no
++(the default) then only addresses and not host names may be used in
++.Pa ~/.ssh/known_hosts
++.Cm from
++and
++.Nm
++.Cm Match
++.Cm Host
++directives.
++.It Cm UseLogin
++Specifies whether
++.Xr login 1
++is used for interactive login sessions.
++The default is
++.Dq no .
++Note that
++.Xr login 1
++is never used for remote command execution.
++Note also, that if this is enabled,
++.Cm X11Forwarding
++will be disabled because
++.Xr login 1
++does not know how to handle
++.Xr xauth 1
++cookies.
++If
++.Cm UsePrivilegeSeparation
++is specified, it will be disabled after authentication.
++.It Cm UsePAM
++Enables the Pluggable Authentication Module interface.
++If set to
++.Dq yes
++this will enable PAM authentication using
++.Cm ChallengeResponseAuthentication
++and
++.Cm PasswordAuthentication
++in addition to PAM account and session module processing for all
++authentication types.
++.Pp
++Because PAM challenge-response authentication usually serves an equivalent
++role to password authentication, you should disable either
++.Cm PasswordAuthentication
++or
++.Cm ChallengeResponseAuthentication.
++.Pp
++If
++.Cm UsePAM
++is enabled, you will not be able to run
++.Xr sshd 1M
++as a non-root user.
++The default is
++.Dq no .
++.It Cm UsePrivilegeSeparation
++Specifies whether
++.Xr sshd 1M
++separates privileges by creating an unprivileged child process
++to deal with incoming network traffic.
++After successful authentication, another process will be created that has
++the privilege of the authenticated user.
++The goal of privilege separation is to prevent privilege
++escalation by containing any corruption within the unprivileged processes.
++The default is
++.Dq yes .
++If
++.Cm UsePrivilegeSeparation
++is set to
++.Dq sandbox
++then the pre-authentication unprivileged process is subject to additional
++restrictions.
++.It Cm VersionAddendum
++Optionally specifies additional text to append to the SSH protocol banner
++sent by the server upon connection.
++The default is
++.Dq none .
++.It Cm X11DisplayOffset
++Specifies the first display number available for
++.Xr sshd 1M Ns 's
++X11 forwarding.
++This prevents sshd from interfering with real X11 servers.
++The default is 10.
++.It Cm X11Forwarding
++Specifies whether X11 forwarding is permitted.
++The argument must be
++.Dq yes
++or
++.Dq no .
++The default is
++.Dq no .
++.Pp
++When X11 forwarding is enabled, there may be additional exposure to
++the server and to client displays if the
++.Xr sshd 1M
++proxy display is configured to listen on the wildcard address (see
++.Cm X11UseLocalhost
++below), though this is not the default.
++Additionally, the authentication spoofing and authentication data
++verification and substitution occur on the client side.
++The security risk of using X11 forwarding is that the client's X11
++display server may be exposed to attack when the SSH client requests
++forwarding (see the warnings for
++.Cm ForwardX11
++in
++.Xr ssh_config 4 ) .
++A system administrator may have a stance in which they want to
++protect clients that may expose themselves to attack by unwittingly
++requesting X11 forwarding, which can warrant a
++.Dq no
++setting.
++.Pp
++Note that disabling X11 forwarding does not prevent users from
++forwarding X11 traffic, as users can always install their own forwarders.
++X11 forwarding is automatically disabled if
++.Cm UseLogin
++is enabled.
++.It Cm X11UseLocalhost
++Specifies whether
++.Xr sshd 1M
++should bind the X11 forwarding server to the loopback address or to
++the wildcard address.
++By default,
++sshd binds the forwarding server to the loopback address and sets the
++hostname part of the
++.Ev DISPLAY
++environment variable to
++.Dq localhost .
++This prevents remote hosts from connecting to the proxy display.
++However, some older X11 clients may not function with this
++configuration.
++.Cm X11UseLocalhost
++may be set to
++.Dq no
++to specify that the forwarding server should be bound to the wildcard
++address.
++The argument must be
++.Dq yes
++or
++.Dq no .
++The default is
++.Dq yes .
++.It Cm XAuthLocation
++Specifies the full pathname of the
++.Xr xauth 1
++program, or
++.Dq none
++to not use one.
++The default is
++.Pa /usr/X11R6/bin/xauth .
++.El
++.Sh TIME FORMATS
++.Xr sshd 1M
++command-line arguments and configuration file options that specify time
++may be expressed using a sequence of the form:
++.Sm off
++.Ar time Op Ar qualifier ,
++.Sm on
++where
++.Ar time
++is a positive integer value and
++.Ar qualifier
++is one of the following:
++.Pp
++.Bl -tag -width Ds -compact -offset indent
++.It Aq Cm none
++seconds
++.It Cm s | Cm S
++seconds
++.It Cm m | Cm M
++minutes
++.It Cm h | Cm H
++hours
++.It Cm d | Cm D
++days
++.It Cm w | Cm W
++weeks
++.El
++.Pp
++Each member of the sequence is added together to calculate
++the total time value.
++.Pp
++Time format examples:
++.Pp
++.Bl -tag -width Ds -compact -offset indent
++.It 600
++600 seconds (10 minutes)
++.It 10m
++10 minutes
++.It 1h30m
++1 hour 30 minutes (90 minutes)
++.El
++.Sh FILES
++.Bl -tag -width Ds
++.It Pa /etc/ssh/sshd_config
++Contains configuration data for
++.Xr sshd 1M .
++This file should be writable by root only, but it is recommended
++(though not necessary) that it be world-readable.
++.El
++.Sh SEE ALSO
++.Xr sshd 1M ,
++.Xr pam_unix_session 5
++.Sh AUTHORS
++OpenSSH is a derivative of the original and free
++ssh 1.2.12 release by Tatu Ylonen.
++Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
++Theo de Raadt and Dug Song
++removed many bugs, re-added newer features and
++created OpenSSH.
++Markus Friedl contributed the support for SSH
++protocol versions 1.5 and 2.0.
++Niels Provos and Markus Friedl contributed support
++for privilege separation.
+diff --git a/sshd_config.5 b/sshd_config.5
+deleted file mode 100644
+index 476f71c..0000000
+--- a/sshd_config.5
++++ /dev/null
+@@ -1,1736 +0,0 @@
+-.\"
+-.\" Author: Tatu Ylonen <ylo@cs.hut.fi>
+-.\" Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
+-.\"                    All rights reserved
+-.\"
+-.\" As far as I am concerned, the code I have written for this software
+-.\" can be used freely for any purpose.  Any derived versions of this
+-.\" software must be clearly marked as such, and if the derived work is
+-.\" incompatible with the protocol description in the RFC file, it must be
+-.\" called by a name other than "ssh" or "Secure Shell".
+-.\"
+-.\" Copyright (c) 1999,2000 Markus Friedl.  All rights reserved.
+-.\" Copyright (c) 1999 Aaron Campbell.  All rights reserved.
+-.\" Copyright (c) 1999 Theo de Raadt.  All rights reserved.
+-.\"
+-.\" Redistribution and use in source and binary forms, with or without
+-.\" modification, are permitted provided that the following conditions
+-.\" are met:
+-.\" 1. Redistributions of source code must retain the above copyright
+-.\"    notice, this list of conditions and the following disclaimer.
+-.\" 2. Redistributions in binary form must reproduce the above copyright
+-.\"    notice, this list of conditions and the following disclaimer in the
+-.\"    documentation and/or other materials provided with the distribution.
+-.\"
+-.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+-.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+-.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+-.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+-.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+-.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+-.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+-.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+-.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+-.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+-.\"
+-.\" $OpenBSD: sshd_config.5,v 1.211 2015/08/14 15:32:41 jmc Exp $
+-.Dd $Mdocdate: August 14 2015 $
+-.Dt SSHD_CONFIG 5
+-.Os
+-.Sh NAME
+-.Nm sshd_config
+-.Nd OpenSSH SSH daemon configuration file
+-.Sh SYNOPSIS
+-.Nm /etc/ssh/sshd_config
+-.Sh DESCRIPTION
+-.Xr sshd 8
+-reads configuration data from
+-.Pa /etc/ssh/sshd_config
+-(or the file specified with
+-.Fl f
+-on the command line).
+-The file contains keyword-argument pairs, one per line.
+-Lines starting with
+-.Ql #
+-and empty lines are interpreted as comments.
+-Arguments may optionally be enclosed in double quotes
+-.Pq \&"
+-in order to represent arguments containing spaces.
+-.Pp
+-The possible
+-keywords and their meanings are as follows (note that
+-keywords are case-insensitive and arguments are case-sensitive):
+-.Bl -tag -width Ds
+-.It Cm AcceptEnv
+-Specifies what environment variables sent by the client will be copied into
+-the session's
+-.Xr environ 7 .
+-See
+-.Cm SendEnv
+-in
+-.Xr ssh_config 5
+-for how to configure the client.
+-Note that environment passing is only supported for protocol 2, and
+-that the
+-.Ev TERM
+-environment variable is always sent whenever the client
+-requests a pseudo-terminal as it is required by the protocol.
+-Variables are specified by name, which may contain the wildcard characters
+-.Ql *
+-and
+-.Ql \&? .
+-Multiple environment variables may be separated by whitespace or spread
+-across multiple
+-.Cm AcceptEnv
+-directives.
+-Be warned that some environment variables could be used to bypass restricted
+-user environments.
+-For this reason, care should be taken in the use of this directive.
+-The default is not to accept any environment variables.
+-.It Cm AddressFamily
+-Specifies which address family should be used by
+-.Xr sshd 8 .
+-Valid arguments are
+-.Dq any ,
+-.Dq inet
+-(use IPv4 only), or
+-.Dq inet6
+-(use IPv6 only).
+-The default is
+-.Dq any .
+-.It Cm AllowAgentForwarding
+-Specifies whether
+-.Xr ssh-agent 1
+-forwarding is permitted.
+-The default is
+-.Dq yes .
+-Note that disabling agent forwarding does not improve security
+-unless users are also denied shell access, as they can always install
+-their own forwarders.
+-.It Cm AllowGroups
+-This keyword can be followed by a list of group name patterns, separated
+-by spaces.
+-If specified, login is allowed only for users whose primary
+-group or supplementary group list matches one of the patterns.
+-Only group names are valid; a numerical group ID is not recognized.
+-By default, login is allowed for all groups.
+-The allow/deny directives are processed in the following order:
+-.Cm DenyUsers ,
+-.Cm AllowUsers ,
+-.Cm DenyGroups ,
+-and finally
+-.Cm AllowGroups .
+-.Pp
+-See PATTERNS in
+-.Xr ssh_config 5
+-for more information on patterns.
+-.It Cm AllowTcpForwarding
+-Specifies whether TCP forwarding is permitted.
+-The available options are
+-.Dq yes
+-or
+-.Dq all
+-to allow TCP forwarding,
+-.Dq no
+-to prevent all TCP forwarding,
+-.Dq local
+-to allow local (from the perspective of
+-.Xr ssh 1 )
+-forwarding only or
+-.Dq remote
+-to allow remote forwarding only.
+-The default is
+-.Dq yes .
+-Note that disabling TCP forwarding does not improve security unless
+-users are also denied shell access, as they can always install their
+-own forwarders.
+-.It Cm AllowStreamLocalForwarding
+-Specifies whether StreamLocal (Unix-domain socket) forwarding is permitted.
+-The available options are
+-.Dq yes
+-or
+-.Dq all
+-to allow StreamLocal forwarding,
+-.Dq no
+-to prevent all StreamLocal forwarding,
+-.Dq local
+-to allow local (from the perspective of
+-.Xr ssh 1 )
+-forwarding only or
+-.Dq remote
+-to allow remote forwarding only.
+-The default is
+-.Dq yes .
+-Note that disabling StreamLocal forwarding does not improve security unless
+-users are also denied shell access, as they can always install their
+-own forwarders.
+-.It Cm AllowUsers
+-This keyword can be followed by a list of user name patterns, separated
+-by spaces.
+-If specified, login is allowed only for user names that
+-match one of the patterns.
+-Only user names are valid; a numerical user ID is not recognized.
+-By default, login is allowed for all users.
+-If the pattern takes the form USER@HOST then USER and HOST
+-are separately checked, restricting logins to particular
+-users from particular hosts.
+-The allow/deny directives are processed in the following order:
+-.Cm DenyUsers ,
+-.Cm AllowUsers ,
+-.Cm DenyGroups ,
+-and finally
+-.Cm AllowGroups .
+-.Pp
+-See PATTERNS in
+-.Xr ssh_config 5
+-for more information on patterns.
+-.It Cm AuthenticationMethods
+-Specifies the authentication methods that must be successfully completed
+-for a user to be granted access.
+-This option must be followed by one or more comma-separated lists of
+-authentication method names.
+-Successful authentication requires completion of every method in at least
+-one of these lists.
+-.Pp
+-For example, an argument of
+-.Dq publickey,password publickey,keyboard-interactive
+-would require the user to complete public key authentication, followed by
+-either password or keyboard interactive authentication.
+-Only methods that are next in one or more lists are offered at each stage,
+-so for this example, it would not be possible to attempt password or
+-keyboard-interactive authentication before public key.
+-.Pp
+-For keyboard interactive authentication it is also possible to
+-restrict authentication to a specific device by appending a
+-colon followed by the device identifier
+-.Dq bsdauth ,
+-.Dq pam ,
+-or
+-.Dq skey ,
+-depending on the server configuration.
+-For example,
+-.Dq keyboard-interactive:bsdauth
+-would restrict keyboard interactive authentication to the
+-.Dq bsdauth
+-device.
+-.Pp
+-If the
+-.Dq publickey
+-method is listed more than once,
+-.Xr sshd 8
+-verifies that keys that have been used successfully are not reused for
+-subsequent authentications.
+-For example, an
+-.Cm AuthenticationMethods
+-of
+-.Dq publickey,publickey
+-will require successful authentication using two different public keys.
+-.Pp
+-This option is only available for SSH protocol 2 and will yield a fatal
+-error if enabled if protocol 1 is also enabled.
+-Note that each authentication method listed should also be explicitly enabled
+-in the configuration.
+-The default is not to require multiple authentication; successful completion
+-of a single authentication method is sufficient.
+-.It Cm AuthorizedKeysCommand
+-Specifies a program to be used to look up the user's public keys.
+-The program must be owned by root, not writable by group or others and
+-specified by an absolute path.
+-.Pp
+-Arguments to
+-.Cm AuthorizedKeysCommand
+-may be provided using the following tokens, which will be expanded
+-at runtime: %% is replaced by a literal '%', %u is replaced by the
+-username being authenticated, %h is replaced by the home directory
+-of the user being authenticated, %t is replaced with the key type
+-offered for authentication, %f is replaced with the fingerprint of
+-the key, and %k is replaced with the key being offered for authentication.
+-If no arguments are specified then the username of the target user
+-will be supplied.
+-.Pp
+-The program should produce on standard output zero or
+-more lines of authorized_keys output (see AUTHORIZED_KEYS in
+-.Xr sshd 8 ) .
+-If a key supplied by AuthorizedKeysCommand does not successfully authenticate
+-and authorize the user then public key authentication continues using the usual
+-.Cm AuthorizedKeysFile
+-files.
+-By default, no AuthorizedKeysCommand is run.
+-.It Cm AuthorizedKeysCommandUser
+-Specifies the user under whose account the AuthorizedKeysCommand is run.
+-It is recommended to use a dedicated user that has no other role on the host
+-than running authorized keys commands.
+-If
+-.Cm AuthorizedKeysCommand
+-is specified but
+-.Cm AuthorizedKeysCommandUser
+-is not, then
+-.Xr sshd 8
+-will refuse to start.
+-.It Cm AuthorizedKeysFile
+-Specifies the file that contains the public keys that can be used
+-for user authentication.
+-The format is described in the
+-AUTHORIZED_KEYS FILE FORMAT
+-section of
+-.Xr sshd 8 .
+-.Cm AuthorizedKeysFile
+-may contain tokens of the form %T which are substituted during connection
+-setup.
+-The following tokens are defined: %% is replaced by a literal '%',
+-%h is replaced by the home directory of the user being authenticated, and
+-%u is replaced by the username of that user.
+-After expansion,
+-.Cm AuthorizedKeysFile
+-is taken to be an absolute path or one relative to the user's home
+-directory.
+-Multiple files may be listed, separated by whitespace.
+-The default is
+-.Dq .ssh/authorized_keys .ssh/authorized_keys2 .
+-.It Cm AuthorizedPrincipalsCommand
+-Specifies a program to be used to generate the list of allowed
+-certificate principals as per
+-.Cm AuthorizedPrincipalsFile .
+-The program must be owned by root, not writable by group or others and
+-specified by an absolute path.
+-.Pp
+-Arguments to
+-.Cm AuthorizedPrincipalsCommand
+-may be provided using the following tokens, which will be expanded
+-at runtime: %% is replaced by a literal '%', %u is replaced by the
+-username being authenticated and %h is replaced by the home directory
+-of the user being authenticated.
+-.Pp
+-The program should produce on standard output zero or
+-more lines of
+-.Cm AuthorizedPrincipalsFile
+-output.
+-If either
+-.Cm AuthorizedPrincipalsCommand
+-or
+-.Cm AuthorizedPrincipalsFile
+-is specified, then certificates offered by the client for authentication
+-must contain a principal that is listed.
+-By default, no AuthorizedPrincipalsCommand is run.
+-.It Cm AuthorizedPrincipalsCommandUser
+-Specifies the user under whose account the AuthorizedPrincipalsCommand is run.
+-It is recommended to use a dedicated user that has no other role on the host
+-than running authorized principals commands.
+-If
+-.Cm AuthorizedPrincipalsCommand
+-is specified but
+-.Cm AuthorizedPrincipalsCommandUser
+-is not, then
+-.Xr sshd 8
+-will refuse to start.
+-.It Cm AuthorizedPrincipalsFile
+-Specifies a file that lists principal names that are accepted for
+-certificate authentication.
+-When using certificates signed by a key listed in
+-.Cm TrustedUserCAKeys ,
+-this file lists names, one of which must appear in the certificate for it
+-to be accepted for authentication.
+-Names are listed one per line preceded by key options (as described
+-in AUTHORIZED_KEYS FILE FORMAT in
+-.Xr sshd 8 ) .
+-Empty lines and comments starting with
+-.Ql #
+-are ignored.
+-.Pp
+-.Cm AuthorizedPrincipalsFile
+-may contain tokens of the form %T which are substituted during connection
+-setup.
+-The following tokens are defined: %% is replaced by a literal '%',
+-%h is replaced by the home directory of the user being authenticated, and
+-%u is replaced by the username of that user.
+-After expansion,
+-.Cm AuthorizedPrincipalsFile
+-is taken to be an absolute path or one relative to the user's home
+-directory.
+-.Pp
+-The default is
+-.Dq none ,
+-i.e. not to use a principals file \(en in this case, the username
+-of the user must appear in a certificate's principals list for it to be
+-accepted.
+-Note that
+-.Cm AuthorizedPrincipalsFile
+-is only used when authentication proceeds using a CA listed in
+-.Cm TrustedUserCAKeys
+-and is not consulted for certification authorities trusted via
+-.Pa ~/.ssh/authorized_keys ,
+-though the
+-.Cm principals=
+-key option offers a similar facility (see
+-.Xr sshd 8
+-for details).
+-.It Cm Banner
+-The contents of the specified file are sent to the remote user before
+-authentication is allowed.
+-If the argument is
+-.Dq none
+-then no banner is displayed.
+-This option is only available for protocol version 2.
+-By default, no banner is displayed.
+-.It Cm ChallengeResponseAuthentication
+-Specifies whether challenge-response authentication is allowed (e.g. via
+-PAM or through authentication styles supported in
+-.Xr login.conf 5 )
+-The default is
+-.Dq yes .
+-.It Cm ChrootDirectory
+-Specifies the pathname of a directory to
+-.Xr chroot 2
+-to after authentication.
+-At session startup
+-.Xr sshd 8
+-checks that all components of the pathname are root-owned directories
+-which are not writable by any other user or group.
+-After the chroot,
+-.Xr sshd 8
+-changes the working directory to the user's home directory.
+-.Pp
+-The pathname may contain the following tokens that are expanded at runtime once
+-the connecting user has been authenticated: %% is replaced by a literal '%',
+-%h is replaced by the home directory of the user being authenticated, and
+-%u is replaced by the username of that user.
+-.Pp
+-The
+-.Cm ChrootDirectory
+-must contain the necessary files and directories to support the
+-user's session.
+-For an interactive session this requires at least a shell, typically
+-.Xr sh 1 ,
+-and basic
+-.Pa /dev
+-nodes such as
+-.Xr null 4 ,
+-.Xr zero 4 ,
+-.Xr stdin 4 ,
+-.Xr stdout 4 ,
+-.Xr stderr 4 ,
+-and
+-.Xr tty 4
+-devices.
+-For file transfer sessions using
+-.Dq sftp ,
+-no additional configuration of the environment is necessary if the
+-in-process sftp server is used,
+-though sessions which use logging may require
+-.Pa /dev/log
+-inside the chroot directory on some operating systems (see
+-.Xr sftp-server 8
+-for details).
+-.Pp
+-For safety, it is very important that the directory hierarchy be
+-prevented from modification by other processes on the system (especially
+-those outside the jail).
+-Misconfiguration can lead to unsafe environments which
+-.Xr sshd 8
+-cannot detect.
+-.Pp
+-The default is not to
+-.Xr chroot 2 .
+-.It Cm Ciphers
+-Specifies the ciphers allowed for protocol version 2.
+-Multiple ciphers must be comma-separated.
+-If the specified value begins with a
+-.Sq +
+-character, then the specified ciphers will be appended to the default set
+-instead of replacing them.
+-.Pp
+-The supported ciphers are:
+-.Pp
+-.Bl -item -compact -offset indent
+-.It
+-3des-cbc
+-.It
+-aes128-cbc
+-.It
+-aes192-cbc
+-.It
+-aes256-cbc
+-.It
+-aes128-ctr
+-.It
+-aes192-ctr
+-.It
+-aes256-ctr
+-.It
+-aes128-gcm@openssh.com
+-.It
+-aes256-gcm@openssh.com
+-.It
+-arcfour
+-.It
+-arcfour128
+-.It
+-arcfour256
+-.It
+-blowfish-cbc
+-.It
+-cast128-cbc
+-.It
+-chacha20-poly1305@openssh.com
+-.El
+-.Pp
+-The default is:
+-.Bd -literal -offset indent
+-chacha20-poly1305@openssh.com,
+-aes128-ctr,aes192-ctr,aes256-ctr,
+-aes128-gcm@openssh.com,aes256-gcm@openssh.com
+-.Ed
+-.Pp
+-The list of available ciphers may also be obtained using the
+-.Fl Q
+-option of
+-.Xr ssh 1
+-with an argument of
+-.Dq cipher .
+-.It Cm ClientAliveCountMax
+-Sets the number of client alive messages (see below) which may be
+-sent without
+-.Xr sshd 8
+-receiving any messages back from the client.
+-If this threshold is reached while client alive messages are being sent,
+-sshd will disconnect the client, terminating the session.
+-It is important to note that the use of client alive messages is very
+-different from
+-.Cm TCPKeepAlive
+-(below).
+-The client alive messages are sent through the encrypted channel
+-and therefore will not be spoofable.
+-The TCP keepalive option enabled by
+-.Cm TCPKeepAlive
+-is spoofable.
+-The client alive mechanism is valuable when the client or
+-server depend on knowing when a connection has become inactive.
+-.Pp
+-The default value is 3.
+-If
+-.Cm ClientAliveInterval
+-(see below) is set to 15, and
+-.Cm ClientAliveCountMax
+-is left at the default, unresponsive SSH clients
+-will be disconnected after approximately 45 seconds.
+-This option applies to protocol version 2 only.
+-.It Cm ClientAliveInterval
+-Sets a timeout interval in seconds after which if no data has been received
+-from the client,
+-.Xr sshd 8
+-will send a message through the encrypted
+-channel to request a response from the client.
+-The default
+-is 0, indicating that these messages will not be sent to the client.
+-This option applies to protocol version 2 only.
+-.It Cm Compression
+-Specifies whether compression is allowed, or delayed until
+-the user has authenticated successfully.
+-The argument must be
+-.Dq yes ,
+-.Dq delayed ,
+-or
+-.Dq no .
+-The default is
+-.Dq delayed .
+-.It Cm DenyGroups
+-This keyword can be followed by a list of group name patterns, separated
+-by spaces.
+-Login is disallowed for users whose primary group or supplementary
+-group list matches one of the patterns.
+-Only group names are valid; a numerical group ID is not recognized.
+-By default, login is allowed for all groups.
+-The allow/deny directives are processed in the following order:
+-.Cm DenyUsers ,
+-.Cm AllowUsers ,
+-.Cm DenyGroups ,
+-and finally
+-.Cm AllowGroups .
+-.Pp
+-See PATTERNS in
+-.Xr ssh_config 5
+-for more information on patterns.
+-.It Cm DenyUsers
+-This keyword can be followed by a list of user name patterns, separated
+-by spaces.
+-Login is disallowed for user names that match one of the patterns.
+-Only user names are valid; a numerical user ID is not recognized.
+-By default, login is allowed for all users.
+-If the pattern takes the form USER@HOST then USER and HOST
+-are separately checked, restricting logins to particular
+-users from particular hosts.
+-The allow/deny directives are processed in the following order:
+-.Cm DenyUsers ,
+-.Cm AllowUsers ,
+-.Cm DenyGroups ,
+-and finally
+-.Cm AllowGroups .
+-.Pp
+-See PATTERNS in
+-.Xr ssh_config 5
+-for more information on patterns.
+-.It Cm FingerprintHash
+-Specifies the hash algorithm used when logging key fingerprints.
+-Valid options are:
+-.Dq md5
+-and
+-.Dq sha256 .
+-The default is
+-.Dq sha256 .
+-.It Cm ForceCommand
+-Forces the execution of the command specified by
+-.Cm ForceCommand ,
+-ignoring any command supplied by the client and
+-.Pa ~/.ssh/rc
+-if present.
+-The command is invoked by using the user's login shell with the -c option.
+-This applies to shell, command, or subsystem execution.
+-It is most useful inside a
+-.Cm Match
+-block.
+-The command originally supplied by the client is available in the
+-.Ev SSH_ORIGINAL_COMMAND
+-environment variable.
+-Specifying a command of
+-.Dq internal-sftp
+-will force the use of an in-process sftp server that requires no support
+-files when used with
+-.Cm ChrootDirectory .
+-.It Cm GatewayPorts
+-Specifies whether remote hosts are allowed to connect to ports
+-forwarded for the client.
+-By default,
+-.Xr sshd 8
+-binds remote port forwardings to the loopback address.
+-This prevents other remote hosts from connecting to forwarded ports.
+-.Cm GatewayPorts
+-can be used to specify that sshd
+-should allow remote port forwardings to bind to non-loopback addresses, thus
+-allowing other hosts to connect.
+-The argument may be
+-.Dq no
+-to force remote port forwardings to be available to the local host only,
+-.Dq yes
+-to force remote port forwardings to bind to the wildcard address, or
+-.Dq clientspecified
+-to allow the client to select the address to which the forwarding is bound.
+-The default is
+-.Dq no .
+-.It Cm GSSAPIAuthentication
+-Specifies whether user authentication based on GSSAPI is allowed.
+-The default is
+-.Dq no .
+-Note that this option applies to protocol version 2 only.
+-.It Cm GSSAPICleanupCredentials
+-Specifies whether to automatically destroy the user's credentials cache
+-on logout.
+-The default is
+-.Dq yes .
+-Note that this option applies to protocol version 2 only.
+-.It Cm GSSAPIStrictAcceptorCheck
+-Determines whether to be strict about the identity of the GSSAPI acceptor
+-a client authenticates against.
+-If set to
+-.Dq yes
+-then the client must authenticate against the
+-.Pa host
+-service on the current hostname.
+-If set to
+-.Dq no
+-then the client may authenticate against any service key stored in the
+-machine's default store.
+-This facility is provided to assist with operation on multi homed machines.
+-The default is
+-.Dq yes .
+-.It Cm HostbasedAcceptedKeyTypes
+-Specifies the key types that will be accepted for hostbased authentication
+-as a comma-separated pattern list.
+-Alternately if the specified value begins with a
+-.Sq +
+-character, then the specified key types will be appended to the default set
+-instead of replacing them.
+-The default for this option is:
+-.Bd -literal -offset 3n
+-ecdsa-sha2-nistp256-cert-v01@openssh.com,
+-ecdsa-sha2-nistp384-cert-v01@openssh.com,
+-ecdsa-sha2-nistp521-cert-v01@openssh.com,
+-ssh-ed25519-cert-v01@openssh.com,
+-ssh-rsa-cert-v01@openssh.com,
+-ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
+-ssh-ed25519,ssh-rsa
+-.Ed
+-.Pp
+-The
+-.Fl Q
+-option of
+-.Xr ssh 1
+-may be used to list supported key types.
+-.It Cm HostbasedAuthentication
+-Specifies whether rhosts or /etc/hosts.equiv authentication together
+-with successful public key client host authentication is allowed
+-(host-based authentication).
+-This option is similar to
+-.Cm RhostsRSAAuthentication
+-and applies to protocol version 2 only.
+-The default is
+-.Dq no .
+-.It Cm HostbasedUsesNameFromPacketOnly
+-Specifies whether or not the server will attempt to perform a reverse
+-name lookup when matching the name in the
+-.Pa ~/.shosts ,
+-.Pa ~/.rhosts ,
+-and
+-.Pa /etc/hosts.equiv
+-files during
+-.Cm HostbasedAuthentication .
+-A setting of
+-.Dq yes
+-means that
+-.Xr sshd 8
+-uses the name supplied by the client rather than
+-attempting to resolve the name from the TCP connection itself.
+-The default is
+-.Dq no .
+-.It Cm HostCertificate
+-Specifies a file containing a public host certificate.
+-The certificate's public key must match a private host key already specified
+-by
+-.Cm HostKey .
+-The default behaviour of
+-.Xr sshd 8
+-is not to load any certificates.
+-.It Cm HostKey
+-Specifies a file containing a private host key
+-used by SSH.
+-The default is
+-.Pa /etc/ssh/ssh_host_key
+-for protocol version 1, and
+-.Pa /etc/ssh/ssh_host_dsa_key ,
+-.Pa /etc/ssh/ssh_host_ecdsa_key ,
+-.Pa /etc/ssh/ssh_host_ed25519_key
+-and
+-.Pa /etc/ssh/ssh_host_rsa_key
+-for protocol version 2.
+-.Pp
+-Note that
+-.Xr sshd 8
+-will refuse to use a file if it is group/world-accessible
+-and that the
+-.Cm HostKeyAlgorithms
+-option restricts which of the keys are actually used by
+-.Xr sshd 8 .
+-.Pp
+-It is possible to have multiple host key files.
+-.Dq rsa1
+-keys are used for version 1 and
+-.Dq dsa ,
+-.Dq ecdsa ,
+-.Dq ed25519
+-or
+-.Dq rsa
+-are used for version 2 of the SSH protocol.
+-It is also possible to specify public host key files instead.
+-In this case operations on the private key will be delegated
+-to an
+-.Xr ssh-agent 1 .
+-.It Cm HostKeyAgent
+-Identifies the UNIX-domain socket used to communicate
+-with an agent that has access to the private host keys.
+-If
+-.Dq SSH_AUTH_SOCK
+-is specified, the location of the socket will be read from the
+-.Ev SSH_AUTH_SOCK
+-environment variable.
+-.It Cm HostKeyAlgorithms
+-Specifies the protocol version 2 host key algorithms
+-that the server offers.
+-The default for this option is:
+-.Bd -literal -offset 3n
+-ecdsa-sha2-nistp256-cert-v01@openssh.com,
+-ecdsa-sha2-nistp384-cert-v01@openssh.com,
+-ecdsa-sha2-nistp521-cert-v01@openssh.com,
+-ssh-ed25519-cert-v01@openssh.com,
+-ssh-rsa-cert-v01@openssh.com,
+-ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
+-ssh-ed25519,ssh-rsa
+-.Ed
+-.Pp
+-The list of available key types may also be obtained using the
+-.Fl Q
+-option of
+-.Xr ssh 1
+-with an argument of
+-.Dq key .
+-.It Cm IgnoreRhosts
+-Specifies that
+-.Pa .rhosts
+-and
+-.Pa .shosts
+-files will not be used in
+-.Cm RhostsRSAAuthentication
+-or
+-.Cm HostbasedAuthentication .
+-.Pp
+-.Pa /etc/hosts.equiv
+-and
+-.Pa /etc/shosts.equiv
+-are still used.
+-The default is
+-.Dq yes .
+-.It Cm IgnoreUserKnownHosts
+-Specifies whether
+-.Xr sshd 8
+-should ignore the user's
+-.Pa ~/.ssh/known_hosts
+-during
+-.Cm RhostsRSAAuthentication
+-or
+-.Cm HostbasedAuthentication .
+-The default is
+-.Dq no .
+-.It Cm IPQoS
+-Specifies the IPv4 type-of-service or DSCP class for the connection.
+-Accepted values are
+-.Dq af11 ,
+-.Dq af12 ,
+-.Dq af13 ,
+-.Dq af21 ,
+-.Dq af22 ,
+-.Dq af23 ,
+-.Dq af31 ,
+-.Dq af32 ,
+-.Dq af33 ,
+-.Dq af41 ,
+-.Dq af42 ,
+-.Dq af43 ,
+-.Dq cs0 ,
+-.Dq cs1 ,
+-.Dq cs2 ,
+-.Dq cs3 ,
+-.Dq cs4 ,
+-.Dq cs5 ,
+-.Dq cs6 ,
+-.Dq cs7 ,
+-.Dq ef ,
+-.Dq lowdelay ,
+-.Dq throughput ,
+-.Dq reliability ,
+-or a numeric value.
+-This option may take one or two arguments, separated by whitespace.
+-If one argument is specified, it is used as the packet class unconditionally.
+-If two values are specified, the first is automatically selected for
+-interactive sessions and the second for non-interactive sessions.
+-The default is
+-.Dq lowdelay
+-for interactive sessions and
+-.Dq throughput
+-for non-interactive sessions.
+-.It Cm KbdInteractiveAuthentication
+-Specifies whether to allow keyboard-interactive authentication.
+-The argument to this keyword must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is to use whatever value
+-.Cm ChallengeResponseAuthentication
+-is set to
+-(by default
+-.Dq yes ) .
+-.It Cm KerberosAuthentication
+-Specifies whether the password provided by the user for
+-.Cm PasswordAuthentication
+-will be validated through the Kerberos KDC.
+-To use this option, the server needs a
+-Kerberos servtab which allows the verification of the KDC's identity.
+-The default is
+-.Dq no .
+-.It Cm KerberosGetAFSToken
+-If AFS is active and the user has a Kerberos 5 TGT, attempt to acquire
+-an AFS token before accessing the user's home directory.
+-The default is
+-.Dq no .
+-.It Cm KerberosOrLocalPasswd
+-If password authentication through Kerberos fails then
+-the password will be validated via any additional local mechanism
+-such as
+-.Pa /etc/passwd .
+-The default is
+-.Dq yes .
+-.It Cm KerberosTicketCleanup
+-Specifies whether to automatically destroy the user's ticket cache
+-file on logout.
+-The default is
+-.Dq yes .
+-.It Cm KexAlgorithms
+-Specifies the available KEX (Key Exchange) algorithms.
+-Multiple algorithms must be comma-separated.
+-Alternately if the specified value begins with a
+-.Sq +
+-character, then the specified methods will be appended to the default set
+-instead of replacing them.
+-The supported algorithms are:
+-.Pp
+-.Bl -item -compact -offset indent
+-.It
+-curve25519-sha256@libssh.org
+-.It
+-diffie-hellman-group1-sha1
+-.It
+-diffie-hellman-group14-sha1
+-.It
+-diffie-hellman-group-exchange-sha1
+-.It
+-diffie-hellman-group-exchange-sha256
+-.It
+-ecdh-sha2-nistp256
+-.It
+-ecdh-sha2-nistp384
+-.It
+-ecdh-sha2-nistp521
+-.El
+-.Pp
+-The default is:
+-.Bd -literal -offset indent
+-curve25519-sha256@libssh.org,
+-ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,
+-diffie-hellman-group-exchange-sha256,
+-diffie-hellman-group14-sha1
+-.Ed
+-.Pp
+-The list of available key exchange algorithms may also be obtained using the
+-.Fl Q
+-option of
+-.Xr ssh 1
+-with an argument of
+-.Dq kex .
+-.It Cm KeyRegenerationInterval
+-In protocol version 1, the ephemeral server key is automatically regenerated
+-after this many seconds (if it has been used).
+-The purpose of regeneration is to prevent
+-decrypting captured sessions by later breaking into the machine and
+-stealing the keys.
+-The key is never stored anywhere.
+-If the value is 0, the key is never regenerated.
+-The default is 3600 (seconds).
+-.It Cm ListenAddress
+-Specifies the local addresses
+-.Xr sshd 8
+-should listen on.
+-The following forms may be used:
+-.Pp
+-.Bl -item -offset indent -compact
+-.It
+-.Cm ListenAddress
+-.Sm off
+-.Ar host | Ar IPv4_addr | Ar IPv6_addr
+-.Sm on
+-.It
+-.Cm ListenAddress
+-.Sm off
+-.Ar host | Ar IPv4_addr : Ar port
+-.Sm on
+-.It
+-.Cm ListenAddress
+-.Sm off
+-.Oo
+-.Ar host | Ar IPv6_addr Oc : Ar port
+-.Sm on
+-.El
+-.Pp
+-If
+-.Ar port
+-is not specified,
+-sshd will listen on the address and all
+-.Cm Port
+-options specified.
+-The default is to listen on all local addresses.
+-Multiple
+-.Cm ListenAddress
+-options are permitted.
+-.It Cm LoginGraceTime
+-The server disconnects after this time if the user has not
+-successfully logged in.
+-If the value is 0, there is no time limit.
+-The default is 120 seconds.
+-.It Cm LogLevel
+-Gives the verbosity level that is used when logging messages from
+-.Xr sshd 8 .
+-The possible values are:
+-QUIET, FATAL, ERROR, INFO, VERBOSE, DEBUG, DEBUG1, DEBUG2, and DEBUG3.
+-The default is INFO.
+-DEBUG and DEBUG1 are equivalent.
+-DEBUG2 and DEBUG3 each specify higher levels of debugging output.
+-Logging with a DEBUG level violates the privacy of users and is not recommended.
+-.It Cm MACs
+-Specifies the available MAC (message authentication code) algorithms.
+-The MAC algorithm is used in protocol version 2
+-for data integrity protection.
+-Multiple algorithms must be comma-separated.
+-If the specified value begins with a
+-.Sq +
+-character, then the specified algorithms will be appended to the default set
+-instead of replacing them.
+-.Pp
+-The algorithms that contain
+-.Dq -etm
+-calculate the MAC after encryption (encrypt-then-mac).
+-These are considered safer and their use recommended.
+-The supported MACs are:
+-.Pp
+-.Bl -item -compact -offset indent
+-.It
+-hmac-md5
+-.It
+-hmac-md5-96
+-.It
+-hmac-ripemd160
+-.It
+-hmac-sha1
+-.It
+-hmac-sha1-96
+-.It
+-hmac-sha2-256
+-.It
+-hmac-sha2-512
+-.It
+-umac-64@openssh.com
+-.It
+-umac-128@openssh.com
+-.It
+-hmac-md5-etm@openssh.com
+-.It
+-hmac-md5-96-etm@openssh.com
+-.It
+-hmac-ripemd160-etm@openssh.com
+-.It
+-hmac-sha1-etm@openssh.com
+-.It
+-hmac-sha1-96-etm@openssh.com
+-.It
+-hmac-sha2-256-etm@openssh.com
+-.It
+-hmac-sha2-512-etm@openssh.com
+-.It
+-umac-64-etm@openssh.com
+-.It
+-umac-128-etm@openssh.com
+-.El
+-.Pp
+-The default is:
+-.Bd -literal -offset indent
+-umac-64-etm@openssh.com,umac-128-etm@openssh.com,
+-hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,
+-umac-64@openssh.com,umac-128@openssh.com,
+-hmac-sha2-256,hmac-sha2-512
+-.Ed
+-.Pp
+-The list of available MAC algorithms may also be obtained using the
+-.Fl Q
+-option of
+-.Xr ssh 1
+-with an argument of
+-.Dq mac .
+-.It Cm Match
+-Introduces a conditional block.
+-If all of the criteria on the
+-.Cm Match
+-line are satisfied, the keywords on the following lines override those
+-set in the global section of the config file, until either another
+-.Cm Match
+-line or the end of the file.
+-If a keyword appears in multiple
+-.Cm Match
+-blocks that are satisfied, only the first instance of the keyword is
+-applied.
+-.Pp
+-The arguments to
+-.Cm Match
+-are one or more criteria-pattern pairs or the single token
+-.Cm All
+-which matches all criteria.
+-The available criteria are
+-.Cm User ,
+-.Cm Group ,
+-.Cm Host ,
+-.Cm LocalAddress ,
+-.Cm LocalPort ,
+-and
+-.Cm Address .
+-The match patterns may consist of single entries or comma-separated
+-lists and may use the wildcard and negation operators described in the
+-PATTERNS section of
+-.Xr ssh_config 5 .
+-.Pp
+-The patterns in an
+-.Cm Address
+-criteria may additionally contain addresses to match in CIDR
+-address/masklen format, e.g.\&
+-.Dq 192.0.2.0/24
+-or
+-.Dq 3ffe:ffff::/32 .
+-Note that the mask length provided must be consistent with the address -
+-it is an error to specify a mask length that is too long for the address
+-or one with bits set in this host portion of the address.
+-For example,
+-.Dq 192.0.2.0/33
+-and
+-.Dq 192.0.2.0/8
+-respectively.
+-.Pp
+-Only a subset of keywords may be used on the lines following a
+-.Cm Match
+-keyword.
+-Available keywords are
+-.Cm AcceptEnv ,
+-.Cm AllowAgentForwarding ,
+-.Cm AllowGroups ,
+-.Cm AllowStreamLocalForwarding ,
+-.Cm AllowTcpForwarding ,
+-.Cm AllowUsers ,
+-.Cm AuthenticationMethods ,
+-.Cm AuthorizedKeysCommand ,
+-.Cm AuthorizedKeysCommandUser ,
+-.Cm AuthorizedKeysFile ,
+-.Cm AuthorizedPrincipalsFile ,
+-.Cm Banner ,
+-.Cm ChrootDirectory ,
+-.Cm DenyGroups ,
+-.Cm DenyUsers ,
+-.Cm ForceCommand ,
+-.Cm GatewayPorts ,
+-.Cm GSSAPIAuthentication ,
+-.Cm HostbasedAcceptedKeyTypes ,
+-.Cm HostbasedAuthentication ,
+-.Cm HostbasedUsesNameFromPacketOnly ,
+-.Cm IPQoS ,
+-.Cm KbdInteractiveAuthentication ,
+-.Cm KerberosAuthentication ,
+-.Cm MaxAuthTries ,
+-.Cm MaxSessions ,
+-.Cm PasswordAuthentication ,
+-.Cm PermitEmptyPasswords ,
+-.Cm PermitOpen ,
+-.Cm PermitRootLogin ,
+-.Cm PermitTTY ,
+-.Cm PermitTunnel ,
+-.Cm PermitUserRC ,
+-.Cm PubkeyAcceptedKeyTypes ,
+-.Cm PubkeyAuthentication ,
+-.Cm RekeyLimit ,
+-.Cm RevokedKeys ,
+-.Cm RhostsRSAAuthentication ,
+-.Cm RSAAuthentication ,
+-.Cm StreamLocalBindMask ,
+-.Cm StreamLocalBindUnlink ,
+-.Cm TrustedUserCAKeys ,
+-.Cm X11DisplayOffset ,
+-.Cm X11Forwarding
+-and
+-.Cm X11UseLocalHost .
+-.It Cm MaxAuthTries
+-Specifies the maximum number of authentication attempts permitted per
+-connection.
+-Once the number of failures reaches half this value,
+-additional failures are logged.
+-The default is 6.
+-.It Cm MaxSessions
+-Specifies the maximum number of open sessions permitted per network connection.
+-The default is 10.
+-.It Cm MaxStartups
+-Specifies the maximum number of concurrent unauthenticated connections to the
+-SSH daemon.
+-Additional connections will be dropped until authentication succeeds or the
+-.Cm LoginGraceTime
+-expires for a connection.
+-The default is 10:30:100.
+-.Pp
+-Alternatively, random early drop can be enabled by specifying
+-the three colon separated values
+-.Dq start:rate:full
+-(e.g. "10:30:60").
+-.Xr sshd 8
+-will refuse connection attempts with a probability of
+-.Dq rate/100
+-(30%)
+-if there are currently
+-.Dq start
+-(10)
+-unauthenticated connections.
+-The probability increases linearly and all connection attempts
+-are refused if the number of unauthenticated connections reaches
+-.Dq full
+-(60).
+-.It Cm PasswordAuthentication
+-Specifies whether password authentication is allowed.
+-The default is
+-.Dq yes .
+-.It Cm PermitEmptyPasswords
+-When password authentication is allowed, it specifies whether the
+-server allows login to accounts with empty password strings.
+-The default is
+-.Dq no .
+-.It Cm PermitOpen
+-Specifies the destinations to which TCP port forwarding is permitted.
+-The forwarding specification must be one of the following forms:
+-.Pp
+-.Bl -item -offset indent -compact
+-.It
+-.Cm PermitOpen
+-.Sm off
+-.Ar host : port
+-.Sm on
+-.It
+-.Cm PermitOpen
+-.Sm off
+-.Ar IPv4_addr : port
+-.Sm on
+-.It
+-.Cm PermitOpen
+-.Sm off
+-.Ar \&[ IPv6_addr \&] : port
+-.Sm on
+-.El
+-.Pp
+-Multiple forwards may be specified by separating them with whitespace.
+-An argument of
+-.Dq any
+-can be used to remove all restrictions and permit any forwarding requests.
+-An argument of
+-.Dq none
+-can be used to prohibit all forwarding requests.
+-By default all port forwarding requests are permitted.
+-.It Cm PermitRootLogin
+-Specifies whether root can log in using
+-.Xr ssh 1 .
+-The argument must be
+-.Dq yes ,
+-.Dq prohibit-password ,
+-.Dq without-password ,
+-.Dq forced-commands-only ,
+-or
+-.Dq no .
+-The default is
+-.Dq prohibit-password .
+-.Pp
+-If this option is set to
+-.Dq prohibit-password
+-or
+-.Dq without-password ,
+-password and keyboard-interactive authentication are disabled for root.
+-.Pp
+-If this option is set to
+-.Dq forced-commands-only ,
+-root login with public key authentication will be allowed,
+-but only if the
+-.Ar command
+-option has been specified
+-(which may be useful for taking remote backups even if root login is
+-normally not allowed).
+-All other authentication methods are disabled for root.
+-.Pp
+-If this option is set to
+-.Dq no ,
+-root is not allowed to log in.
+-.It Cm PermitTunnel
+-Specifies whether
+-.Xr tun 4
+-device forwarding is allowed.
+-The argument must be
+-.Dq yes ,
+-.Dq point-to-point
+-(layer 3),
+-.Dq ethernet
+-(layer 2), or
+-.Dq no .
+-Specifying
+-.Dq yes
+-permits both
+-.Dq point-to-point
+-and
+-.Dq ethernet .
+-The default is
+-.Dq no .
+-.Pp
+-Independent of this setting, the permissions of the selected
+-.Xr tun 4
+-device must allow access to the user.
+-.It Cm PermitTTY
+-Specifies whether
+-.Xr pty 4
+-allocation is permitted.
+-The default is
+-.Dq yes .
+-.It Cm PermitUserEnvironment
+-Specifies whether
+-.Pa ~/.ssh/environment
+-and
+-.Cm environment=
+-options in
+-.Pa ~/.ssh/authorized_keys
+-are processed by
+-.Xr sshd 8 .
+-The default is
+-.Dq no .
+-Enabling environment processing may enable users to bypass access
+-restrictions in some configurations using mechanisms such as
+-.Ev LD_PRELOAD .
+-.It Cm PermitUserRC
+-Specifies whether any
+-.Pa ~/.ssh/rc
+-file is executed.
+-The default is
+-.Dq yes .
+-.It Cm PidFile
+-Specifies the file that contains the process ID of the
+-SSH daemon, or
+-.Dq none
+-to not write one.
+-The default is
+-.Pa /var/run/sshd.pid .
+-.It Cm Port
+-Specifies the port number that
+-.Xr sshd 8
+-listens on.
+-The default is 22.
+-Multiple options of this type are permitted.
+-See also
+-.Cm ListenAddress .
+-.It Cm PrintLastLog
+-Specifies whether
+-.Xr sshd 8
+-should print the date and time of the last user login when a user logs
+-in interactively.
+-On Solaris this option is always ignored since pam_unix_session(5)
+-reports the last login time.
+-.It Cm PrintMotd
+-Specifies whether
+-.Xr sshd 8
+-should print
+-.Pa /etc/motd
+-when a user logs in interactively.
+-(On some systems it is also printed by the shell,
+-.Pa /etc/profile ,
+-or equivalent.)
+-The default is
+-.Dq yes .
+-.It Cm Protocol
+-Specifies the protocol versions
+-.Xr sshd 8
+-supports.
+-The possible values are
+-.Sq 1
+-and
+-.Sq 2 .
+-Multiple versions must be comma-separated.
+-The default is
+-.Sq 2 .
+-Note that the order of the protocol list does not indicate preference,
+-because the client selects among multiple protocol versions offered
+-by the server.
+-Specifying
+-.Dq 2,1
+-is identical to
+-.Dq 1,2 .
+-.It Cm PubkeyAcceptedKeyTypes
+-Specifies the key types that will be accepted for public key authentication
+-as a comma-separated pattern list.
+-Alternately if the specified value begins with a
+-.Sq +
+-character, then the specified key types will be appended to the default set
+-instead of replacing them.
+-The default for this option is:
+-.Bd -literal -offset 3n
+-ecdsa-sha2-nistp256-cert-v01@openssh.com,
+-ecdsa-sha2-nistp384-cert-v01@openssh.com,
+-ecdsa-sha2-nistp521-cert-v01@openssh.com,
+-ssh-ed25519-cert-v01@openssh.com,
+-ssh-rsa-cert-v01@openssh.com,
+-ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
+-ssh-ed25519,ssh-rsa
+-.Ed
+-.Pp
+-The
+-.Fl Q
+-option of
+-.Xr ssh 1
+-may be used to list supported key types.
+-.It Cm PubkeyAuthentication
+-Specifies whether public key authentication is allowed.
+-The default is
+-.Dq yes .
+-Note that this option applies to protocol version 2 only.
+-.It Cm RekeyLimit
+-Specifies the maximum amount of data that may be transmitted before the
+-session key is renegotiated, optionally followed a maximum amount of
+-time that may pass before the session key is renegotiated.
+-The first argument is specified in bytes and may have a suffix of
+-.Sq K ,
+-.Sq M ,
+-or
+-.Sq G
+-to indicate Kilobytes, Megabytes, or Gigabytes, respectively.
+-The default is between
+-.Sq 1G
+-and
+-.Sq 4G ,
+-depending on the cipher.
+-The optional second value is specified in seconds and may use any of the
+-units documented in the
+-.Sx TIME FORMATS
+-section.
+-The default value for
+-.Cm RekeyLimit
+-is
+-.Dq default none ,
+-which means that rekeying is performed after the cipher's default amount
+-of data has been sent or received and no time based rekeying is done.
+-This option applies to protocol version 2 only.
+-.It Cm RevokedKeys
+-Specifies revoked public keys file, or
+-.Dq none
+-to not use one.
+-Keys listed in this file will be refused for public key authentication.
+-Note that if this file is not readable, then public key authentication will
+-be refused for all users.
+-Keys may be specified as a text file, listing one public key per line, or as
+-an OpenSSH Key Revocation List (KRL) as generated by
+-.Xr ssh-keygen 1 .
+-For more information on KRLs, see the KEY REVOCATION LISTS section in
+-.Xr ssh-keygen 1 .
+-.It Cm RhostsRSAAuthentication
+-Specifies whether rhosts or /etc/hosts.equiv authentication together
+-with successful RSA host authentication is allowed.
+-The default is
+-.Dq no .
+-This option applies to protocol version 1 only.
+-.It Cm RSAAuthentication
+-Specifies whether pure RSA authentication is allowed.
+-The default is
+-.Dq yes .
+-This option applies to protocol version 1 only.
+-.It Cm ServerKeyBits
+-Defines the number of bits in the ephemeral protocol version 1 server key.
+-The default and minimum value is 1024.
+-.It Cm StreamLocalBindMask
+-Sets the octal file creation mode mask
+-.Pq umask
+-used when creating a Unix-domain socket file for local or remote
+-port forwarding.
+-This option is only used for port forwarding to a Unix-domain socket file.
+-.Pp
+-The default value is 0177, which creates a Unix-domain socket file that is
+-readable and writable only by the owner.
+-Note that not all operating systems honor the file mode on Unix-domain
+-socket files.
+-.It Cm StreamLocalBindUnlink
+-Specifies whether to remove an existing Unix-domain socket file for local
+-or remote port forwarding before creating a new one.
+-If the socket file already exists and
+-.Cm StreamLocalBindUnlink
+-is not enabled,
+-.Nm sshd
+-will be unable to forward the port to the Unix-domain socket file.
+-This option is only used for port forwarding to a Unix-domain socket file.
+-.Pp
+-The argument must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is
+-.Dq no .
+-.It Cm StrictModes
+-Specifies whether
+-.Xr sshd 8
+-should check file modes and ownership of the
+-user's files and home directory before accepting login.
+-This is normally desirable because novices sometimes accidentally leave their
+-directory or files world-writable.
+-The default is
+-.Dq yes .
+-Note that this does not apply to
+-.Cm ChrootDirectory ,
+-whose permissions and ownership are checked unconditionally.
+-.It Cm Subsystem
+-Configures an external subsystem (e.g. file transfer daemon).
+-Arguments should be a subsystem name and a command (with optional arguments)
+-to execute upon subsystem request.
+-.Pp
+-The command
+-.Xr sftp-server 8
+-implements the
+-.Dq sftp
+-file transfer subsystem.
+-.Pp
+-Alternately the name
+-.Dq internal-sftp
+-implements an in-process
+-.Dq sftp
+-server.
+-This may simplify configurations using
+-.Cm ChrootDirectory
+-to force a different filesystem root on clients.
+-.Pp
+-By default no subsystems are defined.
+-Note that this option applies to protocol version 2 only.
+-.It Cm SyslogFacility
+-Gives the facility code that is used when logging messages from
+-.Xr sshd 8 .
+-The possible values are: DAEMON, USER, AUTH, LOCAL0, LOCAL1, LOCAL2,
+-LOCAL3, LOCAL4, LOCAL5, LOCAL6, LOCAL7.
+-The default is AUTH.
+-.It Cm TCPKeepAlive
+-Specifies whether the system should send TCP keepalive messages to the
+-other side.
+-If they are sent, death of the connection or crash of one
+-of the machines will be properly noticed.
+-However, this means that
+-connections will die if the route is down temporarily, and some people
+-find it annoying.
+-On the other hand, if TCP keepalives are not sent,
+-sessions may hang indefinitely on the server, leaving
+-.Dq ghost
+-users and consuming server resources.
+-.Pp
+-The default is
+-.Dq yes
+-(to send TCP keepalive messages), and the server will notice
+-if the network goes down or the client host crashes.
+-This avoids infinitely hanging sessions.
+-.Pp
+-To disable TCP keepalive messages, the value should be set to
+-.Dq no .
+-.It Cm TrustedUserCAKeys
+-Specifies a file containing public keys of certificate authorities that are
+-trusted to sign user certificates for authentication, or
+-.Dq none
+-to not use one.
+-Keys are listed one per line; empty lines and comments starting with
+-.Ql #
+-are allowed.
+-If a certificate is presented for authentication and has its signing CA key
+-listed in this file, then it may be used for authentication for any user
+-listed in the certificate's principals list.
+-Note that certificates that lack a list of principals will not be permitted
+-for authentication using
+-.Cm TrustedUserCAKeys .
+-For more details on certificates, see the CERTIFICATES section in
+-.Xr ssh-keygen 1 .
+-.It Cm UseDNS
+-Specifies whether
+-.Xr sshd 8
+-should look up the remote host name, and to check that
+-the resolved host name for the remote IP address maps back to the
+-very same IP address.
+-.Pp
+-If this option is set to
+-.Dq no
+-(the default) then only addresses and not host names may be used in
+-.Pa ~/.ssh/known_hosts
+-.Cm from
+-and
+-.Nm
+-.Cm Match
+-.Cm Host
+-directives.
+-.It Cm UseLogin
+-Specifies whether
+-.Xr login 1
+-is used for interactive login sessions.
+-The default is
+-.Dq no .
+-Note that
+-.Xr login 1
+-is never used for remote command execution.
+-Note also, that if this is enabled,
+-.Cm X11Forwarding
+-will be disabled because
+-.Xr login 1
+-does not know how to handle
+-.Xr xauth 1
+-cookies.
+-If
+-.Cm UsePrivilegeSeparation
+-is specified, it will be disabled after authentication.
+-.It Cm UsePAM
+-Enables the Pluggable Authentication Module interface.
+-If set to
+-.Dq yes
+-this will enable PAM authentication using
+-.Cm ChallengeResponseAuthentication
+-and
+-.Cm PasswordAuthentication
+-in addition to PAM account and session module processing for all
+-authentication types.
+-.Pp
+-Because PAM challenge-response authentication usually serves an equivalent
+-role to password authentication, you should disable either
+-.Cm PasswordAuthentication
+-or
+-.Cm ChallengeResponseAuthentication.
+-.Pp
+-If
+-.Cm UsePAM
+-is enabled, you will not be able to run
+-.Xr sshd 8
+-as a non-root user.
+-The default is
+-.Dq no .
+-.It Cm UsePrivilegeSeparation
+-Specifies whether
+-.Xr sshd 8
+-separates privileges by creating an unprivileged child process
+-to deal with incoming network traffic.
+-After successful authentication, another process will be created that has
+-the privilege of the authenticated user.
+-The goal of privilege separation is to prevent privilege
+-escalation by containing any corruption within the unprivileged processes.
+-The default is
+-.Dq yes .
+-If
+-.Cm UsePrivilegeSeparation
+-is set to
+-.Dq sandbox
+-then the pre-authentication unprivileged process is subject to additional
+-restrictions.
+-.It Cm VersionAddendum
+-Optionally specifies additional text to append to the SSH protocol banner
+-sent by the server upon connection.
+-The default is
+-.Dq none .
+-.It Cm X11DisplayOffset
+-Specifies the first display number available for
+-.Xr sshd 8 Ns 's
+-X11 forwarding.
+-This prevents sshd from interfering with real X11 servers.
+-The default is 10.
+-.It Cm X11Forwarding
+-Specifies whether X11 forwarding is permitted.
+-The argument must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is
+-.Dq no .
+-.Pp
+-When X11 forwarding is enabled, there may be additional exposure to
+-the server and to client displays if the
+-.Xr sshd 8
+-proxy display is configured to listen on the wildcard address (see
+-.Cm X11UseLocalhost
+-below), though this is not the default.
+-Additionally, the authentication spoofing and authentication data
+-verification and substitution occur on the client side.
+-The security risk of using X11 forwarding is that the client's X11
+-display server may be exposed to attack when the SSH client requests
+-forwarding (see the warnings for
+-.Cm ForwardX11
+-in
+-.Xr ssh_config 5 ) .
+-A system administrator may have a stance in which they want to
+-protect clients that may expose themselves to attack by unwittingly
+-requesting X11 forwarding, which can warrant a
+-.Dq no
+-setting.
+-.Pp
+-Note that disabling X11 forwarding does not prevent users from
+-forwarding X11 traffic, as users can always install their own forwarders.
+-X11 forwarding is automatically disabled if
+-.Cm UseLogin
+-is enabled.
+-.It Cm X11UseLocalhost
+-Specifies whether
+-.Xr sshd 8
+-should bind the X11 forwarding server to the loopback address or to
+-the wildcard address.
+-By default,
+-sshd binds the forwarding server to the loopback address and sets the
+-hostname part of the
+-.Ev DISPLAY
+-environment variable to
+-.Dq localhost .
+-This prevents remote hosts from connecting to the proxy display.
+-However, some older X11 clients may not function with this
+-configuration.
+-.Cm X11UseLocalhost
+-may be set to
+-.Dq no
+-to specify that the forwarding server should be bound to the wildcard
+-address.
+-The argument must be
+-.Dq yes
+-or
+-.Dq no .
+-The default is
+-.Dq yes .
+-.It Cm XAuthLocation
+-Specifies the full pathname of the
+-.Xr xauth 1
+-program, or
+-.Dq none
+-to not use one.
+-The default is
+-.Pa /usr/X11R6/bin/xauth .
+-.El
+-.Sh TIME FORMATS
+-.Xr sshd 8
+-command-line arguments and configuration file options that specify time
+-may be expressed using a sequence of the form:
+-.Sm off
+-.Ar time Op Ar qualifier ,
+-.Sm on
+-where
+-.Ar time
+-is a positive integer value and
+-.Ar qualifier
+-is one of the following:
+-.Pp
+-.Bl -tag -width Ds -compact -offset indent
+-.It Aq Cm none
+-seconds
+-.It Cm s | Cm S
+-seconds
+-.It Cm m | Cm M
+-minutes
+-.It Cm h | Cm H
+-hours
+-.It Cm d | Cm D
+-days
+-.It Cm w | Cm W
+-weeks
+-.El
+-.Pp
+-Each member of the sequence is added together to calculate
+-the total time value.
+-.Pp
+-Time format examples:
+-.Pp
+-.Bl -tag -width Ds -compact -offset indent
+-.It 600
+-600 seconds (10 minutes)
+-.It 10m
+-10 minutes
+-.It 1h30m
+-1 hour 30 minutes (90 minutes)
+-.El
+-.Sh FILES
+-.Bl -tag -width Ds
+-.It Pa /etc/ssh/sshd_config
+-Contains configuration data for
+-.Xr sshd 8 .
+-This file should be writable by root only, but it is recommended
+-(though not necessary) that it be world-readable.
+-.El
+-.Sh SEE ALSO
+-.Xr sshd 8 ,
+-.Xr pam_unix_session 5
+-.Sh AUTHORS
+-OpenSSH is a derivative of the original and free
+-ssh 1.2.12 release by Tatu Ylonen.
+-Aaron Campbell, Bob Beck, Markus Friedl, Niels Provos,
+-Theo de Raadt and Dug Song
+-removed many bugs, re-added newer features and
+-created OpenSSH.
+-Markus Friedl contributed the support for SSH
+-protocol versions 1.5 and 2.0.
+-Niels Provos and Markus Friedl contributed support
+-for privilege separation.
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:00 2016
+++ new/build/openssh/patches/0007-Deprecated-SunSSH-options.patch	Wed Feb 10 16:25:00 2016
@@ -0,0 +1,49 @@
+From c05313190893bf4d05c9aa3d882a319061e941db Mon Sep 17 00:00:00 2001
+From: oracle <solaris@oracle.com>
+Date: Mon, 3 Aug 2015 14:35:12 -0700
+Subject: [PATCH 07/36] Deprecated SunSSH options
+
+#
+# To make the transition from SunSSH to OpenSSH as smooth as possible, we
+# added SunSSH-only options as deprecated options in OpenSSH. Note that this
+# is an interim enhancement to OpenSSH to make the transition smoother. If a
+# deprecated SunSSH-only option is migrated to OpenSSH later, then it will be
+# changed from deprecated to supported. Since this is for Solaris only, we will
+# not contribute back this change to the upstream community.
+#
+---
+ readconf.c | 18 ++++++++++++++++++
+ 1 file changed, 18 insertions(+)
+
+diff --git a/readconf.c b/readconf.c
+index cd01482..2c63d44 100644
+--- a/readconf.c
++++ b/readconf.c
+@@ -279,6 +279,24 @@ static struct {
+ 	{ "pubkeyacceptedkeytypes", oPubkeyAcceptedKeyTypes },
+ 	{ "ignoreunknown", oIgnoreUnknown },
+ 
++#ifdef DEPRECATE_SUNSSH_OPT
++        /*
++         * On Solaris, to make the transition from SunSSH to OpenSSH as smooth
++         * as possible, we will deprecate SunSSH-only options in OpenSSH.
++         * Therefore, on a system that is running OpenSSH with a deprecated
++         * option from the user's config file (~/.ssh/config), the ssh
++         * connection will proceed without the deprecated option. Note that
++         * this is an interim enhancement to OpenSSH to make the transition
++         * smoother.  If a deprecated SunSSH-only option is migrated to OpenSSH
++         * later, then it will be changed from deprecated to supported.
++         */
++        { "kmfpolicydatabase", oDeprecated },
++        { "kmfpolicyname", oDeprecated },
++        { "trustedanchorkeystore", oDeprecated },
++        { "usefips140", oDeprecated },
++        { "useopensslengine", oDeprecated },
++#endif
++
+ 	{ NULL, oBadOption }
+ };
+ 
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:01 2016
+++ new/build/openssh/patches/0008-GSS-store-creds-for-Solaris.patch	Wed Feb 10 16:25:01 2016
@@ -0,0 +1,178 @@
+From 96ebc88bdb00bcf381a700049ad324ad0b0064b0 Mon Sep 17 00:00:00 2001
+From: oracle <solaris@oracle.com>
+Date: Mon, 3 Aug 2015 14:35:34 -0700
+Subject: [PATCH 08/36] GSS store creds for Solaris
+
+---
+ configure.ac    |  3 +++
+ gss-serv-krb5.c |  7 ++++++-
+ gss-serv.c      | 44 ++++++++++++++++++++++++++++++++++++++++++++
+ servconf.c      |  4 ++++
+ sshd.c          | 14 ++++++++++++++
+ 5 files changed, 71 insertions(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index b06cede..2985819 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -939,6 +939,9 @@ mips-sony-bsd|mips-sony-newsos4)
+ 		],
+ 	)
+ 	TEST_SHELL=$SHELL	# let configure find us a capable shell
++	AC_DEFINE([USE_GSS_STORE_CRED], [1], [Use the Solaris-style GSS cred store])
++	AC_DEFINE([GSSAPI_STORECREDS_NEEDS_RUID], [1], [GSSAPI storecreds needs ruid])
++	AC_DEFINE([HAVE_PAM_AUSER], [1], [pam_auser])
+ 	;;
+ *-*-sunos4*)
+ 	CPPFLAGS="$CPPFLAGS -DSUNOS4"
+diff --git a/gss-serv-krb5.c b/gss-serv-krb5.c
+index 795992d..6e6cff7 100644
+--- a/gss-serv-krb5.c
++++ b/gss-serv-krb5.c
+@@ -110,7 +110,7 @@ ssh_gssapi_krb5_userok(ssh_gssapi_client *client, char *name)
+ 	return retval;
+ }
+ 
+-
++#ifndef USE_GSS_STORE_CRED
+ /* This writes out any forwarded credentials from the structure populated
+  * during userauth. Called after we have setuid to the user */
+ 
+@@ -196,6 +196,7 @@ ssh_gssapi_krb5_storecreds(ssh_gssapi_client *client)
+ 
+ 	return;
+ }
++#endif /* #ifndef USE_GSS_STORE_CRED */
+ 
+ ssh_gssapi_mech gssapi_kerberos_mech = {
+ 	"toWM5Slw5Ew8Mqkay+al2g==",
+@@ -204,7 +205,11 @@ ssh_gssapi_mech gssapi_kerberos_mech = {
+ 	NULL,
+ 	&ssh_gssapi_krb5_userok,
+ 	NULL,
++#ifdef USE_GSS_STORE_CRED
++	NULL
++#else
+ 	&ssh_gssapi_krb5_storecreds
++#endif
+ };
+ 
+ #endif /* KRB5 */
+diff --git a/gss-serv.c b/gss-serv.c
+index 53993d6..209ffe8 100644
+--- a/gss-serv.c
++++ b/gss-serv.c
+@@ -320,22 +320,66 @@ ssh_gssapi_getclient(Gssctxt *ctx, ssh_gssapi_client *client)
+ void
+ ssh_gssapi_cleanup_creds(void)
+ {
++#ifdef USE_GSS_STORE_CRED
++	debug("removing gssapi cred file not implemented");
++#else
+ 	if (gssapi_client.store.filename != NULL) {
+ 		/* Unlink probably isn't sufficient */
+ 		debug("removing gssapi cred file\"%s\"",
+ 		    gssapi_client.store.filename);
+ 		unlink(gssapi_client.store.filename);
+ 	}
++#endif /* USE_GSS_STORE_CRED */
+ }
+ 
+ /* As user */
+ void
+ ssh_gssapi_storecreds(void)
+ {
++#ifdef USE_GSS_STORE_CRED
++	OM_uint32 maj_status, min_status;
++
++	if (gssapi_client.creds == NULL) {
++		debug("No credentials stored");
++		return;
++	}
++
++	maj_status = gss_store_cred(&min_status, gssapi_client.creds,
++	    GSS_C_INITIATE, &gssapi_client.mech->oid, 1, 1, NULL, NULL);
++
++	if (GSS_ERROR(maj_status)) {
++		Buffer b;
++		gss_buffer_desc msg;
++		OM_uint32 lmin;
++		OM_uint32 more = 0;
++		buffer_init(&b);
++		/* GSS-API error */
++		do {
++			gss_display_status(&lmin, maj_status, GSS_C_GSS_CODE,
++			    GSS_C_NULL_OID, &more, &msg);
++			buffer_append(&b, msg.value, msg.length);
++			buffer_put_char(&b, '\n');
++			gss_release_buffer(&lmin, &msg);
++		} while (more != 0);
++		/* Mechanism specific error */
++		do {
++			gss_display_status(&lmin, min_status, GSS_C_MECH_CODE,
++			    &gssapi_client.mech->oid, &more, &msg);
++			buffer_append(&b, msg.value, msg.length);
++			buffer_put_char(&b, '\n');
++			gss_release_buffer(&lmin, &msg);
++		} while (more != 0);
++		buffer_put_char(&b, '\0');
++		error("GSS-API error while storing delegated credentials: %s",
++		    buffer_ptr(&b));
++		buffer_free(&b);
++	}
++#else	/* #ifdef USE_GSS_STORE_CRED */
+ 	if (gssapi_client.mech && gssapi_client.mech->storecreds) {
+ 		(*gssapi_client.mech->storecreds)(&gssapi_client);
+ 	} else
+ 		debug("ssh_gssapi_storecreds: Not a GSSAPI mechanism");
++#endif	/* #ifdef USE_GSS_STORE_CRED */
+ }
+ 
+ /* This allows GSSAPI methods to do things to the childs environment based
+diff --git a/servconf.c b/servconf.c
+index 4ec6b57..ad884ec 100644
+--- a/servconf.c
++++ b/servconf.c
+@@ -489,7 +489,11 @@ static struct {
+ 	{ "afstokenpassing", sUnsupported, SSHCFG_GLOBAL },
+ #ifdef GSSAPI
+ 	{ "gssapiauthentication", sGssAuthentication, SSHCFG_ALL },
++#ifdef USE_GSS_STORE_CRED
++	{ "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL },
++#else /* USE_GSS_STORE_CRED */
+ 	{ "gssapicleanupcredentials", sGssCleanupCreds, SSHCFG_GLOBAL },
++#endif /* USE_GSS_STORE_CRED */
+ 	{ "gssapistrictacceptorcheck", sGssStrictAcceptor, SSHCFG_GLOBAL },
+ #else
+ 	{ "gssapiauthentication", sUnsupported, SSHCFG_ALL },
+diff --git a/sshd.c b/sshd.c
+index 43d4650..84e1dee 100644
+--- a/sshd.c
++++ b/sshd.c
+@@ -2234,9 +2234,23 @@ main(int ac, char **av)
+ 
+ #ifdef GSSAPI
+ 	if (options.gss_authentication) {
++#ifdef GSSAPI_STORECREDS_NEEDS_RUID
++		if (setreuid(authctxt->pw->pw_uid, -1) != 0) {
++			debug("setreuid %u: %.100s",
++			    (u_int) authctxt->pw->pw_uid, strerror(errno));
++			goto bail_storecred;
++		}
++#endif
+ 		temporarily_use_uid(authctxt->pw);
+ 		ssh_gssapi_storecreds();
+ 		restore_uid();
++#ifdef GSSAPI_STORECREDS_NEEDS_RUID
++		if (setuid(geteuid()) != 0) {
++			fatal("setuid %u: %.100s", (u_int) geteuid(),
++			    strerror(errno));
++		}
++ bail_storecred: ;
++#endif
+ 	}
+ #endif
+ #ifdef USE_PAM
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:01 2016
+++ new/build/openssh/patches/0009-DTrace-support-for-SFTP.patch	Wed Feb 10 16:25:01 2016
@@ -0,0 +1,380 @@
+From df6b82f10e53d43cfbc4cb3f52aa7e1751998fa1 Mon Sep 17 00:00:00 2001
+From: oracle <solaris@oracle.com>
+Date: Mon, 3 Aug 2015 14:35:43 -0700
+Subject: [PATCH 09/36] DTrace support for SFTP
+
+---
+ Makefile.in          | 25 +++++++++++++++---
+ sftp-server.c        | 25 ++++++++++++++++--
+ sftp64.d             | 56 ++++++++++++++++++++++++++++++++++++++++
+ sftp_provider.d      | 61 +++++++++++++++++++++++++++++++++++++++++++
+ sftp_provider_impl.h | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++
+ 5 files changed, 234 insertions(+), 6 deletions(-)
+ create mode 100644 sftp64.d
+ create mode 100644 sftp_provider.d
+ create mode 100644 sftp_provider_impl.h
+
+diff --git a/Makefile.in b/Makefile.in
+index 9f953e1..121a261 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -26,6 +26,7 @@ ASKPASS_PROGRAM=$(libexecdir)/ssh-askpass
+ SFTP_SERVER=$(libexecdir)/sftp-server
+ SSH_KEYSIGN=$(libexecdir)/ssh-keysign
+ SSH_PKCS11_HELPER=$(libexecdir)/ssh-pkcs11-helper
++ROOTDLIBDIR64=$(DESTDIR)/usr/lib/dtrace/64
+ PRIVSEP_PATH=@PRIVSEP_PATH@
+ SSH_PRIVSEP_USER=@SSH_PRIVSEP_USER@
+ STRIP_OPT=@STRIP_OPT@
+@@ -85,6 +86,7 @@ LIBSSH_OBJS=${LIBOPENSSH_OBJS} \
+ 	atomicio.o key.o dispatch.o mac.o uidswap.o uuencode.o misc.o \
+ 	monitor_fdpass.o rijndael.o ssh-dss.o ssh-ecdsa.o ssh-rsa.o dh.o \
+ 	msg.o progressmeter.o dns.o entropy.o gss-genr.o umac.o umac128.o \
++	sftp_provider.o \
+ 	ssh-pkcs11.o smult_curve25519_ref.o \
+ 	poly1305.o chacha.o cipher-chachapoly.o \
+ 	ssh-ed25519.o digest-openssl.o digest-libc.o hmac.o \
+@@ -111,7 +113,8 @@ SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \
+ 	sftp-server.o sftp-common.o \
+ 	roaming_common.o roaming_serv.o \
+ 	sandbox-null.o sandbox-rlimit.o sandbox-systrace.o sandbox-darwin.o \
+-	sandbox-seccomp-filter.o sandbox-capsicum.o sandbox-solaris.o
++	sandbox-seccomp-filter.o sandbox-capsicum.o sandbox-solaris.o \
++	sftp_provider.o
+ 
+ MANPAGES	= moduli.4.out scp.1.out ssh-add.1.out ssh-agent.1.out ssh-keygen.1.out ssh-keyscan.1.out ssh.1.out sshd.1m.out sftp-server.1m.out sftp.1.out ssh-keysign.1m.out ssh-pkcs11-helper.1m.out sshd_config.4.out ssh_config.4.out
+ MANPAGES_IN	= moduli.4 scp.1 ssh-add.1 ssh-agent.1 ssh-keygen.1 ssh-keyscan.1 ssh.1 sshd.1m sftp-server.1m sftp.1 ssh-keysign.1m ssh-pkcs11-helper.1m sshd_config.4 ssh_config.4
+@@ -188,8 +191,8 @@ ssh-pkcs11-helper$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-pkcs11-helper.o ssh-pkcs11
+ ssh-keyscan$(EXEEXT): $(LIBCOMPAT) libssh.a ssh-keyscan.o roaming_dummy.o
+ 	$(LD) -o $@ ssh-keyscan.o roaming_dummy.o $(LDFLAGS) -lssh -lopenbsd-compat -lssh $(LIBS)
+ 
+-sftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o sftp-server-main.o
+-	$(LD) -o $@ sftp-server.o sftp-common.o sftp-server-main.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
++sftp-server$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-common.o sftp-server.o sftp-server-main.o sftp_provider.o
++	$(LD) -o $@ sftp-server.o sftp-common.o sftp-server-main.o sftp_provider.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS)
+ 
+ sftp$(EXEEXT): $(LIBCOMPAT) libssh.a sftp.o sftp-client.o sftp-common.o sftp-glob.o progressmeter.o
+ 	$(LD) -o $@ progressmeter.o sftp.o sftp-client.o sftp-common.o sftp-glob.o $(LDFLAGS) -lssh -lopenbsd-compat $(LIBS) $(LIBEDIT)
+@@ -226,9 +229,22 @@ umac128.o:	umac.c
+ 	    -Dumac_update=umac128_update -Dumac_final=umac128_final \
+ 	    -Dumac_delete=umac128_delete
+ 
++# dtrace sftp
++sftp_provider.h: $(srcdir)/sftp_provider.d
++	/usr/sbin/dtrace -xnolibs -h -s $(srcdir)/sftp_provider.d \
++	    -o $(srcdir)/sftp_provider.h
++
++sftp_provider.o: sftp_provider.d sftp_provider.h sftp-server.o
++	/usr/sbin/dtrace -G -64 -xnolibs -s $(srcdir)/sftp_provider.d \
++	    sftp-server.o -o sftp_provider.o
++
++# special case for sftp-server.o, it includes sftp_provider.h
++sftp-server.o: sftp_provider.h sftp-server.c
++	$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $(srcdir)/sftp-server.c
++
+ clean:	regressclean
+ 	rm -f *.o *.a $(TARGETS) logintest config.cache config.log
+-	rm -f *.out core survey
++	rm -f *.out core survey sftp_provider.h
+ 	rm -f regress/unittests/test_helper/*.a
+ 	rm -f regress/unittests/test_helper/*.o
+ 	rm -f regress/unittests/sshbuf/*.o
+@@ -341,6 +357,7 @@ install-files:
+ 	ln -s ./ssh$(EXEEXT) $(DESTDIR)$(bindir)/slogin
+ 	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/slogin.1
+ 	ln -s ./ssh.1 $(DESTDIR)$(mandir)/$(mansubdir)1/slogin.1
++	mkdir -p $(ROOTDLIBDIR64) && cp $(srcdir)/sftp64.d $(ROOTDLIBDIR64)/sftp64.d
+ 
+ install-sysconf:
+ 	if [ ! -d $(DESTDIR)$(sysconfdir) ]; then \
+diff --git a/sftp-server.c b/sftp-server.c
+index 3877c03..772a7c3 100644
+--- a/sftp-server.c
++++ b/sftp-server.c
+@@ -54,6 +54,9 @@
+ 
+ #include "sftp.h"
+ #include "sftp-common.h"
++#ifdef DTRACE_SFTP
++#include "sftp_provider_impl.h"
++#endif
+ 
+ /* Our verbosity */
+ static LogLevel log_level = SYSLOG_LEVEL_ERROR;
+@@ -740,14 +743,17 @@ process_read(u_int32_t id)
+ 	u_int32_t len;
+ 	int r, handle, fd, ret, status = SSH2_FX_FAILURE;
+ 	u_int64_t off;
++	char *fpath;
+ 
+ 	if ((r = get_handle(iqueue, &handle)) != 0 ||
+ 	    (r = sshbuf_get_u64(iqueue, &off)) != 0 ||
+ 	    (r = sshbuf_get_u32(iqueue, &len)) != 0)
+ 		fatal("%s: buffer error: %s", __func__, ssh_err(r));
+ 
++	fpath = handle_to_name(handle);
++
+ 	debug("request %u: read \"%s\" (handle %d) off %llu len %d",
+-	    id, handle_to_name(handle), handle, (unsigned long long)off, len);
++	    id, fpath, handle, (unsigned long long)off, len);
+ 	if (len > sizeof buf) {
+ 		len = sizeof buf;
+ 		debug2("read change len %d", len);
+@@ -758,7 +764,13 @@ process_read(u_int32_t id)
+ 			error("process_read: seek failed");
+ 			status = errno_to_portable(errno);
+ 		} else {
++#ifdef DTRACE_SFTP
++			SFTP_TRANSFER_START_OP("read", fd, fpath, len);
++#endif
+ 			ret = read(fd, buf, len);
++#ifdef DTRACE_SFTP
++			SFTP_TRANSFER_DONE_OP("read", fd, fpath, ret);
++#endif
+ 			if (ret < 0) {
+ 				status = errno_to_portable(errno);
+ 			} else if (ret == 0) {
+@@ -781,14 +793,16 @@ process_write(u_int32_t id)
+ 	size_t len;
+ 	int r, handle, fd, ret, status;
+ 	u_char *data;
++	char *fpath;
+ 
+ 	if ((r = get_handle(iqueue, &handle)) != 0 ||
+ 	    (r = sshbuf_get_u64(iqueue, &off)) != 0 ||
+ 	    (r = sshbuf_get_string(iqueue, &data, &len)) != 0)
+ 		fatal("%s: buffer error: %s", __func__, ssh_err(r));
+ 
++	fpath = handle_to_name(handle);
+ 	debug("request %u: write \"%s\" (handle %d) off %llu len %zu",
+-	    id, handle_to_name(handle), handle, (unsigned long long)off, len);
++	    id, fpath, handle, (unsigned long long)off, len);
+ 	fd = handle_to_fd(handle);
+ 
+ 	if (fd < 0)
+@@ -800,7 +814,14 @@ process_write(u_int32_t id)
+ 			error("process_write: seek failed");
+ 		} else {
+ /* XXX ATOMICIO ? */
++#ifdef DTRACE_SFTP
++			SFTP_TRANSFER_START_OP("write", fd, fpath, len);
++#endif
+ 			ret = write(fd, data, len);
++#ifdef DTRACE_SFTP
++			SFTP_TRANSFER_DONE_OP("write", fd, fpath, ret);
++#endif
++
+ 			if (ret < 0) {
+ 				error("process_write: write failed");
+ 				status = errno_to_portable(errno);
+diff --git a/sftp64.d b/sftp64.d
+new file mode 100644
+index 0000000..8305d0a
+--- /dev/null
++++ b/sftp64.d
+@@ -0,0 +1,56 @@
++/*
++ * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
++ */
++
++#pragma D depends_on library net.d
++#pragma D depends_on library io.d
++#pragma D depends_on module lofs
++
++typedef struct sftpinfo {
++	string sfi_user;		/* user name */
++	string sfi_operation;		/* SFTP Operation */
++	ssize_t sfi_nbytes;		/* bytes transferred, if any */
++	string sfi_pathname;		/* pathname of transfer */
++	string sfi_fsresource;		/* Dataset(ZFS) or resource name */
++} sftpinfo_t;
++
++/*
++ * This structure must match the definition of same in sftp_provider_impl.h.
++ */
++typedef struct sftpproto {
++	int64_t sftp_nbytes;		/* bytes written or read */
++	uint64_t sftp_user;		/* user name */
++	uint64_t sftp_operation;	/* SFTP operation */
++	uint64_t sftp_raddr;		/* remote address */
++	uint64_t sftp_pathname;		/* path with file name */
++	int32_t sftp_fd;		/* fd for transfer, if any */
++} sftpproto_t;
++
++#pragma D binding "1.6.1" translator
++translator conninfo_t <sftpproto_t *s> {
++	ci_protocol = "tcp";
++	ci_remote = copyinstr((uintptr_t)
++	    *(uint64_t *)copyin((uintptr_t)&s->sftp_raddr, sizeof (uint64_t)));
++	ci_local = "<unknown>";
++};
++
++#pragma D binding "1.6.1" translator
++translator sftpinfo_t <sftpproto_t *s> {
++	sfi_user = copyinstr((uintptr_t)
++	    *(uint64_t *)copyin((uintptr_t)&s->sftp_user, sizeof (uint64_t)));
++	sfi_operation = copyinstr((uintptr_t)
++	    *(uint64_t *)copyin((uintptr_t)&s->sftp_operation,
++	    sizeof (uint64_t)));
++	sfi_nbytes =
++	    *(uint64_t *)copyin((uintptr_t)&s->sftp_nbytes, sizeof (uint64_t));
++	sfi_fsresource = stringof(fds[*(int32_t *)copyin((uintptr_t)&s->sftp_fd,
++	    sizeof (int32_t))].fi_fs) == "lofs" ? stringof(((struct loinfo *)
++	    curthread->t_procp->p_user.u_finfo.fi_list[*(int32_t *)copyin(
++	    (uintptr_t)&s->sftp_fd, sizeof (int32_t))].uf_file->f_vnode->
++	    v_vfsp->vfs_data)->li_realvfs->vfs_resource->rs_string) :
++	    stringof(curthread->t_procp->p_user.u_finfo.fi_list[
++	    *(int32_t *)copyin((uintptr_t)&s->sftp_fd, sizeof (int32_t))].
++	    uf_file->f_vnode->v_vfsp->vfs_resource->rs_string);
++	sfi_pathname = copyinstr((uintptr_t)*(uint64_t *)copyin(
++	    (uintptr_t)&s->sftp_pathname, sizeof (uint64_t)));
++};
+diff --git a/sftp_provider.d b/sftp_provider.d
+new file mode 100644
+index 0000000..99e9920
+--- /dev/null
++++ b/sftp_provider.d
+@@ -0,0 +1,61 @@
++/*
++ * CDDL HEADER START
++ *
++ * The contents of this file are subject to the terms of the
++ * Common Development and Distribution License (the "License").
++ * You may not use this file except in compliance with the License.
++ *
++ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
++ * or http://www.opensolaris.org/os/licensing.
++ * See the License for the specific language governing permissions
++ * and limitations under the License.
++ *
++ * When distributing Covered Code, include this CDDL HEADER in each
++ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
++ * If applicable, add the following below this CDDL HEADER, with the
++ * fields enclosed by brackets "[]" replaced with your own identifying
++ * information: Portions Copyright [yyyy] [name of copyright owner]
++ *
++ * CDDL HEADER END
++ */
++/*
++ * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
++ */
++
++/*
++ * We seem currently unable to depend properly on existing D libraries (like
++ * sftp.d). But the definitions for conninfo_t and sftpinfo_t are stored there
++ * (and have to be, since that's where the real translators live). So we're
++ * forced to define something here to satisfy dtrace(1M), but none of the
++ * definitions or translators here are actually used.
++ */
++typedef struct sftpinfo {
++	int dummy;
++} sftpinfo_t;
++
++typedef struct sftpproto {
++	int dummy;
++} sftpproto_t;
++
++typedef struct conninfo {
++	int dummy;
++} conninfo_t;
++
++translator conninfo_t <sftpproto_t *dp> {
++};
++
++translator sftpinfo_t <sftpproto_t *dp> {
++};
++
++provider sftp {
++	probe transfer__start(sftpproto_t *p) :
++	    (conninfo_t *p, sftpinfo_t *p);
++	probe transfer__done(sftpproto_t *p) :
++	    (conninfo_t *p, sftpinfo_t *p);
++};
++
++#pragma D attributes Evolving/Evolving/ISA provider sftp provider
++#pragma D attributes Private/Private/Unknown provider sftp module
++#pragma D attributes Private/Private/Unknown provider sftp function
++#pragma D attributes Private/Private/ISA provider sftp name
++#pragma D attributes Evolving/Evolving/ISA provider sftp args
+diff --git a/sftp_provider_impl.h b/sftp_provider_impl.h
+new file mode 100644
+index 0000000..4b18e6e
+--- /dev/null
++++ b/sftp_provider_impl.h
+@@ -0,0 +1,73 @@
++/*
++ * CDDL HEADER START
++ *
++ * The contents of this file are subject to the terms of the
++ * Common Development and Distribution License (the "License").
++ * You may not use this file except in compliance with the License.
++ *
++ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
++ * or http://www.opensolaris.org/os/licensing.
++ * See the License for the specific language governing permissions
++ * and limitations under the License.
++ *
++ * When distributing Covered Code, include this CDDL HEADER in each
++ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
++ * If applicable, add the following below this CDDL HEADER, with the
++ * fields enclosed by brackets "[]" replaced with your own identifying
++ * information: Portions Copyright [yyyy] [name of copyright owner]
++ *
++ * CDDL HEADER END
++ */
++/*
++ * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
++ */
++
++#ifndef	_SFTP_PROVIDER_IMPL_H
++#define	_SFTP_PROVIDER_IMPL_H
++
++#ifdef	__cplusplus
++extern "C" {
++#endif
++
++/*
++ * This structure must match the definition of same in sftp.d.
++ */
++typedef struct sftpproto {
++	int64_t sftp_nbytes;		/* bytes writtten or read */
++	const char *sftp_user;		/* user name */
++	const char *sftp_operation;	/* SFTP Operation */
++	const char *sftp_raddr;		/* remote address */
++	const char *sftp_pathname;	/* path with file name */
++	int32_t sftp_fd;		/* fd for transfer, if any */
++} sftpproto_t;
++
++#define	SFTP_TRANSFER_PROTO(proto, op, fd, path, len) \
++	bzero((proto), sizeof (struct sftpproto)); \
++	(proto)->sftp_user = (pw->pw_name ? pw->pw_name : "UNKNOWN"); \
++	(proto)->sftp_operation = (op ? op : "UNKNOWN"); \
++	(proto)->sftp_raddr = (client_addr); \
++	(proto)->sftp_fd = (fd); \
++	(proto)->sftp_pathname = (path ? path : "UNKNOWN"); \
++	(proto)->sftp_nbytes = (len); \
++
++#define	SFTP_TRANSFER_START_OP(op, fd, path, len) \
++	if (SFTP_TRANSFER_START_ENABLED()) { \
++		sftpproto_t proto; \
++		SFTP_TRANSFER_PROTO(&proto, op, fd, path, len); \
++		SFTP_TRANSFER_START(&proto); \
++	} \
++
++#define	SFTP_TRANSFER_DONE_OP(op, fd, path, len) \
++	if (SFTP_TRANSFER_DONE_ENABLED()) { \
++		sftpproto_t proto; \
++		SFTP_TRANSFER_PROTO(&proto, op, fd, path, len); \
++		SFTP_TRANSFER_DONE(&proto); \
++	} \
++
++#include "sftp_provider.h"
++
++#ifdef	__cplusplus
++}
++#endif
++
++#endif /* _SFTP_PROVIDER_IMPL_H */
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:01 2016
+++ new/build/openssh/patches/0010-Add-DisableBanner-option.patch	Wed Feb 10 16:25:01 2016
@@ -0,0 +1,182 @@
+From debfde6b8d41a9b15452b519089ce2ee22b6addd Mon Sep 17 00:00:00 2001
+From: oracle <solaris@oracle.com>
+Date: Mon, 3 Aug 2015 14:36:00 -0700
+Subject: [PATCH 10/36] Add DisableBanner option
+
+#
+# This patch is to add a new DisableBanner option to the ssh client command,
+# which allows the ssh command to disable the display of the banner message.
+# We have contributed back this feature to the OpenSSH upstream community. For
+# more information, see https://bugzilla.mindrot.org/show_bug.cgi?id=2242.
+# In the future, if this feature is accepted by the upsteam in a later release,
+# we will remove this patch when we upgrade to that release.
+#
+---
+ readconf.c    | 31 +++++++++++++++++++++++++++++++
+ readconf.h    |  9 +++++++++
+ ssh_config.4  |  8 ++++++++
+ sshconnect2.c | 17 +++++++++++++++++
+ 4 files changed, 65 insertions(+)
+
+diff --git a/readconf.c b/readconf.c
+index 2c63d44..d0f4068 100644
+--- a/readconf.c
++++ b/readconf.c
+@@ -150,6 +150,9 @@ typedef enum {
+ 	oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly,
+ 	oSendEnv, oControlPath, oControlMaster, oControlPersist,
+ 	oHashKnownHosts,
++#ifdef DISABLE_BANNER 
++	oDisableBanner,
++#endif
+ 	oTunnel, oTunnelDevice, oLocalCommand, oPermitLocalCommand,
+ 	oVisualHostKey, oUseRoaming,
+ 	oKexAlgorithms, oIPQoS, oRequestTTY, oIgnoreUnknown, oProxyUseFdpass,
+@@ -255,6 +258,9 @@ static struct {
+ 	{ "controlmaster", oControlMaster },
+ 	{ "controlpersist", oControlPersist },
+ 	{ "hashknownhosts", oHashKnownHosts },
++#ifdef DISABLE_BANNER
++	{ "disablebanner", oDisableBanner },
++#endif
+ 	{ "tunnel", oTunnel },
+ 	{ "tunneldevice", oTunnelDevice },
+ 	{ "localcommand", oLocalCommand },
+@@ -754,6 +760,17 @@ static const struct multistate multistate_canonicalizehostname[] = {
+ 	{ NULL, -1 }
+ };
+ 
++#ifdef DISABLE_BANNER
++static const struct multistate multistate_disablebanner[] = {
++	{ "true",			SSH_DISABLEBANNER_YES },
++	{ "false",			SSH_DISABLEBANNER_NO },
++	{ "yes",			SSH_DISABLEBANNER_YES },
++	{ "no",				SSH_DISABLEBANNER_NO },
++	{ "in-exec-mode",		SSH_DISABLEBANNER_INEXECMODE },
++	{ NULL, -1 }
++}; 
++#endif
++
+ /*
+  * Processes a single option line as used in the configuration files. This
+  * only sets those values that have not already been set.
+@@ -1514,6 +1531,13 @@ parse_keytypes:
+ 		charptr = &options->pubkey_key_types;
+ 		goto parse_keytypes;
+ 
++#ifdef DISABLE_BANNER
++	case oDisableBanner:
++	        intptr = &options->disable_banner;
++                multistate_ptr = multistate_disablebanner;
++                goto parse_multistate; 
++#endif
++
+ 	case oDeprecated:
+ 		debug("%s line %d: Deprecated option \"%s\"",
+ 		    filename, linenum, keyword);
+@@ -1684,6 +1708,9 @@ initialize_options(Options * options)
+ 	options->ip_qos_bulk = -1;
+ 	options->request_tty = -1;
+ 	options->proxy_use_fdpass = -1;
++#ifdef DISABLE_BANNER
++	options->disable_banner = -1;
++#endif
+ 	options->ignored_unknown = NULL;
+ 	options->num_canonical_domains = 0;
+ 	options->num_permitted_cnames = 0;
+@@ -1868,6 +1895,10 @@ fill_default_options(Options * options)
+ 		options->canonicalize_fallback_local = 1;
+ 	if (options->canonicalize_hostname == -1)
+ 		options->canonicalize_hostname = SSH_CANONICALISE_NO;
++#ifdef DISABLE_BANNER
++	if (options->disable_banner == -1)
++		options->disable_banner = 0;
++#endif
+ 	if (options->fingerprint_hash == -1)
+ 		options->fingerprint_hash = SSH_FP_HASH_DEFAULT;
+ 	if (options->update_hostkeys == -1)
+diff --git a/readconf.h b/readconf.h
+index bb2d552..b961309 100644
+--- a/readconf.h
++++ b/readconf.h
+@@ -154,6 +154,9 @@ typedef struct {
+ 	char   *pubkey_key_types;
+ 
+ 	char	*ignored_unknown; /* Pattern list of unknown tokens to ignore */
++#ifdef DISABLE_BANNER
++        int     disable_banner; /* Disable display of banner */
++#endif
+ }       Options;
+ 
+ #define SSH_CANONICALISE_NO	0
+@@ -179,6 +182,12 @@ typedef struct {
+ #define SSH_UPDATE_HOSTKEYS_YES	1
+ #define SSH_UPDATE_HOSTKEYS_ASK	2
+ 
++#ifdef DISABLE_BANNER
++#define SSH_DISABLEBANNER_NO		0
++#define SSH_DISABLEBANNER_YES		1
++#define SSH_DISABLEBANNER_INEXECMODE	2
++#endif
++
+ void     initialize_options(Options *);
+ void     fill_default_options(Options *);
+ void	 fill_default_options_for_canonicalization(Options *);
+diff --git a/ssh_config.4 b/ssh_config.4
+index 8c099eb..6325b3a 100644
+--- a/ssh_config.4
++++ b/ssh_config.4
+@@ -572,6 +572,14 @@ If set to a time in seconds, or a time in any of the formats documented in
+ then the backgrounded master connection will automatically terminate
+ after it has remained idle (with no client connections) for the
+ specified time.
++.It Cm DisableBanner
++If set to yes, disables the display of the  banner  message.
++If set to in-exec-mode, disables the display of banner message when in remote 
++command mode only.
++.Pp
++The default value is no, which means that the banner is displayed unless the 
++log level  is  QUIET, FATAL, or ERROR. See also the Banner option in
++.Xr sshd_config 4 . This option applies to protocol version 2 only.
+ .It Cm DynamicForward
+ Specifies that a TCP port on the local machine be forwarded
+ over the secure channel, and the application
+diff --git a/sshconnect2.c b/sshconnect2.c
+index 7751031..95593b9 100644
+--- a/sshconnect2.c
++++ b/sshconnect2.c
+@@ -81,6 +81,10 @@ extern char *client_version_string;
+ extern char *server_version_string;
+ extern Options options;
+ 
++#ifdef DISABLE_BANNER
++extern Buffer command;
++#endif
++
+ /*
+  * SSH2 key exchange
+  */
+@@ -473,7 +477,20 @@ input_userauth_banner(int type, u_int32_t seq, void *ctxt)
+ 	debug3("input_userauth_banner");
+ 	raw = packet_get_string(&len);
+ 	lang = packet_get_string(NULL);
++
++#ifdef DISABLE_BANNER
++	/*
++	 * Banner is a warning message according to RFC 4252. So, never print
++	 * a banner in error log level or lower. If the log level is higher,
++	 * use DisableBanner option to decide whether to display it or not.
++	 */
++	if (len > 0 && options.log_level >= SYSLOG_LEVEL_INFO && 
++            (options.disable_banner == SSH_DISABLEBANNER_NO ||
++            (options.disable_banner == SSH_DISABLEBANNER_INEXECMODE &&
++            buffer_len(&command) == 0))) {
++#else
+ 	if (len > 0 && options.log_level >= SYSLOG_LEVEL_INFO) {
++#endif
+ 		if (len > 65536)
+ 			len = 65536;
+ 		msg = xmalloc(len * 4 + 1); /* max expansion from strnvis() */
+-- 
+2.5.4 (Apple Git-61)
+
--- old/build/openssh/patches/0009-PAM-conversation-fix.patch	Wed Feb 10 16:25:01 2016
+++ /dev/null	Wed Feb 10 16:25:01 2016
@@ -1,104 +0,0 @@
-From 71e2185a3a2301f08c845a9cb884280dcb0d2cff Mon Sep 17 00:00:00 2001
-From: oracle <solaris@oracle.com>
-Date: Mon, 3 Aug 2015 14:36:13 -0700
-Subject: [PATCH 09/30] PAM conversation fix
-
-#
-# This patch contains an important bug fix for the PAM password userauth
-# conversation function. This bug fix was contributed back to the upstream in
-# 2009, but it was not accepted by the upstream.  For more information, see
-# https://bugzilla.mindrot.org/show_bug.cgi?id=1681.
-#
----
- auth-pam.c | 36 ++++++++++++++++++++++++++++++++++++
- 1 file changed, 36 insertions(+)
-
-diff --git a/auth-pam.c b/auth-pam.c
-index d94c828..b941991 100644
---- a/auth-pam.c
-+++ b/auth-pam.c
-@@ -1111,11 +1111,13 @@ free_pam_environment(char **env)
- 	free(env);
- }
- 
-+#ifndef PAM_BUGFIX
- /*
-  * "Blind" conversation function for password authentication.  Assumes that
-  * echo-off prompts are for the password and stores messages for later
-  * display.
-  */
-+#endif
- static int
- sshpam_passwd_conv(int n, sshpam_const struct pam_message **msg,
-     struct pam_response **resp, void *data)
-@@ -1137,12 +1139,24 @@ sshpam_passwd_conv(int n, sshpam_const struct pam_message **msg,
- 	for (i = 0; i < n; ++i) {
- 		switch (PAM_MSG_MEMBER(msg, i, msg_style)) {
- 		case PAM_PROMPT_ECHO_OFF:
-+#ifdef PAM_BUGFIX
-+                       /*
-+                        * PAM conversation function for the password userauth
-+			* method (non-interactive) really cannot do any 
-+			* prompting.  We set the PAM_AUTHTOK item in 
-+                        * sshpam_auth_passwd()to avoid conversation. If some
-+			* modules still try to converse, then the password
-+			* userauth will fail.
-+			*/
-+			goto fail;
-+#else
- 			if (sshpam_password == NULL)
- 				goto fail;
- 			if ((reply[i].resp = strdup(sshpam_password)) == NULL)
- 				goto fail;
- 			reply[i].resp_retcode = PAM_SUCCESS;
- 			break;
-+#endif
- 		case PAM_ERROR_MSG:
- 		case PAM_TEXT_INFO:
- 			len = strlen(PAM_MSG_MEMBER(msg, i, msg));
-@@ -1178,6 +1192,9 @@ static struct pam_conv passwd_conv = { sshpam_passwd_conv, NULL };
- int
- sshpam_auth_passwd(Authctxt *authctxt, const char *password)
- {
-+#ifdef PAM_BUGFIX
-+        int set_item_rtn;
-+#endif
- 	int flags = (options.permit_empty_passwd == 0 ?
- 	    PAM_DISALLOW_NULL_AUTHTOK : 0);
- 
-@@ -1197,6 +1214,15 @@ sshpam_auth_passwd(Authctxt *authctxt, const char *password)
- 	    options.permit_root_login != PERMIT_YES))
- 		sshpam_password = badpw;
- 
-+#ifdef PAM_BUGFIX
-+  	sshpam_err = pam_set_item(sshpam_handle, PAM_AUTHTOK, password);
-+	if (sshpam_err != PAM_SUCCESS) {
-+		debug("PAM: %s: failed to set PAM_AUTHTOK: %s", __func__,
-+		    pam_strerror(sshpam_handle, sshpam_err));
-+		return 0;
-+	}
-+#endif
-+
- 	sshpam_err = pam_set_item(sshpam_handle, PAM_CONV,
- 	    (const void *)&passwd_conv);
- 	if (sshpam_err != PAM_SUCCESS)
-@@ -1205,6 +1231,16 @@ sshpam_auth_passwd(Authctxt *authctxt, const char *password)
- 
- 	sshpam_err = pam_authenticate(sshpam_handle, flags);
- 	sshpam_password = NULL;
-+
-+#ifdef PAM_BUGFIX
-+        set_item_rtn = pam_set_item(sshpam_handle, PAM_AUTHTOK, NULL);
-+	if (set_item_rtn != PAM_SUCCESS) {
-+		debug("PAM: %s: failed to set PAM_AUTHTOK: %s", __func__,
-+		    pam_strerror(sshpam_handle, set_item_rtn));
-+		return 0;
-+	}
-+#endif
-+
- 	if (sshpam_err == PAM_SUCCESS && authctxt->valid) {
- 		debug("PAM: password authentication accepted for %.100s",
- 		    authctxt->user);
--- 
-2.3.2 (Apple Git-55)
-
--- /dev/null	Wed Feb 10 16:25:01 2016
+++ new/build/openssh/patches/0011-PAM-conversation-fix.patch	Wed Feb 10 16:25:01 2016
@@ -0,0 +1,104 @@
+From 4836dba2499f4c161ea7f18bb35535c366a4cdec Mon Sep 17 00:00:00 2001
+From: oracle <solaris@oracle.com>
+Date: Mon, 3 Aug 2015 14:36:13 -0700
+Subject: [PATCH 11/36] PAM conversation fix
+
+#
+# This patch contains an important bug fix for the PAM password userauth
+# conversation function. This bug fix was contributed back to the upstream in
+# 2009, but it was not accepted by the upstream.  For more information, see
+# https://bugzilla.mindrot.org/show_bug.cgi?id=1681.
+#
+---
+ auth-pam.c | 36 ++++++++++++++++++++++++++++++++++++
+ 1 file changed, 36 insertions(+)
+
+diff --git a/auth-pam.c b/auth-pam.c
+index d94c828..b941991 100644
+--- a/auth-pam.c
++++ b/auth-pam.c
+@@ -1111,11 +1111,13 @@ free_pam_environment(char **env)
+ 	free(env);
+ }
+ 
++#ifndef PAM_BUGFIX
+ /*
+  * "Blind" conversation function for password authentication.  Assumes that
+  * echo-off prompts are for the password and stores messages for later
+  * display.
+  */
++#endif
+ static int
+ sshpam_passwd_conv(int n, sshpam_const struct pam_message **msg,
+     struct pam_response **resp, void *data)
+@@ -1137,12 +1139,24 @@ sshpam_passwd_conv(int n, sshpam_const struct pam_message **msg,
+ 	for (i = 0; i < n; ++i) {
+ 		switch (PAM_MSG_MEMBER(msg, i, msg_style)) {
+ 		case PAM_PROMPT_ECHO_OFF:
++#ifdef PAM_BUGFIX
++                       /*
++                        * PAM conversation function for the password userauth
++			* method (non-interactive) really cannot do any 
++			* prompting.  We set the PAM_AUTHTOK item in 
++                        * sshpam_auth_passwd()to avoid conversation. If some
++			* modules still try to converse, then the password
++			* userauth will fail.
++			*/
++			goto fail;
++#else
+ 			if (sshpam_password == NULL)
+ 				goto fail;
+ 			if ((reply[i].resp = strdup(sshpam_password)) == NULL)
+ 				goto fail;
+ 			reply[i].resp_retcode = PAM_SUCCESS;
+ 			break;
++#endif
+ 		case PAM_ERROR_MSG:
+ 		case PAM_TEXT_INFO:
+ 			len = strlen(PAM_MSG_MEMBER(msg, i, msg));
+@@ -1178,6 +1192,9 @@ static struct pam_conv passwd_conv = { sshpam_passwd_conv, NULL };
+ int
+ sshpam_auth_passwd(Authctxt *authctxt, const char *password)
+ {
++#ifdef PAM_BUGFIX
++        int set_item_rtn;
++#endif
+ 	int flags = (options.permit_empty_passwd == 0 ?
+ 	    PAM_DISALLOW_NULL_AUTHTOK : 0);
+ 
+@@ -1197,6 +1214,15 @@ sshpam_auth_passwd(Authctxt *authctxt, const char *password)
+ 	    options.permit_root_login != PERMIT_YES))
+ 		sshpam_password = badpw;
+ 
++#ifdef PAM_BUGFIX
++  	sshpam_err = pam_set_item(sshpam_handle, PAM_AUTHTOK, password);
++	if (sshpam_err != PAM_SUCCESS) {
++		debug("PAM: %s: failed to set PAM_AUTHTOK: %s", __func__,
++		    pam_strerror(sshpam_handle, sshpam_err));
++		return 0;
++	}
++#endif
++
+ 	sshpam_err = pam_set_item(sshpam_handle, PAM_CONV,
+ 	    (const void *)&passwd_conv);
+ 	if (sshpam_err != PAM_SUCCESS)
+@@ -1205,6 +1231,16 @@ sshpam_auth_passwd(Authctxt *authctxt, const char *password)
+ 
+ 	sshpam_err = pam_authenticate(sshpam_handle, flags);
+ 	sshpam_password = NULL;
++
++#ifdef PAM_BUGFIX
++        set_item_rtn = pam_set_item(sshpam_handle, PAM_AUTHTOK, NULL);
++	if (set_item_rtn != PAM_SUCCESS) {
++		debug("PAM: %s: failed to set PAM_AUTHTOK: %s", __func__,
++		    pam_strerror(sshpam_handle, set_item_rtn));
++		return 0;
++	}
++#endif
++
+ 	if (sshpam_err == PAM_SUCCESS && authctxt->valid) {
+ 		debug("PAM: password authentication accepted for %.100s",
+ 		    authctxt->user);
+-- 
+2.5.4 (Apple Git-61)
+
--- old/build/openssh/patches/0010-PAM-enhancements-for-Solaris.patch	Wed Feb 10 16:25:01 2016
+++ /dev/null	Wed Feb 10 16:25:01 2016
@@ -1,676 +0,0 @@
-From f31faf48842765bb3a9a5a9c400bf4613d639e94 Mon Sep 17 00:00:00 2001
-From: oracle <solaris@oracle.com>
-Date: Mon, 3 Aug 2015 14:36:19 -0700
-Subject: [PATCH 10/30] PAM enhancements for Solaris
-
-#
-# This patch contains a couple of PAM enhancements:
-#   1) Each SSHv2 userauth method has its own PAM service name so that PAM can
-#      be used to control what userauth methods are allowed.
-#   2) The PAMServiceName and PAMServicePrefix options.
-#
-# We have contributed back this feature to the OpenSSH upstream community.
-# For more information, see https://bugzilla.mindrot.org/show_bug.cgi?id=2246
-# In the future, if these enhancements are accepted by the upsteam in a
-# later release, we will remove this patch when we upgrade to that release.
-#
----
- auth-pam.c     | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- auth.h         |   3 ++
- auth2.c        |  61 ++++++++++++++++++++++++++++-
- monitor.c      |  63 ++++++++++++++++++++++++++++++
- monitor.h      |   3 ++
- monitor_wrap.c |  18 +++++++++
- servconf.c     |  56 +++++++++++++++++++++++++++
- servconf.h     |  10 +++++
- sshd.1m        |  27 +++++++++++++
- sshd.c         |   5 +++
- sshd_config.4  |  18 ++++++++-
- 11 files changed, 379 insertions(+), 4 deletions(-)
-
-diff --git a/auth-pam.c b/auth-pam.c
-index b941991..7bdee5c 100644
---- a/auth-pam.c
-+++ b/auth-pam.c
-@@ -617,6 +617,72 @@ sshpam_cleanup(void)
- 	sshpam_handle = NULL;
- }
- 
-+#ifdef PAM_ENHANCEMENT
-+char *
-+derive_pam_service_name(Authctxt *authctxt)
-+{
-+	char *svcname = xmalloc(BUFSIZ);
-+
-+	/*
-+	 * If PamServiceName is set we use that for everything, including
-+	 * SSHv1
-+	 */
-+	if (options.pam_service_name != NULL) {
-+		(void) strlcpy(svcname, options.pam_service_name, BUFSIZ);
-+		return (svcname);
-+	}
-+
-+	if (compat20) {
-+		char *method_name = authctxt->authmethod_name;
-+
-+		if (!method_name)
-+			fatal("Userauth method unknown while starting PAM");
-+
-+		/*
-+		 * For SSHv2 we use "sshd-<userauth name>
-+		 * The "sshd" prefix can be changed via the PAMServicePrefix
-+		 * sshd_config option.
-+		 */
-+		if (strcmp(method_name, "none") == 0) {
-+			snprintf(svcname, BUFSIZ, "%s-none",
-+			    options.pam_service_prefix);
-+		}
-+		if (strcmp(method_name, "password") == 0) {
-+			snprintf(svcname, BUFSIZ, "%s-password",
-+			    options.pam_service_prefix);
-+		}
-+		if (strcmp(method_name, "keyboard-interactive") == 0) {
-+			/* "keyboard-interactive" is too long, shorten it */
-+			snprintf(svcname, BUFSIZ, "%s-kbdint",
-+			    options.pam_service_prefix);
-+		}
-+		if (strcmp(method_name, "publickey") == 0) {
-+			/* "publickey" is too long, shorten it */
-+			snprintf(svcname, BUFSIZ, "%s-pubkey",
-+			    options.pam_service_prefix);
-+		}
-+		if (strcmp(method_name, "hostbased") == 0) {
-+			snprintf(svcname, BUFSIZ, "%s-hostbased",
-+			    options.pam_service_prefix);
-+		}
-+		if (strncmp(method_name, "gssapi-", 7) == 0) {
-+		        /*
-+			 * Although OpenSSH only supports "gssapi-with-mic"
-+			 * for now. We will still map any userauth method
-+                         * prefixed with "gssapi-" to the gssapi PAM service.
-+			 */ 
-+			snprintf(svcname, BUFSIZ, "%s-gssapi",
-+			    options.pam_service_prefix);
-+		}
-+		return svcname;
-+	} else {
-+		/* SSHv1 doesn't get to be so cool */
-+	        snprintf(svcname, BUFSIZ, "sshd-v1");
-+	}
-+	return svcname;
-+}
-+#endif /* PAM_ENHANCEMENT */
-+
- static int
- sshpam_init(Authctxt *authctxt)
- {
-@@ -624,18 +690,71 @@ sshpam_init(Authctxt *authctxt)
- 	const char *pam_rhost, *pam_user, *user = authctxt->user;
- 	const char **ptr_pam_user = &pam_user;
- 
-+#ifdef PAM_ENHANCEMENT
-+	const char *pam_service;
-+        const char **ptr_pam_service = &pam_service;
-+	char *svc = NULL;
-+
-+	svc = derive_pam_service_name(authctxt);
-+        debug3("PAM service is %s", svc);
-+#endif
-+
- 	if (sshpam_handle != NULL) {
-+#ifdef PAM_ENHANCEMENT
-+	        /* get the pam service name */
-+		sshpam_err = pam_get_item(sshpam_handle,
-+		    PAM_SERVICE, (sshpam_const void **)ptr_pam_service);
-+                if (sshpam_err != PAM_SUCCESS) 
-+		    fatal("Failed to get the PAM service name");
-+		debug3("Previous pam_service is %s", pam_service ?
-+                    pam_service : "NULL");
-+
-+		/* get the pam user name */
-+		sshpam_err = pam_get_item(sshpam_handle,
-+		    PAM_USER, (sshpam_const void **)ptr_pam_user);
-+
-+		/*
-+		 * only need to re-start if either user or service is 
-+                 * different.
-+                 */
-+		if (sshpam_err == PAM_SUCCESS && strcmp(user, pam_user) == 0
-+		    && strncmp(svc, pam_service, strlen(svc)) == 0) {
-+		        free(svc);
-+			return (0);
-+                }
-+
-+		/*
-+		 * Clean up previous PAM state.  No need to clean up session 
-+		 * and creds.
-+		 */
-+                sshpam_authenticated = 0;
-+                sshpam_account_status = -1;
-+
-+		sshpam_err = pam_set_item(sshpam_handle, PAM_CONV, NULL);
-+         	if (sshpam_err != PAM_SUCCESS)
-+		        debug3("Cannot remove PAM conv"); /* a warning only */
-+#else /* Original */
- 		/* We already have a PAM context; check if the user matches */
- 		sshpam_err = pam_get_item(sshpam_handle,
- 		    PAM_USER, (sshpam_const void **)ptr_pam_user);
- 		if (sshpam_err == PAM_SUCCESS && strcmp(user, pam_user) == 0)
- 			return (0);
-+#endif /* PAM_ENHANCEMENT */
- 		pam_end(sshpam_handle, sshpam_err);
- 		sshpam_handle = NULL;
- 	}
- 	debug("PAM: initializing for \"%s\"", user);
-+
-+#ifdef PAM_ENHANCEMENT
-+        debug3("Starting PAM service %s for user %s method %s", svc, user,
-+            authctxt->authmethod_name);
-+	sshpam_err =
-+	    pam_start(svc, user, &store_conv, &sshpam_handle);
-+	free(svc);
-+#else /* Original */
- 	sshpam_err =
- 	    pam_start(SSHD_PAM_SERVICE, user, &store_conv, &sshpam_handle);
-+#endif
- 	sshpam_authctxt = authctxt;
- 
- 	if (sshpam_err != PAM_SUCCESS) {
-diff --git a/auth.h b/auth.h
-index 8b27575..a0e41a4 100644
---- a/auth.h
-+++ b/auth.h
-@@ -81,6 +81,9 @@ struct Authctxt {
- 
- 	struct sshkey	**prev_userkeys;
- 	u_int		 nprev_userkeys;
-+#ifdef PAM_ENHANCEMENT
-+        char            *authmethod_name;
-+#endif 
- };
- /*
-  * Every authentication method has to handle authentication requests for
-diff --git a/auth2.c b/auth2.c
-index 7177962..32ba663 100644
---- a/auth2.c
-+++ b/auth2.c
-@@ -243,10 +243,21 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt)
- 			PRIVSEP(audit_event(SSH_INVALID_USER));
- #endif
- 		}
-+
-+
- #ifdef USE_PAM
-+#ifdef PAM_ENHANCEMENT
-+		/*
-+		 * Start PAM here and once only, if each userauth does not
-+		 * has its own PAM service.
-+		 */
-+	        if (options.use_pam && !options.pam_service_per_authmethod)
-+			PRIVSEP(start_pam(authctxt));
-+#else
- 		if (options.use_pam)
- 			PRIVSEP(start_pam(authctxt));
- #endif
-+#endif
- 		setproctitle("%s%s", authctxt->valid ? user : "unknown",
- 		    use_privsep ? " [net]" : "");
- 		authctxt->service = xstrdup(service);
-@@ -277,6 +288,18 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt)
- 	/* try to authenticate user */
- 	m = authmethod_lookup(authctxt, method);
- 	if (m != NULL && authctxt->failures < options.max_authtries) {
-+
-+#if defined(USE_PAM) && defined(PAM_ENHANCEMENT)
-+		/* start PAM service for each userauth */
-+                if (options.use_pam && options.pam_service_per_authmethod) {
-+       		        if (authctxt->authmethod_name != NULL)
-+		                free(authctxt->authmethod_name);
-+                        authctxt->authmethod_name = xstrdup(method);
-+                        if (use_privsep)
-+                                mm_inform_authmethod(method);
-+		        PRIVSEP(start_pam(authctxt));
-+		}
-+#endif
- 		debug2("input_userauth_request: try method %s", method);
- 		authenticated =	m->userauth(authctxt);
- 	}
-@@ -295,6 +318,10 @@ userauth_finish(Authctxt *authctxt, int authenticated, const char *method,
- 	char *methods;
- 	int partial = 0;
- 
-+#ifdef  PAM_ENHANCEMENT
-+        debug3("%s: entering", __func__);
-+#endif
-+
- 	if (!authctxt->valid && authenticated)
- 		fatal("INTERNAL ERROR: authenticated invalid user %s",
- 		    authctxt->user);
-@@ -311,6 +338,25 @@ userauth_finish(Authctxt *authctxt, int authenticated, const char *method,
- 	}
- 
- 	if (authenticated && options.num_auth_methods != 0) {
-+
-+#if defined(USE_PAM) && defined(PAM_ENHANCEMENT)
-+                /*
-+                 * If each userauth has its own PAM service, then PAM need to 
-+                 * perform account check for this service.
-+                 */
-+                if (options.use_pam && options.pam_service_per_authmethod &&
-+                    !PRIVSEP(do_pam_account())) {
-+                        /* if PAM returned a message, send it to the user */
-+                        if (buffer_len(&loginmsg) > 0) {
-+                                buffer_append(&loginmsg, "\0", 1);
-+                                userauth_send_banner(buffer_ptr(&loginmsg));
-+                                packet_write_wait();
-+                        }
-+
-+                        fatal("Access denied for user %s by PAM account "
-+                            "configuration", authctxt->user);
-+                }
-+#endif
- 		if (!auth2_update_methods_lists(authctxt, method, submethod)) {
- 			authenticated = 0;
- 			partial = 1;
-@@ -324,7 +370,20 @@ userauth_finish(Authctxt *authctxt, int authenticated, const char *method,
- 		return;
- 
- #ifdef USE_PAM
-+
-+#ifdef PAM_ENHANCEMENT
-+        /*
-+         * PAM needs to perform account checks after auth. However, if each
-+         * userauth has its own PAM service and options.num_auth_methods != 0,
-+         * then no need to perform account checking, because it was done 
-+         * already.
-+         */
-+        if (options.use_pam && authenticated && 
-+            !(options.num_auth_methods != 0 &&
-+            options.pam_service_per_authmethod)){
-+#else
- 	if (options.use_pam && authenticated) {
-+#endif
- 		if (!PRIVSEP(do_pam_account())) {
- 			/* if PAM returned a message, send it to the user */
- 			if (buffer_len(&loginmsg) > 0) {
-@@ -615,5 +674,3 @@ auth2_update_methods_lists(Authctxt *authctxt, const char *method,
- 		fatal("%s: method not in AuthenticationMethods", __func__);
- 	return 0;
- }
--
--
-diff --git a/monitor.c b/monitor.c
-index a914209..b3efbb0 100644
---- a/monitor.c
-+++ b/monitor.c
-@@ -127,6 +127,9 @@ int mm_answer_sign(int, Buffer *);
- int mm_answer_pwnamallow(int, Buffer *);
- int mm_answer_auth2_read_banner(int, Buffer *);
- int mm_answer_authserv(int, Buffer *);
-+#ifdef PAM_ENHANCEMENT
-+int mm_answer_authmethod(int, Buffer *);
-+#endif
- int mm_answer_authpassword(int, Buffer *);
- int mm_answer_bsdauthquery(int, Buffer *);
- int mm_answer_bsdauthrespond(int, Buffer *);
-@@ -206,10 +209,17 @@ struct mon_table mon_dispatch_proto20[] = {
-     {MONITOR_REQ_SIGN, MON_ONCE, mm_answer_sign},
-     {MONITOR_REQ_PWNAM, MON_ONCE, mm_answer_pwnamallow},
-     {MONITOR_REQ_AUTHSERV, MON_ONCE, mm_answer_authserv},
-+#ifdef PAM_ENHANCEMENT
-+    {MONITOR_REQ_AUTHMETHOD, MON_ISAUTH, mm_answer_authmethod},
-+#endif
-     {MONITOR_REQ_AUTH2_READ_BANNER, MON_ONCE, mm_answer_auth2_read_banner},
-     {MONITOR_REQ_AUTHPASSWORD, MON_AUTH, mm_answer_authpassword},
- #ifdef USE_PAM
-+#ifdef PAM_ENHANCEMENT
-+    {MONITOR_REQ_PAM_START, MON_ISAUTH, mm_answer_pam_start},
-+#else
-     {MONITOR_REQ_PAM_START, MON_ONCE, mm_answer_pam_start},
-+#endif
-     {MONITOR_REQ_PAM_ACCOUNT, 0, mm_answer_pam_account},
-     {MONITOR_REQ_PAM_INIT_CTX, MON_ISAUTH, mm_answer_pam_init_ctx},
-     {MONITOR_REQ_PAM_QUERY, MON_ISAUTH, mm_answer_pam_query},
-@@ -371,6 +381,24 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor)
- 			if (!compat20)
- 				fatal("AuthenticationMethods is not supported"
- 				    "with SSH protocol 1");
-+
-+#if defined(USE_PAM) && defined(PAM_ENHANCEMENT)
-+                        /* 
-+                         * If each userauth has its own PAM service, then PAM
-+                         * need to perform account check for this service.
-+                         */
-+                        if (options.use_pam && authenticated &&
-+                            options.pam_service_per_authmethod) {
-+                                Buffer m;
-+
-+                                buffer_init(&m);
-+                                mm_request_receive_expect(pmonitor->m_sendfd,
-+                                    MONITOR_REQ_PAM_ACCOUNT, &m);
-+                                authenticated = 
-+                                    mm_answer_pam_account(pmonitor->m_sendfd, &m);
-+                                buffer_free(&m);
-+                         }
-+#endif
- 			if (authenticated &&
- 			    !auth2_update_methods_lists(authctxt,
- 			    auth_method, auth_submethod)) {
-@@ -389,8 +417,21 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor)
- 			    !auth_root_allowed(auth_method))
- 				authenticated = 0;
- #ifdef USE_PAM
-+#ifdef PAM_ENHANCEMENT
-+                        /*
-+                         * PAM needs to perform account checks after auth.
-+                         * However, if each userauth has its own PAM service
-+                         * and options.num_auth_methods != 0, then no need to
-+                         * perform account checking, because it was done 
-+                         * already.
-+                         */
-+                        if (options.use_pam && authenticated &&
-+                            !(options.num_auth_methods != 0 &&
-+                            options.pam_service_per_authmethod)) {
-+#else
- 			/* PAM needs to perform account checks after auth */
- 			if (options.use_pam && authenticated) {
-+#endif
- 				Buffer m;
- 
- 				buffer_init(&m);
-@@ -863,6 +904,10 @@ mm_answer_pwnamallow(int sock, Buffer *m)
- 		/* Allow service/style information on the auth context */
- 		monitor_permit(mon_dispatch, MONITOR_REQ_AUTHSERV, 1);
- 		monitor_permit(mon_dispatch, MONITOR_REQ_AUTH2_READ_BANNER, 1);
-+#ifdef PAM_ENHANCEMENT
-+                /* Allow authmethod information on the auth context */
-+		monitor_permit(mon_dispatch, MONITOR_REQ_AUTHMETHOD, 1);
-+#endif
- 	}
- #ifdef USE_PAM
- 	if (options.use_pam)
-@@ -903,6 +948,24 @@ mm_answer_authserv(int sock, Buffer *m)
- 	return (0);
- }
- 
-+#ifdef PAM_ENHANCEMENT
-+int
-+mm_answer_authmethod(int sock, Buffer *m)
-+{
-+	monitor_permit_authentications(1);
-+
-+	authctxt->authmethod_name = buffer_get_string(m, NULL);
-+	debug3("%s: authmethod_name=%s", __func__, authctxt->authmethod_name);
-+
-+	if (strlen(authctxt->authmethod_name) == 0) {
-+		free(authctxt->authmethod_name);
-+		authctxt->authmethod_name = NULL;
-+	}
-+
-+	return (0);
-+}
-+#endif
-+
- int
- mm_answer_authpassword(int sock, Buffer *m)
- {
-diff --git a/monitor.h b/monitor.h
-index 93b8b66..da63e7d 100644
---- a/monitor.h
-+++ b/monitor.h
-@@ -65,6 +65,9 @@ enum monitor_reqtype {
- 	MONITOR_REQ_PAM_FREE_CTX = 110, MONITOR_ANS_PAM_FREE_CTX = 111,
- 	MONITOR_REQ_AUDIT_EVENT = 112, MONITOR_REQ_AUDIT_COMMAND = 113,
- 
-+#ifdef PAM_ENHANCEMENT
-+        MONITOR_REQ_AUTHMETHOD = 114,
-+#endif        
- };
- 
- struct mm_master;
-diff --git a/monitor_wrap.c b/monitor_wrap.c
-index eac421b..95231a3 100644
---- a/monitor_wrap.c
-+++ b/monitor_wrap.c
-@@ -345,6 +345,24 @@ mm_inform_authserv(char *service, char *style)
- 	buffer_free(&m);
- }
- 
-+#ifdef PAM_ENHANCEMENT
-+/* Inform the privileged process about the authentication method */
-+void
-+mm_inform_authmethod(char *authmethod)
-+{
-+	Buffer m;
-+
-+	debug3("%s entering", __func__);
-+
-+	buffer_init(&m);
-+	buffer_put_cstring(&m, authmethod);
-+
-+	mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTHMETHOD, &m);
-+
-+	buffer_free(&m);
-+}
-+#endif
-+
- /* Do the password authentication */
- int
- mm_auth_password(Authctxt *authctxt, char *password)
-diff --git a/servconf.c b/servconf.c
-index ad884ec..d0ca777 100644
---- a/servconf.c
-+++ b/servconf.c
-@@ -169,6 +169,18 @@ initialize_server_options(ServerOptions *options)
- 	options->ip_qos_bulk = -1;
- 	options->version_addendum = NULL;
- 	options->fingerprint_hash = -1;
-+#ifdef PAM_ENHANCEMENT
-+	options->pam_service_name = NULL;
-+	options->pam_service_prefix = NULL;
-+
-+	/* 
-+	 * Each user method will have its own PAM service by default.
-+	 * However, if PAMServiceName is specified or the protocal version
-+	 * is not compat20, then there will be only one PAM service for the
-+	 * entire user authentication.
-+	 */
-+	options->pam_service_per_authmethod = 1;
-+#endif
- }
- 
- /* Returns 1 if a string option is unset or set to "none" or 0 otherwise. */
-@@ -340,6 +352,12 @@ fill_default_server_options(ServerOptions *options)
- 		options->ip_qos_bulk = IPTOS_THROUGHPUT;
- 	if (options->version_addendum == NULL)
- 		options->version_addendum = xstrdup("");
-+
-+#ifdef PAM_ENHANCEMENT
-+	if (options->pam_service_prefix == NULL)
-+		options->pam_service_prefix = _SSH_PAM_SERVICE_PREFIX;
-+#endif
-+
- 	if (options->fwd_opts.streamlocal_bind_mask == (mode_t)-1)
- 		options->fwd_opts.streamlocal_bind_mask = 0177;
- 	if (options->fwd_opts.streamlocal_bind_unlink == -1)
-@@ -421,6 +439,9 @@ typedef enum {
- 	sMatch, sPermitOpen, sForceCommand, sChrootDirectory,
- 	sUsePrivilegeSeparation, sAllowAgentForwarding,
- 	sHostCertificate,
-+#ifdef PAM_ENHANCEMENT
-+	sPAMServicePrefix, sPAMServiceName,
-+#endif
- 	sRevokedKeys, sTrustedUserCAKeys, sAuthorizedPrincipalsFile,
- 	sAuthorizedPrincipalsCommand, sAuthorizedPrincipalsCommandUser,
- 	sKexAlgorithms, sIPQoS, sVersionAddendum,
-@@ -559,6 +580,10 @@ static struct {
- 	{ "forcecommand", sForceCommand, SSHCFG_ALL },
- 	{ "chrootdirectory", sChrootDirectory, SSHCFG_ALL },
- 	{ "hostcertificate", sHostCertificate, SSHCFG_GLOBAL },
-+#ifdef PAM_ENHANCEMENT
-+	{ "pamserviceprefix", sPAMServicePrefix, SSHCFG_GLOBAL },
-+	{ "pamservicename", sPAMServiceName, SSHCFG_GLOBAL },
-+#endif
- 	{ "revokedkeys", sRevokedKeys, SSHCFG_ALL },
- 	{ "trustedusercakeys", sTrustedUserCAKeys, SSHCFG_ALL },
- 	{ "authorizedprincipalsfile", sAuthorizedPrincipalsFile, SSHCFG_ALL },
-@@ -1865,6 +1890,37 @@ process_server_config_line(ServerOptions *options, char *line,
- 			options->fingerprint_hash = value;
- 		break;
- 
-+	case sPAMServicePrefix:
-+		arg = strdelim(&cp);
-+		if (!arg || *arg == '\0')
-+			fatal("%s line %d: Missing argument.",
-+			    filename, linenum);
-+		if (options->pam_service_name != NULL)
-+			fatal("%s line %d: PAMServiceName and PAMServicePrefix"
-+			    " are mutually exclusive.", filename, linenum);
-+		if (options->pam_service_prefix == NULL)
-+			options->pam_service_prefix = xstrdup(arg);
-+		break;
-+
-+	case sPAMServiceName:
-+		arg = strdelim(&cp);
-+		if (!arg || *arg == '\0')
-+			fatal("%s line %d: Missing argument.",
-+			    filename, linenum);
-+		if (options->pam_service_prefix != NULL)
-+			fatal("%s line %d: PAMServiceName and PAMServicePrefix"
-+			    " are mutually exclusive.", filename, linenum);
-+		if (options->pam_service_name == NULL) {
-+			options->pam_service_name = xstrdup(arg);
-+
-+			/*
-+			 * When this option is specified, we will not have
-+			 * PAM service for each auth method.
-+                         */
-+			options->pam_service_per_authmethod = 0;
-+		}
-+		break;
-+
- 	case sDeprecated:
- 		logit("%s line %d: Deprecated option %s",
- 		    filename, linenum, arg);
-diff --git a/servconf.h b/servconf.h
-index f4137af..8c86b57 100644
---- a/servconf.h
-+++ b/servconf.h
-@@ -54,6 +54,10 @@
- /* Magic name for internal sftp-server */
- #define INTERNAL_SFTP_NAME	"internal-sftp"
- 
-+#ifdef PAM_ENHANCEMENT
-+#define _SSH_PAM_SERVICE_PREFIX "sshd"
-+#endif
-+
- typedef struct {
- 	u_int	num_ports;
- 	u_int	ports_from_cmdline;
-@@ -194,6 +198,12 @@ typedef struct {
- 	u_int	num_auth_methods;
- 	char   *auth_methods[MAX_AUTH_METHODS];
- 
-+#ifdef PAM_ENHANCEMENT
-+	char   *pam_service_prefix;
-+	char   *pam_service_name;
-+	int	pam_service_per_authmethod;
-+#endif
-+        
- 	int	fingerprint_hash;
- }       ServerOptions;
- 
-diff --git a/sshd.1m b/sshd.1m
-index 967a753..d67efd7 100644
---- a/sshd.1m
-+++ b/sshd.1m
-@@ -944,6 +944,33 @@ concurrently for different ports, this contains the process ID of the one
- started last).
- The content of this file is not sensitive; it can be world-readable.
- .El
-+
-+.Sh SECURITY
-+sshd uses pam(3PAM) for password and keyboard-interactive methods as well as 
-+for account management, session management, and the password management for all
-+authentication methods.
-+.Pp
-+Each SSHv2 userauth type has its own PAM service name:
-+
-+.Bd -literal -offset 3n
-+
-+-----------------------------------------------
-+| SSHv2 Userauth       | PAM Service Name     |
-+-----------------------------------------------
-+| none                 | sshd-none            |
-+-----------------------------------------------
-+| password             | sshd-password        |
-+-----------------------------------------------
-+| keyboard-interactive | sshd-kbdint          |
-+-----------------------------------------------
-+| pubkey               | sshd-pubkey          |
-+-----------------------------------------------
-+| hostbased            | sshd-hostbased       |
-+-----------------------------------------------
-+| gssapi-with-mic      | sshd-gssapi          |
-+-----------------------------------------------
-+.Ed
-+
- .Sh SEE ALSO
- .Xr scp 1 ,
- .Xr sftp 1 ,
-diff --git a/sshd.c b/sshd.c
-index 3df50f8..5a00ae2 100644
---- a/sshd.c
-+++ b/sshd.c
-@@ -2159,6 +2159,11 @@ main(int ac, char **av)
- 
- 	sshd_exchange_identification(sock_in, sock_out);
- 
-+#ifdef PAM_ENHANCEMENT
-+	if (!compat20)
-+	        options.pam_service_per_authmethod = 0;
-+#endif
-+
- 	/* In inetd mode, generate ephemeral key only for proto 1 connections */
- 	if (!compat20 && inetd_flag && sensitive_data.server_key == NULL)
- 		generate_ephemeral_server_key();
-diff --git a/sshd_config.4 b/sshd_config.4
-index ba4d79a..263175b 100644
---- a/sshd_config.4
-+++ b/sshd_config.4
-@@ -1160,6 +1160,21 @@ The probability increases linearly and all connection attempts
- are refused if the number of unauthenticated connections reaches
- .Dq full
- (60).
-+.It Cm PAMServiceName
-+Specifies the PAM service name for the PAM session. The PAMServiceName and 
-+PAMServicePrefix options are mutually exclusive and if both set, sshd does not
-+start. If this option is set the service name is the same for all user 
-+authentication methods. The option has no default value. See PAMServicePrefix 
-+for more information.
-+.It Cm PAMServicePrefix
-+Specifies the PAM service name prefix for service names used for individual 
-+user authentication methods. The default is sshd. The PAMServiceName and 
-+PAMServicePrefix options are mutually exclusive and if both set, sshd does not 
-+start.
-+.Pp
-+For example, if this option is set to admincli, the service name for the 
-+keyboard-interactive authentication method is admincli-kbdint instead of the 
-+default sshd-kbdint.
- .It Cm PasswordAuthentication
- Specifies whether password authentication is allowed.
- The default is
-@@ -1573,8 +1588,7 @@ If
- is enabled, you will not be able to run
- .Xr sshd 1M
- as a non-root user.
--The default is
--.Dq no .
-+On Solaris, the option is always enabled.
- .It Cm UsePrivilegeSeparation
- Specifies whether
- .Xr sshd 1M
--- 
-2.3.2 (Apple Git-55)
-
--- /dev/null	Wed Feb 10 16:25:01 2016
+++ new/build/openssh/patches/0012-PAM-enhancements-for-Solaris.patch	Wed Feb 10 16:25:01 2016
@@ -0,0 +1,676 @@
+From 8aa9debff40660ed691f984b805e513f3f54334b Mon Sep 17 00:00:00 2001
+From: oracle <solaris@oracle.com>
+Date: Mon, 3 Aug 2015 14:36:19 -0700
+Subject: [PATCH 12/36] PAM enhancements for Solaris
+
+#
+# This patch contains a couple of PAM enhancements:
+#   1) Each SSHv2 userauth method has its own PAM service name so that PAM can
+#      be used to control what userauth methods are allowed.
+#   2) The PAMServiceName and PAMServicePrefix options.
+#
+# We have contributed back this feature to the OpenSSH upstream community.
+# For more information, see https://bugzilla.mindrot.org/show_bug.cgi?id=2246
+# In the future, if these enhancements are accepted by the upsteam in a
+# later release, we will remove this patch when we upgrade to that release.
+#
+---
+ auth-pam.c     | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ auth.h         |   3 ++
+ auth2.c        |  61 ++++++++++++++++++++++++++++-
+ monitor.c      |  63 ++++++++++++++++++++++++++++++
+ monitor.h      |   3 ++
+ monitor_wrap.c |  18 +++++++++
+ servconf.c     |  56 +++++++++++++++++++++++++++
+ servconf.h     |  10 +++++
+ sshd.1m        |  27 +++++++++++++
+ sshd.c         |   5 +++
+ sshd_config.4  |  18 ++++++++-
+ 11 files changed, 379 insertions(+), 4 deletions(-)
+
+diff --git a/auth-pam.c b/auth-pam.c
+index b941991..7bdee5c 100644
+--- a/auth-pam.c
++++ b/auth-pam.c
+@@ -617,6 +617,72 @@ sshpam_cleanup(void)
+ 	sshpam_handle = NULL;
+ }
+ 
++#ifdef PAM_ENHANCEMENT
++char *
++derive_pam_service_name(Authctxt *authctxt)
++{
++	char *svcname = xmalloc(BUFSIZ);
++
++	/*
++	 * If PamServiceName is set we use that for everything, including
++	 * SSHv1
++	 */
++	if (options.pam_service_name != NULL) {
++		(void) strlcpy(svcname, options.pam_service_name, BUFSIZ);
++		return (svcname);
++	}
++
++	if (compat20) {
++		char *method_name = authctxt->authmethod_name;
++
++		if (!method_name)
++			fatal("Userauth method unknown while starting PAM");
++
++		/*
++		 * For SSHv2 we use "sshd-<userauth name>
++		 * The "sshd" prefix can be changed via the PAMServicePrefix
++		 * sshd_config option.
++		 */
++		if (strcmp(method_name, "none") == 0) {
++			snprintf(svcname, BUFSIZ, "%s-none",
++			    options.pam_service_prefix);
++		}
++		if (strcmp(method_name, "password") == 0) {
++			snprintf(svcname, BUFSIZ, "%s-password",
++			    options.pam_service_prefix);
++		}
++		if (strcmp(method_name, "keyboard-interactive") == 0) {
++			/* "keyboard-interactive" is too long, shorten it */
++			snprintf(svcname, BUFSIZ, "%s-kbdint",
++			    options.pam_service_prefix);
++		}
++		if (strcmp(method_name, "publickey") == 0) {
++			/* "publickey" is too long, shorten it */
++			snprintf(svcname, BUFSIZ, "%s-pubkey",
++			    options.pam_service_prefix);
++		}
++		if (strcmp(method_name, "hostbased") == 0) {
++			snprintf(svcname, BUFSIZ, "%s-hostbased",
++			    options.pam_service_prefix);
++		}
++		if (strncmp(method_name, "gssapi-", 7) == 0) {
++		        /*
++			 * Although OpenSSH only supports "gssapi-with-mic"
++			 * for now. We will still map any userauth method
++                         * prefixed with "gssapi-" to the gssapi PAM service.
++			 */ 
++			snprintf(svcname, BUFSIZ, "%s-gssapi",
++			    options.pam_service_prefix);
++		}
++		return svcname;
++	} else {
++		/* SSHv1 doesn't get to be so cool */
++	        snprintf(svcname, BUFSIZ, "sshd-v1");
++	}
++	return svcname;
++}
++#endif /* PAM_ENHANCEMENT */
++
+ static int
+ sshpam_init(Authctxt *authctxt)
+ {
+@@ -624,18 +690,71 @@ sshpam_init(Authctxt *authctxt)
+ 	const char *pam_rhost, *pam_user, *user = authctxt->user;
+ 	const char **ptr_pam_user = &pam_user;
+ 
++#ifdef PAM_ENHANCEMENT
++	const char *pam_service;
++        const char **ptr_pam_service = &pam_service;
++	char *svc = NULL;
++
++	svc = derive_pam_service_name(authctxt);
++        debug3("PAM service is %s", svc);
++#endif
++
+ 	if (sshpam_handle != NULL) {
++#ifdef PAM_ENHANCEMENT
++	        /* get the pam service name */
++		sshpam_err = pam_get_item(sshpam_handle,
++		    PAM_SERVICE, (sshpam_const void **)ptr_pam_service);
++                if (sshpam_err != PAM_SUCCESS) 
++		    fatal("Failed to get the PAM service name");
++		debug3("Previous pam_service is %s", pam_service ?
++                    pam_service : "NULL");
++
++		/* get the pam user name */
++		sshpam_err = pam_get_item(sshpam_handle,
++		    PAM_USER, (sshpam_const void **)ptr_pam_user);
++
++		/*
++		 * only need to re-start if either user or service is 
++                 * different.
++                 */
++		if (sshpam_err == PAM_SUCCESS && strcmp(user, pam_user) == 0
++		    && strncmp(svc, pam_service, strlen(svc)) == 0) {
++		        free(svc);
++			return (0);
++                }
++
++		/*
++		 * Clean up previous PAM state.  No need to clean up session 
++		 * and creds.
++		 */
++                sshpam_authenticated = 0;
++                sshpam_account_status = -1;
++
++		sshpam_err = pam_set_item(sshpam_handle, PAM_CONV, NULL);
++         	if (sshpam_err != PAM_SUCCESS)
++		        debug3("Cannot remove PAM conv"); /* a warning only */
++#else /* Original */
+ 		/* We already have a PAM context; check if the user matches */
+ 		sshpam_err = pam_get_item(sshpam_handle,
+ 		    PAM_USER, (sshpam_const void **)ptr_pam_user);
+ 		if (sshpam_err == PAM_SUCCESS && strcmp(user, pam_user) == 0)
+ 			return (0);
++#endif /* PAM_ENHANCEMENT */
+ 		pam_end(sshpam_handle, sshpam_err);
+ 		sshpam_handle = NULL;
+ 	}
+ 	debug("PAM: initializing for \"%s\"", user);
++
++#ifdef PAM_ENHANCEMENT
++        debug3("Starting PAM service %s for user %s method %s", svc, user,
++            authctxt->authmethod_name);
++	sshpam_err =
++	    pam_start(svc, user, &store_conv, &sshpam_handle);
++	free(svc);
++#else /* Original */
+ 	sshpam_err =
+ 	    pam_start(SSHD_PAM_SERVICE, user, &store_conv, &sshpam_handle);
++#endif
+ 	sshpam_authctxt = authctxt;
+ 
+ 	if (sshpam_err != PAM_SUCCESS) {
+diff --git a/auth.h b/auth.h
+index 8b27575..a0e41a4 100644
+--- a/auth.h
++++ b/auth.h
+@@ -81,6 +81,9 @@ struct Authctxt {
+ 
+ 	struct sshkey	**prev_userkeys;
+ 	u_int		 nprev_userkeys;
++#ifdef PAM_ENHANCEMENT
++        char            *authmethod_name;
++#endif 
+ };
+ /*
+  * Every authentication method has to handle authentication requests for
+diff --git a/auth2.c b/auth2.c
+index 7177962..32ba663 100644
+--- a/auth2.c
++++ b/auth2.c
+@@ -243,10 +243,21 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt)
+ 			PRIVSEP(audit_event(SSH_INVALID_USER));
+ #endif
+ 		}
++
++
+ #ifdef USE_PAM
++#ifdef PAM_ENHANCEMENT
++		/*
++		 * Start PAM here and once only, if each userauth does not
++		 * has its own PAM service.
++		 */
++	        if (options.use_pam && !options.pam_service_per_authmethod)
++			PRIVSEP(start_pam(authctxt));
++#else
+ 		if (options.use_pam)
+ 			PRIVSEP(start_pam(authctxt));
+ #endif
++#endif
+ 		setproctitle("%s%s", authctxt->valid ? user : "unknown",
+ 		    use_privsep ? " [net]" : "");
+ 		authctxt->service = xstrdup(service);
+@@ -277,6 +288,18 @@ input_userauth_request(int type, u_int32_t seq, void *ctxt)
+ 	/* try to authenticate user */
+ 	m = authmethod_lookup(authctxt, method);
+ 	if (m != NULL && authctxt->failures < options.max_authtries) {
++
++#if defined(USE_PAM) && defined(PAM_ENHANCEMENT)
++		/* start PAM service for each userauth */
++                if (options.use_pam && options.pam_service_per_authmethod) {
++       		        if (authctxt->authmethod_name != NULL)
++		                free(authctxt->authmethod_name);
++                        authctxt->authmethod_name = xstrdup(method);
++                        if (use_privsep)
++                                mm_inform_authmethod(method);
++		        PRIVSEP(start_pam(authctxt));
++		}
++#endif
+ 		debug2("input_userauth_request: try method %s", method);
+ 		authenticated =	m->userauth(authctxt);
+ 	}
+@@ -295,6 +318,10 @@ userauth_finish(Authctxt *authctxt, int authenticated, const char *method,
+ 	char *methods;
+ 	int partial = 0;
+ 
++#ifdef  PAM_ENHANCEMENT
++        debug3("%s: entering", __func__);
++#endif
++
+ 	if (!authctxt->valid && authenticated)
+ 		fatal("INTERNAL ERROR: authenticated invalid user %s",
+ 		    authctxt->user);
+@@ -311,6 +338,25 @@ userauth_finish(Authctxt *authctxt, int authenticated, const char *method,
+ 	}
+ 
+ 	if (authenticated && options.num_auth_methods != 0) {
++
++#if defined(USE_PAM) && defined(PAM_ENHANCEMENT)
++                /*
++                 * If each userauth has its own PAM service, then PAM need to 
++                 * perform account check for this service.
++                 */
++                if (options.use_pam && options.pam_service_per_authmethod &&
++                    !PRIVSEP(do_pam_account())) {
++                        /* if PAM returned a message, send it to the user */
++                        if (buffer_len(&loginmsg) > 0) {
++                                buffer_append(&loginmsg, "\0", 1);
++                                userauth_send_banner(buffer_ptr(&loginmsg));
++                                packet_write_wait();
++                        }
++
++                        fatal("Access denied for user %s by PAM account "
++                            "configuration", authctxt->user);
++                }
++#endif
+ 		if (!auth2_update_methods_lists(authctxt, method, submethod)) {
+ 			authenticated = 0;
+ 			partial = 1;
+@@ -324,7 +370,20 @@ userauth_finish(Authctxt *authctxt, int authenticated, const char *method,
+ 		return;
+ 
+ #ifdef USE_PAM
++
++#ifdef PAM_ENHANCEMENT
++        /*
++         * PAM needs to perform account checks after auth. However, if each
++         * userauth has its own PAM service and options.num_auth_methods != 0,
++         * then no need to perform account checking, because it was done 
++         * already.
++         */
++        if (options.use_pam && authenticated && 
++            !(options.num_auth_methods != 0 &&
++            options.pam_service_per_authmethod)){
++#else
+ 	if (options.use_pam && authenticated) {
++#endif
+ 		if (!PRIVSEP(do_pam_account())) {
+ 			/* if PAM returned a message, send it to the user */
+ 			if (buffer_len(&loginmsg) > 0) {
+@@ -615,5 +674,3 @@ auth2_update_methods_lists(Authctxt *authctxt, const char *method,
+ 		fatal("%s: method not in AuthenticationMethods", __func__);
+ 	return 0;
+ }
+-
+-
+diff --git a/monitor.c b/monitor.c
+index a914209..b3efbb0 100644
+--- a/monitor.c
++++ b/monitor.c
+@@ -127,6 +127,9 @@ int mm_answer_sign(int, Buffer *);
+ int mm_answer_pwnamallow(int, Buffer *);
+ int mm_answer_auth2_read_banner(int, Buffer *);
+ int mm_answer_authserv(int, Buffer *);
++#ifdef PAM_ENHANCEMENT
++int mm_answer_authmethod(int, Buffer *);
++#endif
+ int mm_answer_authpassword(int, Buffer *);
+ int mm_answer_bsdauthquery(int, Buffer *);
+ int mm_answer_bsdauthrespond(int, Buffer *);
+@@ -206,10 +209,17 @@ struct mon_table mon_dispatch_proto20[] = {
+     {MONITOR_REQ_SIGN, MON_ONCE, mm_answer_sign},
+     {MONITOR_REQ_PWNAM, MON_ONCE, mm_answer_pwnamallow},
+     {MONITOR_REQ_AUTHSERV, MON_ONCE, mm_answer_authserv},
++#ifdef PAM_ENHANCEMENT
++    {MONITOR_REQ_AUTHMETHOD, MON_ISAUTH, mm_answer_authmethod},
++#endif
+     {MONITOR_REQ_AUTH2_READ_BANNER, MON_ONCE, mm_answer_auth2_read_banner},
+     {MONITOR_REQ_AUTHPASSWORD, MON_AUTH, mm_answer_authpassword},
+ #ifdef USE_PAM
++#ifdef PAM_ENHANCEMENT
++    {MONITOR_REQ_PAM_START, MON_ISAUTH, mm_answer_pam_start},
++#else
+     {MONITOR_REQ_PAM_START, MON_ONCE, mm_answer_pam_start},
++#endif
+     {MONITOR_REQ_PAM_ACCOUNT, 0, mm_answer_pam_account},
+     {MONITOR_REQ_PAM_INIT_CTX, MON_ISAUTH, mm_answer_pam_init_ctx},
+     {MONITOR_REQ_PAM_QUERY, MON_ISAUTH, mm_answer_pam_query},
+@@ -371,6 +381,24 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor)
+ 			if (!compat20)
+ 				fatal("AuthenticationMethods is not supported"
+ 				    "with SSH protocol 1");
++
++#if defined(USE_PAM) && defined(PAM_ENHANCEMENT)
++                        /* 
++                         * If each userauth has its own PAM service, then PAM
++                         * need to perform account check for this service.
++                         */
++                        if (options.use_pam && authenticated &&
++                            options.pam_service_per_authmethod) {
++                                Buffer m;
++
++                                buffer_init(&m);
++                                mm_request_receive_expect(pmonitor->m_sendfd,
++                                    MONITOR_REQ_PAM_ACCOUNT, &m);
++                                authenticated = 
++                                    mm_answer_pam_account(pmonitor->m_sendfd, &m);
++                                buffer_free(&m);
++                         }
++#endif
+ 			if (authenticated &&
+ 			    !auth2_update_methods_lists(authctxt,
+ 			    auth_method, auth_submethod)) {
+@@ -389,8 +417,21 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor)
+ 			    !auth_root_allowed(auth_method))
+ 				authenticated = 0;
+ #ifdef USE_PAM
++#ifdef PAM_ENHANCEMENT
++                        /*
++                         * PAM needs to perform account checks after auth.
++                         * However, if each userauth has its own PAM service
++                         * and options.num_auth_methods != 0, then no need to
++                         * perform account checking, because it was done 
++                         * already.
++                         */
++                        if (options.use_pam && authenticated &&
++                            !(options.num_auth_methods != 0 &&
++                            options.pam_service_per_authmethod)) {
++#else
+ 			/* PAM needs to perform account checks after auth */
+ 			if (options.use_pam && authenticated) {
++#endif
+ 				Buffer m;
+ 
+ 				buffer_init(&m);
+@@ -863,6 +904,10 @@ mm_answer_pwnamallow(int sock, Buffer *m)
+ 		/* Allow service/style information on the auth context */
+ 		monitor_permit(mon_dispatch, MONITOR_REQ_AUTHSERV, 1);
+ 		monitor_permit(mon_dispatch, MONITOR_REQ_AUTH2_READ_BANNER, 1);
++#ifdef PAM_ENHANCEMENT
++                /* Allow authmethod information on the auth context */
++		monitor_permit(mon_dispatch, MONITOR_REQ_AUTHMETHOD, 1);
++#endif
+ 	}
+ #ifdef USE_PAM
+ 	if (options.use_pam)
+@@ -903,6 +948,24 @@ mm_answer_authserv(int sock, Buffer *m)
+ 	return (0);
+ }
+ 
++#ifdef PAM_ENHANCEMENT
++int
++mm_answer_authmethod(int sock, Buffer *m)
++{
++	monitor_permit_authentications(1);
++
++	authctxt->authmethod_name = buffer_get_string(m, NULL);
++	debug3("%s: authmethod_name=%s", __func__, authctxt->authmethod_name);
++
++	if (strlen(authctxt->authmethod_name) == 0) {
++		free(authctxt->authmethod_name);
++		authctxt->authmethod_name = NULL;
++	}
++
++	return (0);
++}
++#endif
++
+ int
+ mm_answer_authpassword(int sock, Buffer *m)
+ {
+diff --git a/monitor.h b/monitor.h
+index 93b8b66..da63e7d 100644
+--- a/monitor.h
++++ b/monitor.h
+@@ -65,6 +65,9 @@ enum monitor_reqtype {
+ 	MONITOR_REQ_PAM_FREE_CTX = 110, MONITOR_ANS_PAM_FREE_CTX = 111,
+ 	MONITOR_REQ_AUDIT_EVENT = 112, MONITOR_REQ_AUDIT_COMMAND = 113,
+ 
++#ifdef PAM_ENHANCEMENT
++        MONITOR_REQ_AUTHMETHOD = 114,
++#endif        
+ };
+ 
+ struct mm_master;
+diff --git a/monitor_wrap.c b/monitor_wrap.c
+index eac421b..95231a3 100644
+--- a/monitor_wrap.c
++++ b/monitor_wrap.c
+@@ -345,6 +345,24 @@ mm_inform_authserv(char *service, char *style)
+ 	buffer_free(&m);
+ }
+ 
++#ifdef PAM_ENHANCEMENT
++/* Inform the privileged process about the authentication method */
++void
++mm_inform_authmethod(char *authmethod)
++{
++	Buffer m;
++
++	debug3("%s entering", __func__);
++
++	buffer_init(&m);
++	buffer_put_cstring(&m, authmethod);
++
++	mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_AUTHMETHOD, &m);
++
++	buffer_free(&m);
++}
++#endif
++
+ /* Do the password authentication */
+ int
+ mm_auth_password(Authctxt *authctxt, char *password)
+diff --git a/servconf.c b/servconf.c
+index ad884ec..d0ca777 100644
+--- a/servconf.c
++++ b/servconf.c
+@@ -169,6 +169,18 @@ initialize_server_options(ServerOptions *options)
+ 	options->ip_qos_bulk = -1;
+ 	options->version_addendum = NULL;
+ 	options->fingerprint_hash = -1;
++#ifdef PAM_ENHANCEMENT
++	options->pam_service_name = NULL;
++	options->pam_service_prefix = NULL;
++
++	/* 
++	 * Each user method will have its own PAM service by default.
++	 * However, if PAMServiceName is specified or the protocal version
++	 * is not compat20, then there will be only one PAM service for the
++	 * entire user authentication.
++	 */
++	options->pam_service_per_authmethod = 1;
++#endif
+ }
+ 
+ /* Returns 1 if a string option is unset or set to "none" or 0 otherwise. */
+@@ -340,6 +352,12 @@ fill_default_server_options(ServerOptions *options)
+ 		options->ip_qos_bulk = IPTOS_THROUGHPUT;
+ 	if (options->version_addendum == NULL)
+ 		options->version_addendum = xstrdup("");
++
++#ifdef PAM_ENHANCEMENT
++	if (options->pam_service_prefix == NULL)
++		options->pam_service_prefix = _SSH_PAM_SERVICE_PREFIX;
++#endif
++
+ 	if (options->fwd_opts.streamlocal_bind_mask == (mode_t)-1)
+ 		options->fwd_opts.streamlocal_bind_mask = 0177;
+ 	if (options->fwd_opts.streamlocal_bind_unlink == -1)
+@@ -421,6 +439,9 @@ typedef enum {
+ 	sMatch, sPermitOpen, sForceCommand, sChrootDirectory,
+ 	sUsePrivilegeSeparation, sAllowAgentForwarding,
+ 	sHostCertificate,
++#ifdef PAM_ENHANCEMENT
++	sPAMServicePrefix, sPAMServiceName,
++#endif
+ 	sRevokedKeys, sTrustedUserCAKeys, sAuthorizedPrincipalsFile,
+ 	sAuthorizedPrincipalsCommand, sAuthorizedPrincipalsCommandUser,
+ 	sKexAlgorithms, sIPQoS, sVersionAddendum,
+@@ -559,6 +580,10 @@ static struct {
+ 	{ "forcecommand", sForceCommand, SSHCFG_ALL },
+ 	{ "chrootdirectory", sChrootDirectory, SSHCFG_ALL },
+ 	{ "hostcertificate", sHostCertificate, SSHCFG_GLOBAL },
++#ifdef PAM_ENHANCEMENT
++	{ "pamserviceprefix", sPAMServicePrefix, SSHCFG_GLOBAL },
++	{ "pamservicename", sPAMServiceName, SSHCFG_GLOBAL },
++#endif
+ 	{ "revokedkeys", sRevokedKeys, SSHCFG_ALL },
+ 	{ "trustedusercakeys", sTrustedUserCAKeys, SSHCFG_ALL },
+ 	{ "authorizedprincipalsfile", sAuthorizedPrincipalsFile, SSHCFG_ALL },
+@@ -1865,6 +1890,37 @@ process_server_config_line(ServerOptions *options, char *line,
+ 			options->fingerprint_hash = value;
+ 		break;
+ 
++	case sPAMServicePrefix:
++		arg = strdelim(&cp);
++		if (!arg || *arg == '\0')
++			fatal("%s line %d: Missing argument.",
++			    filename, linenum);
++		if (options->pam_service_name != NULL)
++			fatal("%s line %d: PAMServiceName and PAMServicePrefix"
++			    " are mutually exclusive.", filename, linenum);
++		if (options->pam_service_prefix == NULL)
++			options->pam_service_prefix = xstrdup(arg);
++		break;
++
++	case sPAMServiceName:
++		arg = strdelim(&cp);
++		if (!arg || *arg == '\0')
++			fatal("%s line %d: Missing argument.",
++			    filename, linenum);
++		if (options->pam_service_prefix != NULL)
++			fatal("%s line %d: PAMServiceName and PAMServicePrefix"
++			    " are mutually exclusive.", filename, linenum);
++		if (options->pam_service_name == NULL) {
++			options->pam_service_name = xstrdup(arg);
++
++			/*
++			 * When this option is specified, we will not have
++			 * PAM service for each auth method.
++                         */
++			options->pam_service_per_authmethod = 0;
++		}
++		break;
++
+ 	case sDeprecated:
+ 		logit("%s line %d: Deprecated option %s",
+ 		    filename, linenum, arg);
+diff --git a/servconf.h b/servconf.h
+index f4137af..8c86b57 100644
+--- a/servconf.h
++++ b/servconf.h
+@@ -54,6 +54,10 @@
+ /* Magic name for internal sftp-server */
+ #define INTERNAL_SFTP_NAME	"internal-sftp"
+ 
++#ifdef PAM_ENHANCEMENT
++#define _SSH_PAM_SERVICE_PREFIX "sshd"
++#endif
++
+ typedef struct {
+ 	u_int	num_ports;
+ 	u_int	ports_from_cmdline;
+@@ -194,6 +198,12 @@ typedef struct {
+ 	u_int	num_auth_methods;
+ 	char   *auth_methods[MAX_AUTH_METHODS];
+ 
++#ifdef PAM_ENHANCEMENT
++	char   *pam_service_prefix;
++	char   *pam_service_name;
++	int	pam_service_per_authmethod;
++#endif
++        
+ 	int	fingerprint_hash;
+ }       ServerOptions;
+ 
+diff --git a/sshd.1m b/sshd.1m
+index ada4f25..3753f90 100644
+--- a/sshd.1m
++++ b/sshd.1m
+@@ -944,6 +944,33 @@ concurrently for different ports, this contains the process ID of the one
+ started last).
+ The content of this file is not sensitive; it can be world-readable.
+ .El
++
++.Sh SECURITY
++sshd uses pam(3PAM) for password and keyboard-interactive methods as well as 
++for account management, session management, and the password management for all
++authentication methods.
++.Pp
++Each SSHv2 userauth type has its own PAM service name:
++
++.Bd -literal -offset 3n
++
++-----------------------------------------------
++| SSHv2 Userauth       | PAM Service Name     |
++-----------------------------------------------
++| none                 | sshd-none            |
++-----------------------------------------------
++| password             | sshd-password        |
++-----------------------------------------------
++| keyboard-interactive | sshd-kbdint          |
++-----------------------------------------------
++| pubkey               | sshd-pubkey          |
++-----------------------------------------------
++| hostbased            | sshd-hostbased       |
++-----------------------------------------------
++| gssapi-with-mic      | sshd-gssapi          |
++-----------------------------------------------
++.Ed
++
+ .Sh SEE ALSO
+ .Xr scp 1 ,
+ .Xr sftp 1 ,
+diff --git a/sshd.c b/sshd.c
+index 84e1dee..7e519d4 100644
+--- a/sshd.c
++++ b/sshd.c
+@@ -2165,6 +2165,11 @@ main(int ac, char **av)
+ 
+ 	sshd_exchange_identification(sock_in, sock_out);
+ 
++#ifdef PAM_ENHANCEMENT
++	if (!compat20)
++	        options.pam_service_per_authmethod = 0;
++#endif
++
+ 	/* In inetd mode, generate ephemeral key only for proto 1 connections */
+ 	if (!compat20 && inetd_flag && sensitive_data.server_key == NULL)
+ 		generate_ephemeral_server_key();
+diff --git a/sshd_config.4 b/sshd_config.4
+index ba4d79a..263175b 100644
+--- a/sshd_config.4
++++ b/sshd_config.4
+@@ -1160,6 +1160,21 @@ The probability increases linearly and all connection attempts
+ are refused if the number of unauthenticated connections reaches
+ .Dq full
+ (60).
++.It Cm PAMServiceName
++Specifies the PAM service name for the PAM session. The PAMServiceName and 
++PAMServicePrefix options are mutually exclusive and if both set, sshd does not
++start. If this option is set the service name is the same for all user 
++authentication methods. The option has no default value. See PAMServicePrefix 
++for more information.
++.It Cm PAMServicePrefix
++Specifies the PAM service name prefix for service names used for individual 
++user authentication methods. The default is sshd. The PAMServiceName and 
++PAMServicePrefix options are mutually exclusive and if both set, sshd does not 
++start.
++.Pp
++For example, if this option is set to admincli, the service name for the 
++keyboard-interactive authentication method is admincli-kbdint instead of the 
++default sshd-kbdint.
+ .It Cm PasswordAuthentication
+ Specifies whether password authentication is allowed.
+ The default is
+@@ -1573,8 +1588,7 @@ If
+ is enabled, you will not be able to run
+ .Xr sshd 1M
+ as a non-root user.
+-The default is
+-.Dq no .
++On Solaris, the option is always enabled.
+ .It Cm UsePrivilegeSeparation
+ Specifies whether
+ .Xr sshd 1M
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:01 2016
+++ new/build/openssh/patches/0013-SunSSH-compat-default-config-values.patch	Wed Feb 10 16:25:01 2016
@@ -0,0 +1,135 @@
+From 6286276c8442faf6514f8f8a6ba5993193fb28bb Mon Sep 17 00:00:00 2001
+From: oracle <solaris@oracle.com>
+Date: Mon, 3 Aug 2015 14:36:22 -0700
+Subject: [PATCH 13/36] SunSSH compat default config values
+
+#
+# Some options in OpenSSH have different default values from those in SunSSH.
+# To make the transition smoother from SunSSH to OpenSSH, we change default
+# values for the following options to be as same as those in SunSSH.
+#
+#   GSSAPIAuthentication (for both server and client)
+#   X11Forwarding        (for server)
+#   ForwardX11Trusted    (for client)
+#
+# This is for Solaris only, we will not contribute back these changes to the
+# upstream.
+#
+---
+ readconf.c    | 8 ++++++++
+ servconf.c    | 8 ++++++++
+ ssh_config.4  | 8 ++++----
+ sshd_config.4 | 8 ++++----
+ 4 files changed, 24 insertions(+), 8 deletions(-)
+
+diff --git a/readconf.c b/readconf.c
+index d0f4068..db37809 100644
+--- a/readconf.c
++++ b/readconf.c
+@@ -1751,7 +1751,11 @@ fill_default_options(Options * options)
+ 	if (options->forward_x11 == -1)
+ 		options->forward_x11 = 0;
+ 	if (options->forward_x11_trusted == -1)
++#ifdef OPTION_DEFAULT_VALUE
++		options->forward_x11_trusted = 1;
++#else
+ 		options->forward_x11_trusted = 0;
++#endif
+ 	if (options->forward_x11_timeout == -1)
+ 		options->forward_x11_timeout = 1200;
+ 	if (options->exit_on_forward_failure == -1)
+@@ -1773,7 +1777,11 @@ fill_default_options(Options * options)
+ 	if (options->challenge_response_authentication == -1)
+ 		options->challenge_response_authentication = 1;
+ 	if (options->gss_authentication == -1)
++#ifdef OPTION_DEFAULT_VALUE
++		options->gss_authentication = 1;
++#else
+ 		options->gss_authentication = 0;
++#endif
+ 	if (options->gss_deleg_creds == -1)
+ 		options->gss_deleg_creds = 0;
+ 	if (options->password_authentication == -1)
+diff --git a/servconf.c b/servconf.c
+index d0ca777..dab8945 100644
+--- a/servconf.c
++++ b/servconf.c
+@@ -251,7 +251,11 @@ fill_default_server_options(ServerOptions *options)
+ 	if (options->print_lastlog == -1)
+ 		options->print_lastlog = 1;
+ 	if (options->x11_forwarding == -1)
++#ifdef OPTION_DEFAULT_VALUE
++		options->x11_forwarding = 1;
++#else
+ 		options->x11_forwarding = 0;
++#endif
+ 	if (options->x11_display_offset == -1)
+ 		options->x11_display_offset = 10;
+ 	if (options->x11_use_localhost == -1)
+@@ -291,7 +295,11 @@ fill_default_server_options(ServerOptions *options)
+ 	if (options->kerberos_get_afs_token == -1)
+ 		options->kerberos_get_afs_token = 0;
+ 	if (options->gss_authentication == -1)
++#ifdef OPTION_DEFAULT_VALUE
++		options->gss_authentication = 1;
++#else
+ 		options->gss_authentication = 0;
++#endif
+ 	if (options->gss_cleanup_creds == -1)
+ 		options->gss_cleanup_creds = 1;
+ 	if (options->gss_strict_acceptor == -1)
+diff --git a/ssh_config.4 b/ssh_config.4
+index 6325b3a..720451e 100644
+--- a/ssh_config.4
++++ b/ssh_config.4
+@@ -724,8 +724,8 @@ Furthermore, the
+ token used for the session will be set to expire after 20 minutes.
+ Remote clients will be refused access after this time.
+ .Pp
+-The default is
+-.Dq no .
++The default on Solaris is
++.Dq yes .
+ .Pp
+ See the X11 SECURITY extension specification for full details on
+ the restrictions imposed on untrusted clients.
+@@ -754,8 +754,8 @@ The default is
+ .Pa /etc/ssh/ssh_known_hosts2 .
+ .It Cm GSSAPIAuthentication
+ Specifies whether user authentication based on GSSAPI is allowed.
+-The default is
+-.Dq no .
++The default on Solaris is
++.Dq yes .
+ Note that this option applies to protocol version 2 only.
+ .It Cm GSSAPIDelegateCredentials
+ Forward (delegate) credentials to the server.
+diff --git a/sshd_config.4 b/sshd_config.4
+index 263175b..03c5b52 100644
+--- a/sshd_config.4
++++ b/sshd_config.4
+@@ -618,8 +618,8 @@ The default is
+ .Dq no .
+ .It Cm GSSAPIAuthentication
+ Specifies whether user authentication based on GSSAPI is allowed.
+-The default is
+-.Dq no .
++The default on Solaris is
++.Dq yes .
+ Note that this option applies to protocol version 2 only.
+ .It Cm GSSAPICleanupCredentials
+ Specifies whether to automatically destroy the user's credentials cache
+@@ -1623,8 +1623,8 @@ The argument must be
+ .Dq yes
+ or
+ .Dq no .
+-The default is
+-.Dq no .
++The default on Solaris is
++.Dq yes .
+ .Pp
+ When X11 forwarding is enabled, there may be additional exposure to
+ the server and to client displays if the
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:01 2016
+++ new/build/openssh/patches/0014-Deprecate-SunSSH-compatible-server-options.patch	Wed Feb 10 16:25:01 2016
@@ -0,0 +1,61 @@
+From 9406fc5e9296bbba9fe16433d0fea6c0fd40abd7 Mon Sep 17 00:00:00 2001
+From: oracle <solaris@oracle.com>
+Date: Mon, 3 Aug 2015 14:36:33 -0700
+Subject: [PATCH 14/36] Deprecate SunSSH compatible server options
+
+#
+# Originally we planned to only deprecate client config (ssh_config) options
+# and leave it up to system administrators to remove all SunSSH specific
+# server config (sshd_config) options. In internal testing we have discovered,
+# that this would bring too much trouble to the said administrators.
+# The probability of these options appearing in existing sshd_config files
+# is higher than initially though, because some of the options have been in
+# default sshd_config file for very long time. Also the consequence of
+# unknown server option is harsh - ssh service goes to maintenance mode
+# possible rendering the instance not accessible. For this reason we will
+# deprecate SunSSH specific sshd_config options too.
+#
+# This is a Solaris specific change to ease the transition and will not be
+# offered upstream.
+#
+---
+ servconf.c | 23 +++++++++++++++++++++++
+ 1 file changed, 23 insertions(+)
+
+diff --git a/servconf.c b/servconf.c
+index dab8945..1a68479 100644
+--- a/servconf.c
++++ b/servconf.c
+@@ -592,6 +592,29 @@ static struct {
+ 	{ "pamserviceprefix", sPAMServicePrefix, SSHCFG_GLOBAL },
+ 	{ "pamservicename", sPAMServiceName, SSHCFG_GLOBAL },
+ #endif
++#ifdef DEPRECATE_SUNSSH_OPT
++	/*
++	 * On Solaris, to make the transition from SunSSH to OpenSSH as smooth
++	 * as possible, we will deprecate SunSSH-only options in OpenSSH.
++	 * Therefore on a system having one of the following options in
++	 * /etc/ssh/sshd_config, change to OpenSSH will not result in service
++	 * network/ssh going to maintenance. Instead, a warning will be printed
++	 * to /var/svc/log/network-ssh:default.log. Note that
++	 * this is an interim enhancement to OpenSSH to make the transition
++	 * smoother.  If a deprecated SunSSH-only option is migrated to OpenSSH
++	 * later, then it will be changed from deprecated to supported.
++	 */
++	{ "maxauthtrieslog", sDeprecated, SSHCFG_GLOBAL },
++	{ "lookupclienthostnames", sDeprecated, SSHCFG_GLOBAL },
++	{ "useopensslengine", sDeprecated, SSHCFG_GLOBAL },
++	{ "preuserauthhook", sDeprecated, SSHCFG_ALL},
++	{ "kmfpolicydatabase", sDeprecated, SSHCFG_GLOBAL },
++	{ "kmfpolicyname", sDeprecated, SSHCFG_GLOBAL },
++	{ "trustedanchorkeystore", sDeprecated, SSHCFG_GLOBAL },
++	{ "useunsupportedsshv1", sDeprecated, SSHCFG_GLOBAL },
++	{ "usefips140", sDeprecated, SSHCFG_ALL},
++	{ "gssapistoredelegatedcredentials", sDeprecated, SSHCFG_ALL },
++#endif
+ 	{ "revokedkeys", sRevokedKeys, SSHCFG_ALL },
+ 	{ "trustedusercakeys", sTrustedUserCAKeys, SSHCFG_ALL },
+ 	{ "authorizedprincipalsfile", sAuthorizedPrincipalsFile, SSHCFG_ALL },
+-- 
+2.5.4 (Apple Git-61)
+
--- old/build/openssh/patches/0014-Solaris-Auditing-support.patch	Wed Feb 10 16:25:01 2016
+++ /dev/null	Wed Feb 10 16:25:01 2016
@@ -1,748 +0,0 @@
-From 6d74600c9a8d52d7b03fd4274a415e980b77d4b6 Mon Sep 17 00:00:00 2001
-From: oracle <solaris@oracle.com>
-Date: Mon, 3 Aug 2015 14:37:01 -0700
-Subject: [PATCH 14/30] Solaris Auditing support
-
-#
-# Add Solaris Auditing configuration (--with-audit=solaris) to openssh-6.5p1.
-#
-# Add phase 1 Solaris Auditing of sshd login/logout to openssh-6.5p1.
-#
-# Additional Solaris Auditing should include audit of password
-#  change.
-# Presuming it is appropriate, this patch should/will be updated
-#  with additional files and updates to sources/audit-solaris.c
-#
-# Code is developed by the Solaris Audit team.
-# It should/will likely be contributed up stream when done.
-# This patch relies on sources/audit-solaris.c being copied into
-#  the openssh source directory by the Makefile that configures
-#  using --with-audit=solaris.
-#
-# The up stream community has been contacted about the plans.
-#  No reply has yet been received.
-#
-# An additional patch relying on the --with-audit=solaris configuration
-#  should/will be created for sftp Solaris Audit and password change.
-#
----
- INSTALL         |  15 +-
- Makefile.in     |   2 +-
- README.platform |   7 +-
- audit-solaris.c | 562 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- configure.ac    |   9 +-
- defines.h       |   5 +
- sshd.c          |   6 +
- 7 files changed, 597 insertions(+), 9 deletions(-)
- create mode 100644 audit-solaris.c
-
-diff --git a/INSTALL b/INSTALL
-index cbbb2df..765d4aa 100644
---- a/INSTALL
-+++ b/INSTALL
-@@ -92,9 +92,13 @@ http://www.gnu.org/software/autoconf/
- 
- Basic Security Module (BSM):
- 
--Native BSM support is know to exist in Solaris from at least 2.5.1,
--FreeBSD 6.1 and OS X.  Alternatively, you may use the OpenBSM
--implementation (http://www.openbsm.org).
-+Native BSM support is known to exist in Solaris from at least 2.5.1
-+to Solaris 10.  From Solaris 11 the previously documented BSM (libbsm)
-+interfaces are no longer public and are unsupported.  While not public
-+interfaces, audit-solaris.c implements Solaris Audit from Solaris 11.
-+Native BSM support is known to exist in FreeBSD 6.1 and OS X.
-+Alternatively, you may use the OpenBSM implementation
-+(http://www.openbsm.org).
- 
- 
- 2. Building / Installation
-@@ -147,8 +151,9 @@ name).
- There are a few other options to the configure script:
- 
- --with-audit=[module] enable additional auditing via the specified module.
--Currently, drivers for "debug" (additional info via syslog) and "bsm"
--(Sun's Basic Security Module) are supported.
-+Currently, drivers for "debug" (additional info via syslog), and "bsm"
-+(Sun's Legacy Basic Security Module prior to Solaris 11), and "solaris"
-+(Sun's Audit infrastructure from Solaris 11) are supported.
- 
- --with-pam enables PAM support. If PAM support is compiled in, it must
- also be enabled in sshd_config (refer to the UsePAM directive).
-diff --git a/Makefile.in b/Makefile.in
-index 5bf2a06..e19c665 100644
---- a/Makefile.in
-+++ b/Makefile.in
-@@ -100,7 +100,7 @@ SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \
- 	roaming_common.o roaming_client.o
- 
- SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \
--	audit.o audit-bsm.o audit-linux.o platform.o \
-+	audit.o audit-bsm.o audit-linux.o audit-solaris.o platform.o \
- 	sshpty.o sshlogin.o servconf.o serverloop.o \
- 	auth.o auth1.o auth2.o auth-options.o session.o \
- 	auth-chall.o auth2-chall.o groupaccess.o \
-diff --git a/README.platform b/README.platform
-index d198232..6949998 100644
---- a/README.platform
-+++ b/README.platform
-@@ -68,8 +68,8 @@ zlib-devel and pam-devel, on Debian based distros these may be
- libssl-dev, libz-dev and libpam-dev.
- 
- 
--Solaris
---------
-+Prior to Solaris 11
-+-------------------
- If you enable BSM auditing on Solaris, you need to update audit_event(4)
- for praudit(1m) to give sensible output.  The following line needs to be
- added to /etc/security/audit_event:
-@@ -82,6 +82,9 @@ There is no official registry of 3rd party event numbers, so if this
- number is already in use on your system, you may change it at build time
- by configure'ing --with-cflags=-DAUE_openssh=32801 then rebuilding.
- 
-+From Solaris 11
-+---------------
-+Solaris Audit is supported by configuring --with-audit=solaris.
- 
- Platforms using PAM
- -------------------
-diff --git a/audit-solaris.c b/audit-solaris.c
-new file mode 100644
-index 0000000..abf870c
---- /dev/null
-+++ b/audit-solaris.c
-@@ -0,0 +1,562 @@
-+/*
-+ * CDDL HEADER START
-+ *
-+ * The contents of this file are subject to the terms of the
-+ * Common Development and Distribution License (the "License").
-+ * You may not use this file except in compliance with the License.
-+ *
-+ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-+ * or http://www.opensolaris.org/os/licensing.
-+ * See the License for the specific language governing permissions
-+ * and limitations under the License.
-+ *
-+ * When distributing Covered Code, include this CDDL HEADER in each
-+ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-+ * If applicable, add the following below this CDDL HEADER, with the
-+ * fields enclosed by brackets "[]" replaced with your own identifying
-+ * information: Portions Copyright [yyyy] [name of copyright owner]
-+ *
-+ * CDDL HEADER END
-+ */
-+
-+/*
-+ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
-+ */
-+
-+#include "includes.h"
-+#if defined(USE_SOLARIS_AUDIT)
-+
-+#include "audit.h"
-+#include "buffer.h"
-+#include "key.h"
-+#include "hostfile.h"
-+#include "auth.h"
-+#include "log.h"
-+#include "packet.h"
-+
-+#include <errno.h>
-+#include <pwd.h>
-+#include <string.h>
-+
-+#include <bsm/adt.h>
-+#include <bsm/adt_event.h>
-+
-+#ifdef	ADT_DEBUG
-+#include <bsm/audit.h>
-+#include <arpa/inet.h>
-+#include <netinet/in.h>
-+#include <values.h>
-+#include <errno.h>
-+#include <pwd.h>
-+#include <stdio.h>
-+#include <unistd.h>
-+#include <stdarg.h>
-+#include <string.h>
-+#include <ucred.h>
-+#include <values.h>
-+
-+#include <bsm/adt.h>
-+#include <bsm/audit.h>
-+
-+#include <sys/types.h>
-+#include <sys/stat.h>
-+
-+/* semi private adt functions to extract information */
-+
-+extern void adt_get_asid(const adt_session_data_t *, au_asid_t *);
-+extern void adt_get_auid(const adt_session_data_t *, au_id_t *);
-+extern void adt_get_mask(const adt_session_data_t *, au_mask_t *);
-+extern void adt_get_termid(const adt_session_data_t *, au_tid_addr_t *);
-+
-+extern void __auditd_debug(char *, ...);
-+
-+void
-+__audit_pidinfo(void)
-+{
-+	adt_session_data_t *ah = NULL;
-+	au_id_t	auid;
-+	char *auid_name = "badname";
-+	struct passwd *pwd;
-+	au_asid_t asid;
-+	au_mask_t mask;
-+	char flags[512];
-+	au_tid_addr_t tid;
-+	char	pbuf[INET6_ADDRSTRLEN];
-+	int	af = AF_INET;
-+	int	remote;
-+	int	local;
-+
-+	if (adt_start_session(&ah, NULL, ADT_USE_PROC_DATA) != 0) {
-+		__auditd_debug("cannot start session %s\n", strerror(errno));
-+		return;
-+	}
-+	if (ah == NULL) {
-+		__auditd_debug("ah is NULL\n");
-+		return;
-+	}
-+	adt_get_auid(ah, &auid);
-+	if ((pwd = getpwuid((uid_t)auid)) != NULL) {
-+		auid_name = pwd->pw_name;
-+	}
-+	__auditd_debug("audit id = %s(%d)\n", auid_name, auid);
-+
-+	adt_get_mask(ah, &mask);
-+	if (getauditflagschar(flags, &mask, NULL) < 0) {
-+		(void) strlcpy(flags, "badflags", sizeof (flags));
-+	}
-+#ifdef	_LP64
-+	__auditd_debug("preselection mask = %s(0x%lx,0x%lx)\n", flags,
-+	    mask.am_success, mask.am_failure);
-+#else	/* _ILP32 */
-+	__auditd_debug("preselection mask = %s(0x%llx,0x%llx)\n", flags,
-+	    mask.am_success, mask.am_failure);
-+#endif	/* _LP64 */
-+
-+	adt_get_termid(ah, &tid);
-+	__auditd_debug("tid type=%d, maj=%u, min=%u, addr=%x:%x:%x:%x\n",
-+	    tid.at_type,
-+	    (uint16_t)((tid.at_port) >> BITS(uint16_t)),
-+	    (uint16_t)(tid.at_port & UINT16_MAX),
-+	    tid.at_addr[0],
-+	    tid.at_addr[1],
-+	    tid.at_addr[2],
-+	    tid.at_addr[3]);
-+	if (tid.at_type == AU_IPv6) {
-+		af = AF_INET6;
-+	}
-+	(void) inet_ntop(af, (void *)(tid.at_addr), pbuf,
-+	    sizeof (pbuf));
-+	remote = (tid.at_port >> BITS(uint16_t));
-+	local = (tid.at_port & UINT16_MAX);
-+	__auditd_debug("tid type-%d (remote,local,host)= %u,%u,%s\n",
-+	    tid.at_type, remote, local, pbuf);
-+	adt_get_asid(ah, &asid);
-+	__auditd_debug("audit session id = %u\n",  asid);
-+	(void) adt_end_session(ah);
-+}
-+#else	/* !ADT_DEBUG */
-+/*ARGSUSED*/
-+/*PRINTFLIKE1*/
-+static void
-+__auditd_debug(char *fmt, ...)
-+{
-+}
-+static void
-+__audit_pidinfo()
-+{
-+}
-+#endif	/* ADT_DEBUG */
-+
-+#include <security/pam_appl.h>
-+
-+#include <sys/types.h>
-+
-+extern Authctxt *the_authctxt;
-+
-+extern const char *audit_username(void);
-+extern const char *audit_event_lookup(ssh_audit_event_t);
-+
-+static adt_session_data_t *ah = NULL;		/* audit session handle */
-+static adt_termid_t	*tid = NULL;		/* peer terminal id */
-+
-+static void audit_login(void);
-+static void audit_logout(void);
-+static void audit_fail(int);
-+
-+/* Below is the sshd audit API Solaris adt interpretation */
-+
-+/*
-+ * Called after a connection has been accepted but before any authentication
-+ * has been attempted.
-+ */
-+/* ARGSUSED */
-+void
-+audit_connection_from(const char *host, int port)
-+{
-+	int peer = packet_get_connection_in();
-+	adt_session_data_t	*ah;
-+
-+	if (adt_load_termid(peer, &tid) != 0) {
-+		error("adt audit_connection_from: unable to load tid for %d:%s",
-+		    peer, strerror(errno));
-+	}
-+	if (adt_start_session(&ah, NULL, 0) != 0) {
-+		error("adt audit_connection_from: unable to start session "
-+		    "for %s:%d:%s", host, port, strerror(errno));
-+	}
-+	if (adt_set_user(ah, ADT_NO_AUDIT, ADT_NO_AUDIT, 0,
-+	    ADT_NO_AUDIT, tid, ADT_SETTID) != 0) {
-+		error("adt audit_connection_from: unable to set user "
-+		    "for %s:%d:%s", host, port, strerror(errno));
-+		(void) adt_end_session(ah);
-+		ah = NULL;
-+	}
-+	if (adt_set_proc(ah) != 0) {
-+		error("adt audit_connection_from: unable to set proc "
-+		    "for %s:%d:%s", host, port, strerror(errno));
-+	}
-+	(void) adt_end_session(ah);
-+	debug("adt audit_connection_from(%s, %d): peerfd=%d", host, port,
-+	    peer);
-+	__auditd_debug("%d/%d:%d-adt audit_connection_from(%s, %d)ctxt=%p: "
-+	    "peerfd=%d\n", getpid(), getuid(), geteuid(), host, port,
-+	    (void *)the_authctxt, peer);
-+	__audit_pidinfo();
-+}
-+
-+/*
-+ * Called when various events occur (see audit.h for a list of possible
-+ * events and what they mean).
-+ *
-+ *	Entry	the_authcntxt
-+ */
-+void
-+audit_event(ssh_audit_event_t event)
-+{
-+	static boolean_t logged_in = B_FALSE;	/* if user did login */
-+	int fail = PAM_IGNORE;		/* default unset */
-+	static boolean_t did_maxtries = B_FALSE; /* if interactive and abort */
-+
-+	debug("adt audit_event(%s)", audit_event_lookup(event));
-+	__auditd_debug("%d/%d:%d-adt audit_event(%s/%s)ctxt=%p\n",
-+	    getpid(), getuid(), geteuid(), audit_event_lookup(event),
-+	    audit_username(), (void *)the_authctxt);
-+	__audit_pidinfo();
-+
-+	switch (event) {
-+	case SSH_AUTH_SUCCESS:		/* authentication success */
-+		logged_in = B_TRUE;
-+		audit_login(); 		/* ADT_ssh; */
-+		return;
-+
-+	case SSH_CONNECTION_CLOSE:	/* connection closed, all done */
-+		if (logged_in) {
-+			audit_logout();		/* ADT_logout; */
-+			logged_in = B_FALSE;
-+		} else {
-+			error("adt audit_event logout without login");
-+		}
-+		return;
-+
-+	/* Translate fail events to Solaris PAM errors */
-+
-+	/* auth2.c: userauth_finish as audit_event(SSH_LOGIN_EXCEED_MAXTRIES) */
-+	/* auth1.c:do_authloop audit_event(SSH_LOGIN_EXCEED_MAXTRIES) */
-+	case SSH_LOGIN_EXCEED_MAXTRIES:
-+		fail = PAM_MAXTRIES;
-+		did_maxtries = B_TRUE;
-+		break;
-+
-+	/* auth2.c: userauth_finish as audit_event(SSH_LOGIN_ROOT_DENIED) */
-+	/* auth1.c:do_authloop audit_event(SSH_LOGIN_ROOT_DENIED) */
-+	case SSH_LOGIN_ROOT_DENIED:
-+		fail = PAM_PERM_DENIED;
-+		break;
-+
-+	/* auth2.c: input_userauth_request as audit_event(SSH_INVALID_USER) */
-+	/* auth.c: getpwnamallow as audit_event(SSH_INVALID_USER) */
-+	case SSH_INVALID_USER:
-+		fail = PAM_USER_UNKNOWN;
-+		break;
-+
-+	/* seems unused, but translate to the Solaris PAM error */
-+	case SSH_NOLOGIN:
-+		fail = PAM_ACCT_EXPIRED;
-+		break;
-+
-+	/*
-+	 * auth.c in auth_log as it's walking through methods calls
-+	 * audit_classify_method(method) which maps
-+	 *
-+	 * none		-> SSH_AUTH_FAIL_NONE
-+	 * password	-> SSH_AUTH_FAIL_PASSWD
-+	 *
-+	 * publickey	-> SSH_AUTH_FAIL_PUBKEY
-+	 * rsa		-> SSH_AUTH_FAIL_PUBKEY
-+	 *
-+	 * keyboard-interactive	-> SSH_AUTH_FAIL_KBDINT
-+	 * challenge-response	-> SSH_AUTH_FAIL_KBDINT
-+	 *
-+	 * hostbased	-> SSH_AUTH_FAIL_HOSTBASED
-+	 * rhosts-rsa	-> SSH_AUTH_FAIL_HOSTBASED
-+	 *
-+	 * gssapi-with-mic	-> SSH_AUTH_FAIL_GSSAPI
-+	 *
-+	 * unknown method	-> SSH_AUDIT_UNKNOWN
-+	 */
-+	/*
-+	 * see mon_table mon_dispatch_proto20[], mon_dispatch_postauth20[],
-+	 * mon_dispatch_proto15[], mon_dispatch_postauth15[]:
-+	 * MONITOR_REQ_AUDIT_EVENT
-+	 * called from monitor.c:mm_answer_audit_event()
-+	 * SSH_AUTH_FAIL_PUBKEY, SSH_AUTH_FAIL_HOSTBASED,
-+	 * SSH_AUTH_FAIL_GSSAPI, SSH_LOGIN_EXCEED_MAXTRIES,
-+	 * SSH_LOGIN_ROOT_DENIED, SSH_CONNECTION_CLOSE SSH_INVALID_USER
-+	 * monitor_wrap.c: mm_audit_event()
-+	 */
-+	case SSH_AUTH_FAIL_NONE:	/* auth type none */
-+	case SSH_AUTH_FAIL_PUBKEY:	/* authtype publickey */
-+		break;
-+
-+	case SSH_AUTH_FAIL_PASSWD:	/* auth type password */
-+	case SSH_AUTH_FAIL_KBDINT:	/* authtype keyboard-interactive */
-+	case SSH_AUTH_FAIL_HOSTBASED:	/* auth type hostbased */
-+	case SSH_AUTH_FAIL_GSSAPI:	/* auth type gssapi-with-mic */
-+	case SSH_AUDIT_UNKNOWN:		/* auth type unknown */
-+		fail = PAM_AUTH_ERR;
-+		break;
-+
-+	/* sshd.c: cleanup_exit: server specific fatal cleanup */
-+	case SSH_CONNECTION_ABANDON:	/* bailing with fatal error */
-+		/*
-+		 * This seems to occur with OpenSSH client when
-+		 * the user login shell exits.
-+		 */
-+		if (logged_in) {
-+			audit_logout();		/* ADT_logout; */
-+			logged_in = B_FALSE;
-+			return;
-+		} else if (!did_maxtries) {
-+			fail = PAM_AUTHINFO_UNAVAIL;
-+		} else {
-+			/* reset saw max tries */
-+			did_maxtries = FALSE;
-+		}
-+		break;
-+
-+	default:
-+		error("adt audit_event: unknown event %d", event);
-+		__auditd_debug("%d/%d:%d-unknown event %d",
-+		    getpid(), getuid(), geteuid(), event);
-+		__audit_pidinfo();
-+		break;
-+	}
-+	audit_fail(fail);
-+}
-+
-+/*
-+ * Called when a user session is started.  Argument is the tty allocated to
-+ * the session, or NULL if no tty was allocated.
-+ *
-+ * Note that this may be called multiple times if multiple sessions are used
-+ * within a single connection.
-+ */
-+/* ARGSUSED */
-+void
-+audit_session_open(struct logininfo *li)
-+{
-+	const char *t = li->line ? li->line : "(no tty)";
-+
-+	debug("adt audit_session_open: user=%s:tty=%s", audit_username(),
-+	    t);
-+	__auditd_debug("%d/%d:%d-adt audit_session_open:ctxt=%p "
-+	    "user=%s:tty=%s\n", getpid(), getuid(), geteuid(),
-+	    (void *)the_authctxt, audit_username(), t);
-+	__audit_pidinfo();
-+}
-+
-+/*
-+ * Called when a user session is closed.  Argument is the tty allocated to
-+ * the session, or NULL if no tty was allocated.
-+ *
-+ * Note that this may be called multiple times if multiple sessions are used
-+ * within a single connection.
-+ */
-+/* ARGSUSED */
-+void
-+audit_session_close(struct logininfo *li)
-+{
-+	const char *t = li->line ? li->line : "(no tty)";
-+
-+	debug("adt audit_session_close: user=%s:tty=%s", audit_username(),
-+	    t);
-+	__auditd_debug("%d/%d:%d-adt audit_session_close:ctxt=%p "
-+	    "user=%s:tty=%s\n", getpid(), getuid(), geteuid(),
-+	    (void *)the_authctxt, audit_username(), t);
-+	__audit_pidinfo();
-+}
-+
-+/*
-+ * This will be called when a user runs a non-interactive command.  Note that
-+ * it may be called multiple times for a single connection since SSH2 allows
-+ * multiple sessions within a single connection.
-+ */
-+/* ARGSUSED */
-+void
-+audit_run_command(const char *command)
-+{
-+	debug("adt audit_run_command: \"%s\"", command);
-+	__auditd_debug("%d/%d:%d-adt audit_run_command:ctxt=%p \"%s\"\n",
-+	    getpid(), getuid(), geteuid(), (void *)the_authctxt, command);
-+	__audit_pidinfo();
-+}
-+
-+/*
-+ * audit_login - audit successful login
-+ *
-+ *	Entry	the_authctxt should be valid ;-)
-+ *		and pam_setcred called.
-+ *		adt_info &  ADT_INFO_PW_SUCCESS if successful
-+ *		password change.
-+ *
-+ *	Exit	ah = audit session established for audit_logout();
-+ */
-+static void
-+audit_login(void)
-+{
-+	adt_event_data_t *event;
-+	uid_t uid = ADT_NO_ATTRIB;
-+	gid_t gid = (gid_t)ADT_NO_ATTRIB;
-+	au_id_t	auid;
-+
-+	if ((the_authctxt != NULL) && (the_authctxt->valid != 0)) {
-+		uid = the_authctxt->pw->pw_uid;
-+		gid = the_authctxt->pw->pw_gid;
-+	}
-+
-+	if (adt_start_session(&ah, NULL, ADT_USE_PROC_DATA) != 0) {
-+		error("adt_start_session: %s", strerror(errno));
-+		return;
-+	}
-+
-+	adt_get_auid(ah, &auid);
-+
-+	if (adt_set_user(ah, uid, gid, uid, gid, NULL,
-+	    auid == AU_NOAUDITID ? ADT_NEW : ADT_USER)) {
-+		error("adt_set_user auid=%d, uid=%d", auid, uid);
-+		(void) adt_end_session(ah);
-+		ah = NULL;
-+		free(tid);
-+		tid = NULL;
-+		return;
-+	}
-+	if ((event = adt_alloc_event(ah, ADT_ssh)) == NULL) {
-+		error("adt_alloc_event(ADT_ssh): %s", strerror(errno));
-+		return;
-+	}
-+	if (adt_put_event(event, ADT_SUCCESS, ADT_SUCCESS) != 0) {
-+		error("adt_put_event(ADT_ssh, ADT_SUCCESS): %s",
-+		    strerror(errno));
-+	}
-+	/* should audit successful password change here */
-+	adt_free_event(event);
-+}
-+
-+/*
-+ * audit_logout - audit the logout
-+ *
-+ *	Entry	ah = audit session.
-+ */
-+static void
-+audit_logout(void)
-+{
-+	adt_event_data_t *event;
-+
-+	if ((event = adt_alloc_event(ah, ADT_logout)) == NULL) {
-+		error("adt_alloc_event(ADT_logout): %s", strerror(errno));
-+		return;
-+	}
-+	if (adt_put_event(event, ADT_SUCCESS, ADT_SUCCESS) != 0) {
-+		error("adt_put_event(ADT_logout, ADT_SUCCESS): %s",
-+		    strerror(errno));
-+	}
-+	adt_free_event(event);
-+	(void) adt_end_session(ah);
-+	ah = NULL;
-+	free(tid);
-+	tid = NULL;
-+}
-+
-+/*
-+ * audit_fail - audit login failure.
-+ *
-+ *	Entry	the_authctxt assumed to have some info.
-+ *			user = user who asked to be authenticated.
-+ *		tid = connection audit TID set by audit_connect_from();
-+ *
-+ *	N.B.	pam_strerror() prototype takes a pam handle and error number.
-+ *		At least on Solaris, pam_strerror never uses the pam handle.
-+ *		Since there doesn't seem to be a pam handle available, this
-+ *		code just uses NULL.
-+ */
-+static void
-+audit_fail(int pamerr)
-+{
-+	adt_session_data_t *ah = NULL;
-+	adt_event_data_t *event;
-+	uid_t	uid = ADT_NO_ATTRIB;
-+	gid_t	gid = (gid_t)ADT_NO_ATTRIB;
-+
-+	__auditd_debug("%d/%d:%d-audit_fail(%s) ctxt=%p\n",
-+	    getpid(), getuid(), geteuid(), pam_strerror(NULL, pamerr),
-+	    (void *)the_authctxt);
-+	if (the_authctxt != NULL) {
-+		uid_t 	pwuid = ADT_NO_ATTRIB;
-+
-+		if (the_authctxt->pw != NULL) {
-+			pwuid = the_authctxt->pw->pw_uid;
-+		}
-+		__auditd_debug("valid=%d, user=%s, uid=%d\n",
-+		    the_authctxt->valid, audit_username(), pwuid);
-+	} else {
-+		__auditd_debug("\tNo autxctxt\n");
-+	}
-+	__audit_pidinfo();
-+	if (pamerr == PAM_IGNORE) {
-+		return;
-+	}
-+	if ((the_authctxt != NULL) && (the_authctxt->valid != 0)) {
-+		uid = the_authctxt->pw->pw_uid;
-+		gid = the_authctxt->pw->pw_gid;
-+	} else if ((the_authctxt != NULL) && (the_authctxt->user != NULL)) {
-+		struct passwd *pw;
-+
-+		if ((pw = getpwnam(the_authctxt->user)) != NULL) {
-+			uid = pw->pw_uid;
-+			gid = pw->pw_gid;
-+		}
-+	}
-+	if (adt_start_session(&ah, NULL, 0) != 0) {
-+		error("adt_start_session(ADT_ssh, 0, fail=%s):"
-+		    " %s", pam_strerror(NULL, pamerr), strerror(errno));
-+		__auditd_debug("%d/%d:%d-adt_start_session(ADT_ssh, "
-+		    "PROC_DATA, fail=%s): %s", getpid(), getuid(),
-+		    geteuid(), pam_strerror(NULL, pamerr),
-+		    strerror(errno));
-+		return;
-+	}
-+	__auditd_debug("%d/%d:%d-audit_fail+start_session() ah=%p\n",
-+	    getpid(), getuid(), geteuid(), (void *)ah);
-+	if (adt_set_user(ah, uid, gid, uid, gid, tid, ADT_NEW) != 0) {
-+		error("adt_set_user(ADT_ssh, PROC_DATA, fail=%s): %s",
-+		    pam_strerror(NULL, pamerr), strerror(errno));
-+		__auditd_debug("%d/%d:%d-adt_set_user(ADT_ssh, "
-+		    "PROC_DATA, fail=%s): %s", getpid(), getuid(),
-+		    geteuid(), pam_strerror(NULL, pamerr),
-+		    strerror(errno));
-+		goto done;
-+	}
-+	__auditd_debug("%d/%d:%d-audit_fail+set_user() ah=%p\n", getpid(),
-+	    getuid(), geteuid(), (void *)ah);
-+	if ((event = adt_alloc_event(ah, ADT_ssh)) == NULL) {
-+		error("adt_alloc_event(ADT_ssh, fail=%s): %s",
-+		    pam_strerror(NULL, pamerr), strerror(errno));
-+		__auditd_debug("%d/%d:%d-adt_set_user(ADT_ssh, 0, "
-+		    "fail=%s): %s", getpid(), getuid(), geteuid(),
-+		    pam_strerror(NULL, pamerr), strerror(errno));
-+	} else if (adt_put_event(event, ADT_FAILURE,
-+	    ADT_FAIL_PAM + pamerr) != 0) {
-+		error("adt_put_event(ADT_ssh, fail=%s): %s",
-+		    pam_strerror(NULL, pamerr), strerror(errno));
-+		__auditd_debug("%d/%d:%d-adt_put_event(ADT_ssh, fail=%s): %s",
-+		    getpid(), getuid(), geteuid(), pam_strerror(NULL, pamerr),
-+		    strerror(errno));
-+	}
-+	__auditd_debug("%d/%d:%d-audit_fail+put_event() ah=%p\n", getpid(),
-+	    getuid(), geteuid(), (void *)ah);
-+	/* should audit authentication with failed password change here. */
-+	adt_free_event(event);
-+done:
-+	(void) adt_end_session(ah);
-+}
-+#endif	/* USE_SOLARIS_AUDIT */
-diff --git a/configure.ac b/configure.ac
-index 81edc01..27b95cb 100644
---- a/configure.ac
-+++ b/configure.ac
-@@ -1518,7 +1518,7 @@ AC_ARG_WITH([libedit],
- 
- AUDIT_MODULE=none
- AC_ARG_WITH([audit],
--	[  --with-audit=module     Enable audit support (modules=debug,bsm,linux)],
-+	[  --with-audit=module     Enable audit support (modules=debug,bsm,linux,solaris)],
- 	[
- 	  AC_MSG_CHECKING([for supported audit module])
- 	  case "$withval" in
-@@ -1555,6 +1555,13 @@ AC_ARG_WITH([audit],
- 		SSHDLIBS="$SSHDLIBS -laudit"
- 		AC_DEFINE([USE_LINUX_AUDIT], [1], [Use Linux audit module])
- 		;;
-+      solaris)
-+        AC_MSG_RESULT([solaris])
-+        AUDIT_MODULE=solaris
-+        AC_CHECK_HEADERS([bsm/adt.h])
-+        SSHDLIBS="$SSHDLIBS -lbsm"
-+        AC_DEFINE([USE_SOLARIS_AUDIT], [1], [Use Solaris audit module])
-+        ;;
- 	  debug)
- 		AUDIT_MODULE=debug
- 		AC_MSG_RESULT([debug])
-diff --git a/defines.h b/defines.h
-index fa0ccba..f2c1678 100644
---- a/defines.h
-+++ b/defines.h
-@@ -635,6 +635,11 @@ struct winsize {
- # define CUSTOM_SSH_AUDIT_EVENTS
- #endif
- 
-+#ifdef USE_SOLARIS_AUDIT
-+# define SSH_AUDIT_EVENTS
-+# define CUSTOM_SSH_AUDIT_EVENTS
-+#endif
-+
- #if !defined(HAVE___func__) && defined(HAVE___FUNCTION__)
- #  define __func__ __FUNCTION__
- #elif !defined(HAVE___func__)
-diff --git a/sshd.c b/sshd.c
-index 5a00ae2..f577f75 100644
---- a/sshd.c
-+++ b/sshd.c
-@@ -2228,7 +2228,9 @@ main(int ac, char **av)
- 	}
- 
- #ifdef SSH_AUDIT_EVENTS
-+#ifndef	USE_SOLARIS_AUDIT
- 	audit_event(SSH_AUTH_SUCCESS);
-+#endif	/* !USE_SOLARIS_AUDIT */
- #endif
- 
- #ifdef GSSAPI
-@@ -2258,6 +2260,10 @@ main(int ac, char **av)
- 		do_pam_session();
- 	}
- #endif
-+#ifdef	USE_SOLARIS_AUDIT
-+	/* Audit should take place after all successful pam */
-+	audit_event(SSH_AUTH_SUCCESS);
-+#endif	/* USE_SOLARIS_AUDIT */
- 
- 	/*
- 	 * In privilege separation, we fork another child and prepare
--- 
-2.3.2 (Apple Git-55)
-
--- /dev/null	Wed Feb 10 16:25:01 2016
+++ new/build/openssh/patches/0015-Solaris-Auditing-support.patch	Wed Feb 10 16:25:01 2016
@@ -0,0 +1,748 @@
+From b60fe491735349ba901b371dc8a0d1cd5ab163da Mon Sep 17 00:00:00 2001
+From: oracle <solaris@oracle.com>
+Date: Mon, 3 Aug 2015 14:37:01 -0700
+Subject: [PATCH 15/36] Solaris Auditing support
+
+#
+# Add Solaris Auditing configuration (--with-audit=solaris) to openssh-6.5p1.
+#
+# Add phase 1 Solaris Auditing of sshd login/logout to openssh-6.5p1.
+#
+# Additional Solaris Auditing should include audit of password
+#  change.
+# Presuming it is appropriate, this patch should/will be updated
+#  with additional files and updates to sources/audit-solaris.c
+#
+# Code is developed by the Solaris Audit team.
+# It should/will likely be contributed up stream when done.
+# This patch relies on sources/audit-solaris.c being copied into
+#  the openssh source directory by the Makefile that configures
+#  using --with-audit=solaris.
+#
+# The up stream community has been contacted about the plans.
+#  No reply has yet been received.
+#
+# An additional patch relying on the --with-audit=solaris configuration
+#  should/will be created for sftp Solaris Audit and password change.
+#
+---
+ INSTALL         |  15 +-
+ Makefile.in     |   2 +-
+ README.platform |   7 +-
+ audit-solaris.c | 562 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ configure.ac    |   9 +-
+ defines.h       |   5 +
+ sshd.c          |   6 +
+ 7 files changed, 597 insertions(+), 9 deletions(-)
+ create mode 100644 audit-solaris.c
+
+diff --git a/INSTALL b/INSTALL
+index cbbb2df..765d4aa 100644
+--- a/INSTALL
++++ b/INSTALL
+@@ -92,9 +92,13 @@ http://www.gnu.org/software/autoconf/
+ 
+ Basic Security Module (BSM):
+ 
+-Native BSM support is know to exist in Solaris from at least 2.5.1,
+-FreeBSD 6.1 and OS X.  Alternatively, you may use the OpenBSM
+-implementation (http://www.openbsm.org).
++Native BSM support is known to exist in Solaris from at least 2.5.1
++to Solaris 10.  From Solaris 11 the previously documented BSM (libbsm)
++interfaces are no longer public and are unsupported.  While not public
++interfaces, audit-solaris.c implements Solaris Audit from Solaris 11.
++Native BSM support is known to exist in FreeBSD 6.1 and OS X.
++Alternatively, you may use the OpenBSM implementation
++(http://www.openbsm.org).
+ 
+ 
+ 2. Building / Installation
+@@ -147,8 +151,9 @@ name).
+ There are a few other options to the configure script:
+ 
+ --with-audit=[module] enable additional auditing via the specified module.
+-Currently, drivers for "debug" (additional info via syslog) and "bsm"
+-(Sun's Basic Security Module) are supported.
++Currently, drivers for "debug" (additional info via syslog), and "bsm"
++(Sun's Legacy Basic Security Module prior to Solaris 11), and "solaris"
++(Sun's Audit infrastructure from Solaris 11) are supported.
+ 
+ --with-pam enables PAM support. If PAM support is compiled in, it must
+ also be enabled in sshd_config (refer to the UsePAM directive).
+diff --git a/Makefile.in b/Makefile.in
+index 121a261..62e6a84 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -101,7 +101,7 @@ SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \
+ 	roaming_common.o roaming_client.o
+ 
+ SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \
+-	audit.o audit-bsm.o audit-linux.o platform.o \
++	audit.o audit-bsm.o audit-linux.o audit-solaris.o platform.o \
+ 	sshpty.o sshlogin.o servconf.o serverloop.o \
+ 	auth.o auth1.o auth2.o auth-options.o session.o \
+ 	auth-chall.o auth2-chall.o groupaccess.o \
+diff --git a/README.platform b/README.platform
+index d198232..6949998 100644
+--- a/README.platform
++++ b/README.platform
+@@ -68,8 +68,8 @@ zlib-devel and pam-devel, on Debian based distros these may be
+ libssl-dev, libz-dev and libpam-dev.
+ 
+ 
+-Solaris
+--------
++Prior to Solaris 11
++-------------------
+ If you enable BSM auditing on Solaris, you need to update audit_event(4)
+ for praudit(1m) to give sensible output.  The following line needs to be
+ added to /etc/security/audit_event:
+@@ -82,6 +82,9 @@ There is no official registry of 3rd party event numbers, so if this
+ number is already in use on your system, you may change it at build time
+ by configure'ing --with-cflags=-DAUE_openssh=32801 then rebuilding.
+ 
++From Solaris 11
++---------------
++Solaris Audit is supported by configuring --with-audit=solaris.
+ 
+ Platforms using PAM
+ -------------------
+diff --git a/audit-solaris.c b/audit-solaris.c
+new file mode 100644
+index 0000000..abf870c
+--- /dev/null
++++ b/audit-solaris.c
+@@ -0,0 +1,562 @@
++/*
++ * CDDL HEADER START
++ *
++ * The contents of this file are subject to the terms of the
++ * Common Development and Distribution License (the "License").
++ * You may not use this file except in compliance with the License.
++ *
++ * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
++ * or http://www.opensolaris.org/os/licensing.
++ * See the License for the specific language governing permissions
++ * and limitations under the License.
++ *
++ * When distributing Covered Code, include this CDDL HEADER in each
++ * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
++ * If applicable, add the following below this CDDL HEADER, with the
++ * fields enclosed by brackets "[]" replaced with your own identifying
++ * information: Portions Copyright [yyyy] [name of copyright owner]
++ *
++ * CDDL HEADER END
++ */
++
++/*
++ * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved.
++ */
++
++#include "includes.h"
++#if defined(USE_SOLARIS_AUDIT)
++
++#include "audit.h"
++#include "buffer.h"
++#include "key.h"
++#include "hostfile.h"
++#include "auth.h"
++#include "log.h"
++#include "packet.h"
++
++#include <errno.h>
++#include <pwd.h>
++#include <string.h>
++
++#include <bsm/adt.h>
++#include <bsm/adt_event.h>
++
++#ifdef	ADT_DEBUG
++#include <bsm/audit.h>
++#include <arpa/inet.h>
++#include <netinet/in.h>
++#include <values.h>
++#include <errno.h>
++#include <pwd.h>
++#include <stdio.h>
++#include <unistd.h>
++#include <stdarg.h>
++#include <string.h>
++#include <ucred.h>
++#include <values.h>
++
++#include <bsm/adt.h>
++#include <bsm/audit.h>
++
++#include <sys/types.h>
++#include <sys/stat.h>
++
++/* semi private adt functions to extract information */
++
++extern void adt_get_asid(const adt_session_data_t *, au_asid_t *);
++extern void adt_get_auid(const adt_session_data_t *, au_id_t *);
++extern void adt_get_mask(const adt_session_data_t *, au_mask_t *);
++extern void adt_get_termid(const adt_session_data_t *, au_tid_addr_t *);
++
++extern void __auditd_debug(char *, ...);
++
++void
++__audit_pidinfo(void)
++{
++	adt_session_data_t *ah = NULL;
++	au_id_t	auid;
++	char *auid_name = "badname";
++	struct passwd *pwd;
++	au_asid_t asid;
++	au_mask_t mask;
++	char flags[512];
++	au_tid_addr_t tid;
++	char	pbuf[INET6_ADDRSTRLEN];
++	int	af = AF_INET;
++	int	remote;
++	int	local;
++
++	if (adt_start_session(&ah, NULL, ADT_USE_PROC_DATA) != 0) {
++		__auditd_debug("cannot start session %s\n", strerror(errno));
++		return;
++	}
++	if (ah == NULL) {
++		__auditd_debug("ah is NULL\n");
++		return;
++	}
++	adt_get_auid(ah, &auid);
++	if ((pwd = getpwuid((uid_t)auid)) != NULL) {
++		auid_name = pwd->pw_name;
++	}
++	__auditd_debug("audit id = %s(%d)\n", auid_name, auid);
++
++	adt_get_mask(ah, &mask);
++	if (getauditflagschar(flags, &mask, NULL) < 0) {
++		(void) strlcpy(flags, "badflags", sizeof (flags));
++	}
++#ifdef	_LP64
++	__auditd_debug("preselection mask = %s(0x%lx,0x%lx)\n", flags,
++	    mask.am_success, mask.am_failure);
++#else	/* _ILP32 */
++	__auditd_debug("preselection mask = %s(0x%llx,0x%llx)\n", flags,
++	    mask.am_success, mask.am_failure);
++#endif	/* _LP64 */
++
++	adt_get_termid(ah, &tid);
++	__auditd_debug("tid type=%d, maj=%u, min=%u, addr=%x:%x:%x:%x\n",
++	    tid.at_type,
++	    (uint16_t)((tid.at_port) >> BITS(uint16_t)),
++	    (uint16_t)(tid.at_port & UINT16_MAX),
++	    tid.at_addr[0],
++	    tid.at_addr[1],
++	    tid.at_addr[2],
++	    tid.at_addr[3]);
++	if (tid.at_type == AU_IPv6) {
++		af = AF_INET6;
++	}
++	(void) inet_ntop(af, (void *)(tid.at_addr), pbuf,
++	    sizeof (pbuf));
++	remote = (tid.at_port >> BITS(uint16_t));
++	local = (tid.at_port & UINT16_MAX);
++	__auditd_debug("tid type-%d (remote,local,host)= %u,%u,%s\n",
++	    tid.at_type, remote, local, pbuf);
++	adt_get_asid(ah, &asid);
++	__auditd_debug("audit session id = %u\n",  asid);
++	(void) adt_end_session(ah);
++}
++#else	/* !ADT_DEBUG */
++/*ARGSUSED*/
++/*PRINTFLIKE1*/
++static void
++__auditd_debug(char *fmt, ...)
++{
++}
++static void
++__audit_pidinfo()
++{
++}
++#endif	/* ADT_DEBUG */
++
++#include <security/pam_appl.h>
++
++#include <sys/types.h>
++
++extern Authctxt *the_authctxt;
++
++extern const char *audit_username(void);
++extern const char *audit_event_lookup(ssh_audit_event_t);
++
++static adt_session_data_t *ah = NULL;		/* audit session handle */
++static adt_termid_t	*tid = NULL;		/* peer terminal id */
++
++static void audit_login(void);
++static void audit_logout(void);
++static void audit_fail(int);
++
++/* Below is the sshd audit API Solaris adt interpretation */
++
++/*
++ * Called after a connection has been accepted but before any authentication
++ * has been attempted.
++ */
++/* ARGSUSED */
++void
++audit_connection_from(const char *host, int port)
++{
++	int peer = packet_get_connection_in();
++	adt_session_data_t	*ah;
++
++	if (adt_load_termid(peer, &tid) != 0) {
++		error("adt audit_connection_from: unable to load tid for %d:%s",
++		    peer, strerror(errno));
++	}
++	if (adt_start_session(&ah, NULL, 0) != 0) {
++		error("adt audit_connection_from: unable to start session "
++		    "for %s:%d:%s", host, port, strerror(errno));
++	}
++	if (adt_set_user(ah, ADT_NO_AUDIT, ADT_NO_AUDIT, 0,
++	    ADT_NO_AUDIT, tid, ADT_SETTID) != 0) {
++		error("adt audit_connection_from: unable to set user "
++		    "for %s:%d:%s", host, port, strerror(errno));
++		(void) adt_end_session(ah);
++		ah = NULL;
++	}
++	if (adt_set_proc(ah) != 0) {
++		error("adt audit_connection_from: unable to set proc "
++		    "for %s:%d:%s", host, port, strerror(errno));
++	}
++	(void) adt_end_session(ah);
++	debug("adt audit_connection_from(%s, %d): peerfd=%d", host, port,
++	    peer);
++	__auditd_debug("%d/%d:%d-adt audit_connection_from(%s, %d)ctxt=%p: "
++	    "peerfd=%d\n", getpid(), getuid(), geteuid(), host, port,
++	    (void *)the_authctxt, peer);
++	__audit_pidinfo();
++}
++
++/*
++ * Called when various events occur (see audit.h for a list of possible
++ * events and what they mean).
++ *
++ *	Entry	the_authcntxt
++ */
++void
++audit_event(ssh_audit_event_t event)
++{
++	static boolean_t logged_in = B_FALSE;	/* if user did login */
++	int fail = PAM_IGNORE;		/* default unset */
++	static boolean_t did_maxtries = B_FALSE; /* if interactive and abort */
++
++	debug("adt audit_event(%s)", audit_event_lookup(event));
++	__auditd_debug("%d/%d:%d-adt audit_event(%s/%s)ctxt=%p\n",
++	    getpid(), getuid(), geteuid(), audit_event_lookup(event),
++	    audit_username(), (void *)the_authctxt);
++	__audit_pidinfo();
++
++	switch (event) {
++	case SSH_AUTH_SUCCESS:		/* authentication success */
++		logged_in = B_TRUE;
++		audit_login(); 		/* ADT_ssh; */
++		return;
++
++	case SSH_CONNECTION_CLOSE:	/* connection closed, all done */
++		if (logged_in) {
++			audit_logout();		/* ADT_logout; */
++			logged_in = B_FALSE;
++		} else {
++			error("adt audit_event logout without login");
++		}
++		return;
++
++	/* Translate fail events to Solaris PAM errors */
++
++	/* auth2.c: userauth_finish as audit_event(SSH_LOGIN_EXCEED_MAXTRIES) */
++	/* auth1.c:do_authloop audit_event(SSH_LOGIN_EXCEED_MAXTRIES) */
++	case SSH_LOGIN_EXCEED_MAXTRIES:
++		fail = PAM_MAXTRIES;
++		did_maxtries = B_TRUE;
++		break;
++
++	/* auth2.c: userauth_finish as audit_event(SSH_LOGIN_ROOT_DENIED) */
++	/* auth1.c:do_authloop audit_event(SSH_LOGIN_ROOT_DENIED) */
++	case SSH_LOGIN_ROOT_DENIED:
++		fail = PAM_PERM_DENIED;
++		break;
++
++	/* auth2.c: input_userauth_request as audit_event(SSH_INVALID_USER) */
++	/* auth.c: getpwnamallow as audit_event(SSH_INVALID_USER) */
++	case SSH_INVALID_USER:
++		fail = PAM_USER_UNKNOWN;
++		break;
++
++	/* seems unused, but translate to the Solaris PAM error */
++	case SSH_NOLOGIN:
++		fail = PAM_ACCT_EXPIRED;
++		break;
++
++	/*
++	 * auth.c in auth_log as it's walking through methods calls
++	 * audit_classify_method(method) which maps
++	 *
++	 * none		-> SSH_AUTH_FAIL_NONE
++	 * password	-> SSH_AUTH_FAIL_PASSWD
++	 *
++	 * publickey	-> SSH_AUTH_FAIL_PUBKEY
++	 * rsa		-> SSH_AUTH_FAIL_PUBKEY
++	 *
++	 * keyboard-interactive	-> SSH_AUTH_FAIL_KBDINT
++	 * challenge-response	-> SSH_AUTH_FAIL_KBDINT
++	 *
++	 * hostbased	-> SSH_AUTH_FAIL_HOSTBASED
++	 * rhosts-rsa	-> SSH_AUTH_FAIL_HOSTBASED
++	 *
++	 * gssapi-with-mic	-> SSH_AUTH_FAIL_GSSAPI
++	 *
++	 * unknown method	-> SSH_AUDIT_UNKNOWN
++	 */
++	/*
++	 * see mon_table mon_dispatch_proto20[], mon_dispatch_postauth20[],
++	 * mon_dispatch_proto15[], mon_dispatch_postauth15[]:
++	 * MONITOR_REQ_AUDIT_EVENT
++	 * called from monitor.c:mm_answer_audit_event()
++	 * SSH_AUTH_FAIL_PUBKEY, SSH_AUTH_FAIL_HOSTBASED,
++	 * SSH_AUTH_FAIL_GSSAPI, SSH_LOGIN_EXCEED_MAXTRIES,
++	 * SSH_LOGIN_ROOT_DENIED, SSH_CONNECTION_CLOSE SSH_INVALID_USER
++	 * monitor_wrap.c: mm_audit_event()
++	 */
++	case SSH_AUTH_FAIL_NONE:	/* auth type none */
++	case SSH_AUTH_FAIL_PUBKEY:	/* authtype publickey */
++		break;
++
++	case SSH_AUTH_FAIL_PASSWD:	/* auth type password */
++	case SSH_AUTH_FAIL_KBDINT:	/* authtype keyboard-interactive */
++	case SSH_AUTH_FAIL_HOSTBASED:	/* auth type hostbased */
++	case SSH_AUTH_FAIL_GSSAPI:	/* auth type gssapi-with-mic */
++	case SSH_AUDIT_UNKNOWN:		/* auth type unknown */
++		fail = PAM_AUTH_ERR;
++		break;
++
++	/* sshd.c: cleanup_exit: server specific fatal cleanup */
++	case SSH_CONNECTION_ABANDON:	/* bailing with fatal error */
++		/*
++		 * This seems to occur with OpenSSH client when
++		 * the user login shell exits.
++		 */
++		if (logged_in) {
++			audit_logout();		/* ADT_logout; */
++			logged_in = B_FALSE;
++			return;
++		} else if (!did_maxtries) {
++			fail = PAM_AUTHINFO_UNAVAIL;
++		} else {
++			/* reset saw max tries */
++			did_maxtries = FALSE;
++		}
++		break;
++
++	default:
++		error("adt audit_event: unknown event %d", event);
++		__auditd_debug("%d/%d:%d-unknown event %d",
++		    getpid(), getuid(), geteuid(), event);
++		__audit_pidinfo();
++		break;
++	}
++	audit_fail(fail);
++}
++
++/*
++ * Called when a user session is started.  Argument is the tty allocated to
++ * the session, or NULL if no tty was allocated.
++ *
++ * Note that this may be called multiple times if multiple sessions are used
++ * within a single connection.
++ */
++/* ARGSUSED */
++void
++audit_session_open(struct logininfo *li)
++{
++	const char *t = li->line ? li->line : "(no tty)";
++
++	debug("adt audit_session_open: user=%s:tty=%s", audit_username(),
++	    t);
++	__auditd_debug("%d/%d:%d-adt audit_session_open:ctxt=%p "
++	    "user=%s:tty=%s\n", getpid(), getuid(), geteuid(),
++	    (void *)the_authctxt, audit_username(), t);
++	__audit_pidinfo();
++}
++
++/*
++ * Called when a user session is closed.  Argument is the tty allocated to
++ * the session, or NULL if no tty was allocated.
++ *
++ * Note that this may be called multiple times if multiple sessions are used
++ * within a single connection.
++ */
++/* ARGSUSED */
++void
++audit_session_close(struct logininfo *li)
++{
++	const char *t = li->line ? li->line : "(no tty)";
++
++	debug("adt audit_session_close: user=%s:tty=%s", audit_username(),
++	    t);
++	__auditd_debug("%d/%d:%d-adt audit_session_close:ctxt=%p "
++	    "user=%s:tty=%s\n", getpid(), getuid(), geteuid(),
++	    (void *)the_authctxt, audit_username(), t);
++	__audit_pidinfo();
++}
++
++/*
++ * This will be called when a user runs a non-interactive command.  Note that
++ * it may be called multiple times for a single connection since SSH2 allows
++ * multiple sessions within a single connection.
++ */
++/* ARGSUSED */
++void
++audit_run_command(const char *command)
++{
++	debug("adt audit_run_command: \"%s\"", command);
++	__auditd_debug("%d/%d:%d-adt audit_run_command:ctxt=%p \"%s\"\n",
++	    getpid(), getuid(), geteuid(), (void *)the_authctxt, command);
++	__audit_pidinfo();
++}
++
++/*
++ * audit_login - audit successful login
++ *
++ *	Entry	the_authctxt should be valid ;-)
++ *		and pam_setcred called.
++ *		adt_info &  ADT_INFO_PW_SUCCESS if successful
++ *		password change.
++ *
++ *	Exit	ah = audit session established for audit_logout();
++ */
++static void
++audit_login(void)
++{
++	adt_event_data_t *event;
++	uid_t uid = ADT_NO_ATTRIB;
++	gid_t gid = (gid_t)ADT_NO_ATTRIB;
++	au_id_t	auid;
++
++	if ((the_authctxt != NULL) && (the_authctxt->valid != 0)) {
++		uid = the_authctxt->pw->pw_uid;
++		gid = the_authctxt->pw->pw_gid;
++	}
++
++	if (adt_start_session(&ah, NULL, ADT_USE_PROC_DATA) != 0) {
++		error("adt_start_session: %s", strerror(errno));
++		return;
++	}
++
++	adt_get_auid(ah, &auid);
++
++	if (adt_set_user(ah, uid, gid, uid, gid, NULL,
++	    auid == AU_NOAUDITID ? ADT_NEW : ADT_USER)) {
++		error("adt_set_user auid=%d, uid=%d", auid, uid);
++		(void) adt_end_session(ah);
++		ah = NULL;
++		free(tid);
++		tid = NULL;
++		return;
++	}
++	if ((event = adt_alloc_event(ah, ADT_ssh)) == NULL) {
++		error("adt_alloc_event(ADT_ssh): %s", strerror(errno));
++		return;
++	}
++	if (adt_put_event(event, ADT_SUCCESS, ADT_SUCCESS) != 0) {
++		error("adt_put_event(ADT_ssh, ADT_SUCCESS): %s",
++		    strerror(errno));
++	}
++	/* should audit successful password change here */
++	adt_free_event(event);
++}
++
++/*
++ * audit_logout - audit the logout
++ *
++ *	Entry	ah = audit session.
++ */
++static void
++audit_logout(void)
++{
++	adt_event_data_t *event;
++
++	if ((event = adt_alloc_event(ah, ADT_logout)) == NULL) {
++		error("adt_alloc_event(ADT_logout): %s", strerror(errno));
++		return;
++	}
++	if (adt_put_event(event, ADT_SUCCESS, ADT_SUCCESS) != 0) {
++		error("adt_put_event(ADT_logout, ADT_SUCCESS): %s",
++		    strerror(errno));
++	}
++	adt_free_event(event);
++	(void) adt_end_session(ah);
++	ah = NULL;
++	free(tid);
++	tid = NULL;
++}
++
++/*
++ * audit_fail - audit login failure.
++ *
++ *	Entry	the_authctxt assumed to have some info.
++ *			user = user who asked to be authenticated.
++ *		tid = connection audit TID set by audit_connect_from();
++ *
++ *	N.B.	pam_strerror() prototype takes a pam handle and error number.
++ *		At least on Solaris, pam_strerror never uses the pam handle.
++ *		Since there doesn't seem to be a pam handle available, this
++ *		code just uses NULL.
++ */
++static void
++audit_fail(int pamerr)
++{
++	adt_session_data_t *ah = NULL;
++	adt_event_data_t *event;
++	uid_t	uid = ADT_NO_ATTRIB;
++	gid_t	gid = (gid_t)ADT_NO_ATTRIB;
++
++	__auditd_debug("%d/%d:%d-audit_fail(%s) ctxt=%p\n",
++	    getpid(), getuid(), geteuid(), pam_strerror(NULL, pamerr),
++	    (void *)the_authctxt);
++	if (the_authctxt != NULL) {
++		uid_t 	pwuid = ADT_NO_ATTRIB;
++
++		if (the_authctxt->pw != NULL) {
++			pwuid = the_authctxt->pw->pw_uid;
++		}
++		__auditd_debug("valid=%d, user=%s, uid=%d\n",
++		    the_authctxt->valid, audit_username(), pwuid);
++	} else {
++		__auditd_debug("\tNo autxctxt\n");
++	}
++	__audit_pidinfo();
++	if (pamerr == PAM_IGNORE) {
++		return;
++	}
++	if ((the_authctxt != NULL) && (the_authctxt->valid != 0)) {
++		uid = the_authctxt->pw->pw_uid;
++		gid = the_authctxt->pw->pw_gid;
++	} else if ((the_authctxt != NULL) && (the_authctxt->user != NULL)) {
++		struct passwd *pw;
++
++		if ((pw = getpwnam(the_authctxt->user)) != NULL) {
++			uid = pw->pw_uid;
++			gid = pw->pw_gid;
++		}
++	}
++	if (adt_start_session(&ah, NULL, 0) != 0) {
++		error("adt_start_session(ADT_ssh, 0, fail=%s):"
++		    " %s", pam_strerror(NULL, pamerr), strerror(errno));
++		__auditd_debug("%d/%d:%d-adt_start_session(ADT_ssh, "
++		    "PROC_DATA, fail=%s): %s", getpid(), getuid(),
++		    geteuid(), pam_strerror(NULL, pamerr),
++		    strerror(errno));
++		return;
++	}
++	__auditd_debug("%d/%d:%d-audit_fail+start_session() ah=%p\n",
++	    getpid(), getuid(), geteuid(), (void *)ah);
++	if (adt_set_user(ah, uid, gid, uid, gid, tid, ADT_NEW) != 0) {
++		error("adt_set_user(ADT_ssh, PROC_DATA, fail=%s): %s",
++		    pam_strerror(NULL, pamerr), strerror(errno));
++		__auditd_debug("%d/%d:%d-adt_set_user(ADT_ssh, "
++		    "PROC_DATA, fail=%s): %s", getpid(), getuid(),
++		    geteuid(), pam_strerror(NULL, pamerr),
++		    strerror(errno));
++		goto done;
++	}
++	__auditd_debug("%d/%d:%d-audit_fail+set_user() ah=%p\n", getpid(),
++	    getuid(), geteuid(), (void *)ah);
++	if ((event = adt_alloc_event(ah, ADT_ssh)) == NULL) {
++		error("adt_alloc_event(ADT_ssh, fail=%s): %s",
++		    pam_strerror(NULL, pamerr), strerror(errno));
++		__auditd_debug("%d/%d:%d-adt_set_user(ADT_ssh, 0, "
++		    "fail=%s): %s", getpid(), getuid(), geteuid(),
++		    pam_strerror(NULL, pamerr), strerror(errno));
++	} else if (adt_put_event(event, ADT_FAILURE,
++	    ADT_FAIL_PAM + pamerr) != 0) {
++		error("adt_put_event(ADT_ssh, fail=%s): %s",
++		    pam_strerror(NULL, pamerr), strerror(errno));
++		__auditd_debug("%d/%d:%d-adt_put_event(ADT_ssh, fail=%s): %s",
++		    getpid(), getuid(), geteuid(), pam_strerror(NULL, pamerr),
++		    strerror(errno));
++	}
++	__auditd_debug("%d/%d:%d-audit_fail+put_event() ah=%p\n", getpid(),
++	    getuid(), geteuid(), (void *)ah);
++	/* should audit authentication with failed password change here. */
++	adt_free_event(event);
++done:
++	(void) adt_end_session(ah);
++}
++#endif	/* USE_SOLARIS_AUDIT */
+diff --git a/configure.ac b/configure.ac
+index 2985819..b38b1b3 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1547,7 +1547,7 @@ AC_ARG_WITH([libedit],
+ 
+ AUDIT_MODULE=none
+ AC_ARG_WITH([audit],
+-	[  --with-audit=module     Enable audit support (modules=debug,bsm,linux)],
++	[  --with-audit=module     Enable audit support (modules=debug,bsm,linux,solaris)],
+ 	[
+ 	  AC_MSG_CHECKING([for supported audit module])
+ 	  case "$withval" in
+@@ -1584,6 +1584,13 @@ AC_ARG_WITH([audit],
+ 		SSHDLIBS="$SSHDLIBS -laudit"
+ 		AC_DEFINE([USE_LINUX_AUDIT], [1], [Use Linux audit module])
+ 		;;
++      solaris)
++        AC_MSG_RESULT([solaris])
++        AUDIT_MODULE=solaris
++        AC_CHECK_HEADERS([bsm/adt.h])
++        SSHDLIBS="$SSHDLIBS -lbsm"
++        AC_DEFINE([USE_SOLARIS_AUDIT], [1], [Use Solaris audit module])
++        ;;
+ 	  debug)
+ 		AUDIT_MODULE=debug
+ 		AC_MSG_RESULT([debug])
+diff --git a/defines.h b/defines.h
+index fa0ccba..f2c1678 100644
+--- a/defines.h
++++ b/defines.h
+@@ -635,6 +635,11 @@ struct winsize {
+ # define CUSTOM_SSH_AUDIT_EVENTS
+ #endif
+ 
++#ifdef USE_SOLARIS_AUDIT
++# define SSH_AUDIT_EVENTS
++# define CUSTOM_SSH_AUDIT_EVENTS
++#endif
++
+ #if !defined(HAVE___func__) && defined(HAVE___FUNCTION__)
+ #  define __func__ __FUNCTION__
+ #elif !defined(HAVE___func__)
+diff --git a/sshd.c b/sshd.c
+index 7e519d4..87032ec 100644
+--- a/sshd.c
++++ b/sshd.c
+@@ -2234,7 +2234,9 @@ main(int ac, char **av)
+ 	}
+ 
+ #ifdef SSH_AUDIT_EVENTS
++#ifndef	USE_SOLARIS_AUDIT
+ 	audit_event(SSH_AUTH_SUCCESS);
++#endif	/* !USE_SOLARIS_AUDIT */
+ #endif
+ 
+ #ifdef GSSAPI
+@@ -2264,6 +2266,10 @@ main(int ac, char **av)
+ 		do_pam_session();
+ 	}
+ #endif
++#ifdef	USE_SOLARIS_AUDIT
++	/* Audit should take place after all successful pam */
++	audit_event(SSH_AUTH_SUCCESS);
++#endif	/* USE_SOLARIS_AUDIT */
+ 
+ 	/*
+ 	 * In privilege separation, we fork another child and prepare
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:01 2016
+++ new/build/openssh/patches/0016-GSS-API-key-exchange-support.patch	Wed Feb 10 16:25:01 2016
@@ -0,0 +1,1941 @@
+From d49f189d9549a316d9213a441323d72b8f40cccf Mon Sep 17 00:00:00 2001
+From: oracle <solaris@oracle.com>
+Date: Mon, 3 Aug 2015 14:37:24 -0700
+Subject: [PATCH 16/36] GSS-API key exchange support
+
+---
+ Makefile.in    |   3 +-
+ auth2-gss.c    |  41 ++++++-
+ auth2.c        |   2 +
+ gss-genr.c     | 179 ++++++++++++++++++++++++++++-
+ gss-serv.c     |  39 +++++--
+ kex.c          |  11 +-
+ kex.h          |  11 ++
+ kexgssc.c      | 347 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ kexgsss.c      | 297 ++++++++++++++++++++++++++++++++++++++++++++++++
+ monitor.c      |  77 +++++++++++++
+ monitor.h      |   3 +
+ monitor_wrap.c |  23 ++++
+ monitor_wrap.h |   1 +
+ readconf.c     |  14 +++
+ readconf.h     |   1 +
+ servconf.c     |  15 +++
+ servconf.h     |   1 +
+ ssh-gss.h      |  19 ++++
+ ssh_config     |   1 +
+ ssh_config.4   |   6 +
+ sshconnect2.c  | 104 ++++++++++++++++-
+ sshd.c         |  52 +++++++++
+ sshd_config    |   3 +-
+ sshd_config.4  |   6 +
+ sshkey.c       |   1 +
+ sshkey.h       |   3 +
+ 26 files changed, 1239 insertions(+), 21 deletions(-)
+ create mode 100644 kexgssc.c
+ create mode 100644 kexgsss.c
+
+diff --git a/Makefile.in b/Makefile.in
+index 62e6a84..0148742 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -87,6 +87,7 @@ LIBSSH_OBJS=${LIBOPENSSH_OBJS} \
+ 	monitor_fdpass.o rijndael.o ssh-dss.o ssh-ecdsa.o ssh-rsa.o dh.o \
+ 	msg.o progressmeter.o dns.o entropy.o gss-genr.o umac.o umac128.o \
+ 	sftp_provider.o \
++	kexgssc.o \
+ 	ssh-pkcs11.o smult_curve25519_ref.o \
+ 	poly1305.o chacha.o cipher-chachapoly.o \
+ 	ssh-ed25519.o digest-openssl.o digest-libc.o hmac.o \
+@@ -108,7 +109,7 @@ SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \
+ 	auth-skey.o auth-bsdauth.o auth2-hostbased.o auth2-kbdint.o \
+ 	auth2-none.o auth2-passwd.o auth2-pubkey.o \
+ 	monitor_mm.o monitor.o monitor_wrap.o auth-krb5.o \
+-	auth2-gss.o gss-serv.o gss-serv-krb5.o \
++	auth2-gss.o gss-serv.o gss-serv-krb5.o kexgsss.o \
+ 	loginrec.o auth-pam.o auth-shadow.o auth-sia.o md5crypt.o \
+ 	sftp-server.o sftp-common.o \
+ 	roaming_common.o roaming_serv.o \
+diff --git a/auth2-gss.c b/auth2-gss.c
+index 1ca8357..24999c8 100644
+--- a/auth2-gss.c
++++ b/auth2-gss.c
+@@ -1,7 +1,7 @@
+ /* $OpenBSD: auth2-gss.c,v 1.22 2015/01/19 20:07:45 markus Exp $ */
+ 
+ /*
+- * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
++ * Copyright (c) 2001-2007 Simon Wilkinson. All rights reserved.
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+@@ -53,6 +53,39 @@ static int input_gssapi_mic(int type, u_int32_t plen, void *ctxt);
+ static int input_gssapi_exchange_complete(int type, u_int32_t plen, void *ctxt);
+ static int input_gssapi_errtok(int, u_int32_t, void *);
+ 
++/* 
++ * The 'gssapi_keyex' userauth mechanism.
++ */
++static int
++userauth_gsskeyex(Authctxt *authctxt)
++{
++	int authenticated = 0;
++	Buffer b;
++	gss_buffer_desc mic, gssbuf;
++	u_int len;
++
++	mic.value = packet_get_string(&len);
++	mic.length = len;
++
++	packet_check_eom();
++
++	ssh_gssapi_buildmic(&b, authctxt->user, authctxt->service,
++	    "gssapi-keyex");
++
++	gssbuf.value = buffer_ptr(&b);
++	gssbuf.length = buffer_len(&b);
++
++	/* gss_kex_context is NULL with privsep, so we can't check it here */
++	if (!GSS_ERROR(PRIVSEP(ssh_gssapi_checkmic(gss_kex_context, 
++	    &gssbuf, &mic))))
++		authenticated = PRIVSEP(ssh_gssapi_userok(authctxt->user));
++	
++	buffer_free(&b);
++	free(mic.value);
++
++	return (authenticated);
++}
++
+ /*
+  * We only support those mechanisms that we know about (ie ones that we know
+  * how to check local user kuserok and the like)
+@@ -290,6 +323,12 @@ input_gssapi_mic(int type, u_int32_t plen, void *ctxt)
+ 	return 0;
+ }
+ 
++Authmethod method_gsskeyex = {
++	"gssapi-keyex",
++	userauth_gsskeyex,
++	&options.gss_authentication
++};
++
+ Authmethod method_gssapi = {
+ 	"gssapi-with-mic",
+ 	userauth_gssapi,
+diff --git a/auth2.c b/auth2.c
+index 32ba663..5a3ef1b 100644
+--- a/auth2.c
++++ b/auth2.c
+@@ -70,6 +70,7 @@ extern Authmethod method_passwd;
+ extern Authmethod method_kbdint;
+ extern Authmethod method_hostbased;
+ #ifdef GSSAPI
++extern Authmethod method_gsskeyex;
+ extern Authmethod method_gssapi;
+ #endif
+ 
+@@ -77,6 +78,7 @@ Authmethod *authmethods[] = {
+ 	&method_none,
+ 	&method_pubkey,
+ #ifdef GSSAPI
++	&method_gsskeyex,
+ 	&method_gssapi,
+ #endif
+ 	&method_passwd,
+diff --git a/gss-genr.c b/gss-genr.c
+index d617d60..9dcf51c 100644
+--- a/gss-genr.c
++++ b/gss-genr.c
+@@ -1,7 +1,7 @@
+ /* $OpenBSD: gss-genr.c,v 1.23 2015/01/20 23:14:00 deraadt Exp $ */
+ 
+ /*
+- * Copyright (c) 2001-2007 Simon Wilkinson. All rights reserved.
++ * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved.
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+@@ -41,12 +41,167 @@
+ #include "buffer.h"
+ #include "log.h"
+ #include "ssh2.h"
++#include "cipher.h"
++#include "key.h"
++#include "kex.h"
++#include <openssl/evp.h>
+ 
+ #include "ssh-gss.h"
+ 
+ extern u_char *session_id2;
+ extern u_int session_id2_len;
+ 
++typedef struct {
++	char *encoded;
++	gss_OID oid;
++} ssh_gss_kex_mapping;
++
++/*
++ * XXX - It would be nice to find a more elegant way of handling the
++ * XXX   passing of the key exchange context to the userauth routines
++ */
++
++Gssctxt *gss_kex_context = NULL;
++
++static ssh_gss_kex_mapping *gss_enc2oid = NULL;
++
++int 
++ssh_gssapi_oid_table_ok() {
++	return (gss_enc2oid != NULL);
++}
++
++/*
++ * Return a list of the gss-group1-sha1 mechanisms supported by this program
++ *
++ * We test mechanisms to ensure that we can use them, to avoid starting
++ * a key exchange with a bad mechanism
++ */
++
++char *
++ssh_gssapi_client_mechanisms(const char *host) {
++	gss_OID_set gss_supported;
++	OM_uint32 min_status;
++
++	if (GSS_ERROR(gss_indicate_mechs(&min_status, &gss_supported)))
++		return NULL;
++
++	return(ssh_gssapi_kex_mechs(gss_supported, ssh_gssapi_check_mechanism,
++	    host));
++}
++
++char *
++ssh_gssapi_kex_mechs(gss_OID_set gss_supported, ssh_gssapi_check_fn *check,
++    const char *data) {
++	Buffer buf;
++	size_t i;
++	int oidpos, enclen;
++	char *mechs, *encoded;
++	u_char digest[EVP_MAX_MD_SIZE];
++	char deroid[2];
++	const EVP_MD *evp_md = EVP_md5();
++	EVP_MD_CTX md;
++
++	if (gss_enc2oid != NULL) {
++		for (i = 0; gss_enc2oid[i].encoded != NULL; i++)
++			free(gss_enc2oid[i].encoded);
++		free(gss_enc2oid);
++	}
++
++	gss_enc2oid = xmalloc(sizeof(ssh_gss_kex_mapping) *
++	    (gss_supported->count + 1));
++
++	buffer_init(&buf);
++
++	oidpos = 0;
++	for (i = 0; i < gss_supported->count; i++) {
++		if (gss_supported->elements[i].length < 128 &&
++		    (*check)(NULL, &(gss_supported->elements[i]), data)) {
++
++			deroid[0] = SSH_GSS_OIDTYPE;
++			deroid[1] = gss_supported->elements[i].length;
++
++			EVP_DigestInit(&md, evp_md);
++			EVP_DigestUpdate(&md, deroid, 2);
++			EVP_DigestUpdate(&md,
++			    gss_supported->elements[i].elements,
++			    gss_supported->elements[i].length);
++			EVP_DigestFinal(&md, digest, NULL);
++
++			encoded = xmalloc(EVP_MD_size(evp_md) * 2);
++			enclen = __b64_ntop(digest, EVP_MD_size(evp_md),
++			    encoded, EVP_MD_size(evp_md) * 2);
++
++			if (oidpos != 0)
++				buffer_put_char(&buf, ',');
++
++			buffer_append(&buf, KEX_GSS_GEX_SHA1_ID,
++			    sizeof(KEX_GSS_GEX_SHA1_ID) - 1);
++			buffer_append(&buf, encoded, enclen);
++			buffer_put_char(&buf, ',');
++			buffer_append(&buf, KEX_GSS_GRP1_SHA1_ID, 
++			    sizeof(KEX_GSS_GRP1_SHA1_ID) - 1);
++			buffer_append(&buf, encoded, enclen);
++			buffer_put_char(&buf, ',');
++			buffer_append(&buf, KEX_GSS_GRP14_SHA1_ID,
++			    sizeof(KEX_GSS_GRP14_SHA1_ID) - 1);
++			buffer_append(&buf, encoded, enclen);
++
++			gss_enc2oid[oidpos].oid = &(gss_supported->elements[i]);
++			gss_enc2oid[oidpos].encoded = encoded;
++			oidpos++;
++		}
++	}
++	gss_enc2oid[oidpos].oid = NULL;
++	gss_enc2oid[oidpos].encoded = NULL;
++
++	buffer_put_char(&buf, '\0');
++
++	mechs = xmalloc(buffer_len(&buf));
++	buffer_get(&buf, mechs, buffer_len(&buf));
++	buffer_free(&buf);
++
++	if (strlen(mechs) == 0) {
++		free(mechs);
++		mechs = NULL;
++	}
++	
++	return (mechs);
++}
++
++gss_OID
++ssh_gssapi_id_kex(Gssctxt *ctx, char *name, int kex_type) {
++	int i = 0;
++	
++	switch (kex_type) {
++	case KEX_GSS_GRP1_SHA1:
++		if (strlen(name) < sizeof(KEX_GSS_GRP1_SHA1_ID))
++			return GSS_C_NO_OID;
++		name += sizeof(KEX_GSS_GRP1_SHA1_ID) - 1;
++		break;
++	case KEX_GSS_GRP14_SHA1:
++		if (strlen(name) < sizeof(KEX_GSS_GRP14_SHA1_ID))
++			return GSS_C_NO_OID;
++		name += sizeof(KEX_GSS_GRP14_SHA1_ID) - 1;
++		break;
++	case KEX_GSS_GEX_SHA1:
++		if (strlen(name) < sizeof(KEX_GSS_GEX_SHA1_ID))
++			return GSS_C_NO_OID;
++		name += sizeof(KEX_GSS_GEX_SHA1_ID) - 1;
++		break;
++	default:
++		return GSS_C_NO_OID;
++	}
++
++	while (gss_enc2oid[i].encoded != NULL &&
++	    strcmp(name, gss_enc2oid[i].encoded) != 0)
++		i++;
++
++	if (gss_enc2oid[i].oid != NULL && ctx != NULL)
++		ssh_gssapi_set_oid(ctx, gss_enc2oid[i].oid);
++
++	return gss_enc2oid[i].oid;
++}
++
+ /* Check that the OID in a data stream matches that in the context */
+ int
+ ssh_gssapi_check_oid(Gssctxt *ctx, void *data, size_t len)
+@@ -231,6 +386,9 @@ ssh_gssapi_import_name(Gssctxt *ctx, const char *host)
+ OM_uint32
+ ssh_gssapi_sign(Gssctxt *ctx, gss_buffer_t buffer, gss_buffer_t hash)
+ {
++	if (ctx == NULL) 
++		return -1;
++
+ 	if ((ctx->major = gss_get_mic(&ctx->minor, ctx->context,
+ 	    GSS_C_QOP_DEFAULT, buffer, hash)))
+ 		ssh_gssapi_error(ctx);
+@@ -238,6 +396,19 @@ ssh_gssapi_sign(Gssctxt *ctx, gss_buffer_t buffer, gss_buffer_t hash)
+ 	return (ctx->major);
+ }
+ 
++/* Priviledged when used by server */
++OM_uint32
++ssh_gssapi_checkmic(Gssctxt *ctx, gss_buffer_t gssbuf, gss_buffer_t gssmic)
++{
++	if (ctx == NULL)
++		return -1;
++
++	ctx->major = gss_verify_mic(&ctx->minor, ctx->context,
++	    gssbuf, gssmic, NULL);
++
++	return (ctx->major);
++}
++
+ void
+ ssh_gssapi_buildmic(Buffer *b, const char *user, const char *service,
+     const char *context)
+@@ -256,6 +427,10 @@ ssh_gssapi_check_mechanism(Gssctxt **ctx, gss_OID oid, const char *host)
+ 	gss_buffer_desc token = GSS_C_EMPTY_BUFFER;
+ 	OM_uint32 major, minor;
+ 	gss_OID_desc spnego_oid = {6, (void *)"\x2B\x06\x01\x05\x05\x02"};
++	Gssctxt *intctx = NULL;
++
++	if (ctx == NULL)
++		ctx = &intctx;
+ 
+ 	/* RFC 4462 says we MUST NOT do SPNEGO */
+ 	if (oid->length == spnego_oid.length && 
+@@ -274,7 +449,7 @@ ssh_gssapi_check_mechanism(Gssctxt **ctx, gss_OID oid, const char *host)
+ 			    GSS_C_NO_BUFFER);
+ 	}
+ 
+-	if (GSS_ERROR(major)) 
++	if (GSS_ERROR(major) || intctx != NULL) 
+ 		ssh_gssapi_delete_ctx(ctx);
+ 
+ 	return (!GSS_ERROR(major));
+diff --git a/gss-serv.c b/gss-serv.c
+index 209ffe8..a45d8fd 100644
+--- a/gss-serv.c
++++ b/gss-serv.c
+@@ -1,7 +1,7 @@
+ /* $OpenBSD: gss-serv.c,v 1.29 2015/05/22 03:50:02 djm Exp $ */
+ 
+ /*
+- * Copyright (c) 2001-2003 Simon Wilkinson. All rights reserved.
++ * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved.
+  *
+  * Redistribution and use in source and binary forms, with or without
+  * modification, are permitted provided that the following conditions
+@@ -47,6 +47,7 @@
+ #include "servconf.h"
+ 
+ #include "ssh-gss.h"
++#include "monitor_wrap.h"
+ 
+ extern ServerOptions options;
+ 
+@@ -142,6 +143,28 @@ ssh_gssapi_server_ctx(Gssctxt **ctx, gss_OID oid)
+ }
+ 
+ /* Unprivileged */
++char *
++ssh_gssapi_server_mechanisms() {
++	gss_OID_set	supported;
++
++	ssh_gssapi_supported_oids(&supported);
++	return (ssh_gssapi_kex_mechs(supported, &ssh_gssapi_server_check_mech,
++	    NULL));
++}
++
++/* Unprivileged */
++int
++ssh_gssapi_server_check_mech(Gssctxt **dum, gss_OID oid, const char *data) {
++	Gssctxt *ctx = NULL;
++	int res;
++ 
++	res = !GSS_ERROR(PRIVSEP(ssh_gssapi_server_ctx(&ctx, oid)));
++	ssh_gssapi_delete_ctx(&ctx);
++
++	return (res);
++}
++
++/* Unprivileged */
+ void
+ ssh_gssapi_supported_oids(gss_OID_set *oidset)
+ {
+@@ -151,7 +174,9 @@ ssh_gssapi_supported_oids(gss_OID_set *oidset)
+ 	gss_OID_set supported;
+ 
+ 	gss_create_empty_oid_set(&min_status, oidset);
+-	gss_indicate_mechs(&min_status, &supported);
++
++	if (GSS_ERROR(gss_indicate_mechs(&min_status, &supported)))
++		return;
+ 
+ 	while (supported_mechs[i]->name != NULL) {
+ 		if (GSS_ERROR(gss_test_oid_set_member(&min_status,
+@@ -427,14 +452,4 @@ ssh_gssapi_userok(char *user)
+ 	return (0);
+ }
+ 
+-/* Privileged */
+-OM_uint32
+-ssh_gssapi_checkmic(Gssctxt *ctx, gss_buffer_t gssbuf, gss_buffer_t gssmic)
+-{
+-	ctx->major = gss_verify_mic(&ctx->minor, ctx->context,
+-	    gssbuf, gssmic, NULL);
+-
+-	return (ctx->major);
+-}
+-
+ #endif
+diff --git a/kex.c b/kex.c
+index b777b7d..ad0598e 100644
+--- a/kex.c
++++ b/kex.c
+@@ -55,6 +55,10 @@
+ #include "sshbuf.h"
+ #include "digest.h"
+ 
++#ifdef GSSAPI
++#include "ssh-gss.h"
++#endif
++
+ #if OPENSSL_VERSION_NUMBER >= 0x00907000L
+ # if defined(HAVE_EVP_SHA256)
+ # define evp_ssh_sha256 EVP_sha256
+@@ -95,6 +99,11 @@ static const struct kexalg kexalgs[] = {
+ #if defined(HAVE_EVP_SHA256) || !defined(WITH_OPENSSL)
+ 	{ KEX_CURVE25519_SHA256, KEX_C25519_SHA256, 0, SSH_DIGEST_SHA256 },
+ #endif /* HAVE_EVP_SHA256 || !WITH_OPENSSL */
++#ifdef GSSAPI
++	{ KEX_GSS_GEX_SHA1_ID, KEX_GSS_GEX_SHA1, 0, SSH_DIGEST_SHA1 },
++	{ KEX_GSS_GRP1_SHA1_ID, KEX_GSS_GRP1_SHA1, 0, SSH_DIGEST_SHA1 },
++	{ KEX_GSS_GRP14_SHA1_ID, KEX_GSS_GRP14_SHA1, 0, SSH_DIGEST_SHA1 },
++#endif
+ 	{ NULL, -1, -1, -1},
+ };
+ 
+@@ -126,7 +135,7 @@ kex_alg_by_name(const char *name)
+ 	const struct kexalg *k;
+ 
+ 	for (k = kexalgs; k->name != NULL; k++) {
+-		if (strcmp(k->name, name) == 0)
++		if (strncmp(k->name, name, strlen(k->name)) == 0)
+ 			return k;
+ 	}
+ 	return NULL;
+diff --git a/kex.h b/kex.h
+index d71b532..04b4733 100644
+--- a/kex.h
++++ b/kex.h
+@@ -93,6 +93,9 @@ enum kex_exchange {
+ 	KEX_DH_GEX_SHA256,
+ 	KEX_ECDH_SHA2,
+ 	KEX_C25519_SHA256,
++	KEX_GSS_GRP1_SHA1,
++	KEX_GSS_GRP14_SHA1,
++	KEX_GSS_GEX_SHA1,
+ 	KEX_MAX
+ };
+ 
+@@ -139,6 +142,10 @@ struct kex {
+ 	u_int	flags;
+ 	int	hash_alg;
+ 	int	ec_nid;
++#ifdef GSSAPI
++	int	gss_deleg_creds;
++	char    *gss_host;
++#endif
+ 	char	*client_version_string;
+ 	char	*server_version_string;
+ 	char	*failed_choice;
+@@ -186,6 +193,10 @@ int	 kexecdh_client(struct ssh *);
+ int	 kexecdh_server(struct ssh *);
+ int	 kexc25519_client(struct ssh *);
+ int	 kexc25519_server(struct ssh *);
++#ifdef GSSAPI
++int	 kexgss_client(struct ssh *);
++int	 kexgss_server(struct ssh *);
++#endif
+ 
+ int	 kex_dh_hash(const char *, const char *,
+     const u_char *, size_t, const u_char *, size_t, const u_char *, size_t,
+diff --git a/kexgssc.c b/kexgssc.c
+new file mode 100644
+index 0000000..c36d36b
+--- /dev/null
++++ b/kexgssc.c
+@@ -0,0 +1,347 @@
++/*
++ * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ *    notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ *    notice, this list of conditions and the following disclaimer in the
++ *    documentation and/or other materials provided with the distribution.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
++ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
++ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
++ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
++ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
++ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++ */
++
++/*
++ * May 22, 2015
++ * In version 6.8 a new packet interface has been introduced to OpenSSH,
++ * while the old packet API has been provided in opacket.c.
++ * At this moment we are not rewritting GSS-API key exchange code to the new
++ * API, just adjusting it to still work with new struct ssh.
++ * Rewritting to the new API can be considered in the future.
++ */
++
++#include "includes.h"
++
++#ifdef GSSAPI
++
++#include "includes.h"
++
++#include <openssl/crypto.h>
++#include <openssl/bn.h>
++
++#include <signal.h>	/* for sig_atomic_t in kex.h */
++#include <string.h>
++
++#include "xmalloc.h"
++#include "buffer.h"
++#include "ssh2.h"
++#include "key.h"
++#include "cipher.h"
++#include "digest.h"
++#include "kex.h"
++#include "log.h"
++#include "packet.h"
++#include "dh.h"
++
++#include "ssh-gss.h"
++
++int
++kexgss_client(struct ssh *ssh) {
++	gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER;
++	gss_buffer_desc recv_tok, gssbuf, msg_tok, *token_ptr;
++	Gssctxt *ctxt;
++	OM_uint32 maj_status, min_status, ret_flags;
++	uint_t klen, kout, slen = 0, strlen;
++	DH *dh;
++	BIGNUM *dh_server_pub = NULL;
++	BIGNUM *shared_secret = NULL;
++	BIGNUM *p = NULL;
++	BIGNUM *g = NULL;
++	uchar_t *kbuf;
++	uchar_t *serverhostkey = NULL;
++	uchar_t *empty = "";
++	char *msg;
++	char *lang;
++	int type = 0;
++	int first = 1;
++	int nbits = 0, min = DH_GRP_MIN, max = DH_GRP_MAX;
++	struct kex *kex = ssh->kex;
++	int r;
++	uchar_t hash[SSH_DIGEST_MAX_LENGTH];
++	size_t hashlen;
++
++	/* Initialise our GSSAPI world */
++	ssh_gssapi_build_ctx(&ctxt);
++	if (ssh_gssapi_id_kex(ctxt, kex->name, kex->kex_type)
++	    == GSS_C_NO_OID)
++		fatal("Couldn't identify host exchange");
++
++	if (ssh_gssapi_import_name(ctxt, kex->gss_host))
++		fatal("Couldn't import hostname");
++
++	switch (kex->kex_type) {
++	case KEX_GSS_GRP1_SHA1:
++		kex->dh = dh_new_group1();
++		break;
++	case KEX_GSS_GRP14_SHA1:
++		kex->dh = dh_new_group14();
++		break;
++	case KEX_GSS_GEX_SHA1:
++		debug("Doing group exchange\n");
++		nbits = dh_estimate(kex->we_need * 8);
++		packet_start(SSH2_MSG_KEXGSS_GROUPREQ);
++		packet_put_int(min);
++		packet_put_int(nbits);
++		packet_put_int(max);
++
++		packet_send();
++
++		packet_read_expect(SSH2_MSG_KEXGSS_GROUP);
++
++		if ((p = BN_new()) == NULL)
++			fatal("BN_new() failed");
++		packet_get_bignum2(p);
++		if ((g = BN_new()) == NULL)
++			fatal("BN_new() failed");
++		packet_get_bignum2(g);
++		packet_check_eom();
++
++		if (BN_num_bits(p) < min || BN_num_bits(p) > max)
++			fatal("GSSGRP_GEX group out of range: %d !< %d !< %d",
++			    min, BN_num_bits(p), max);
++
++		kex->dh = dh_new_group(g, p);
++		break;
++	default:
++		fatal("%s: Unexpected KEX type %d", __func__, kex->kex_type);
++	}
++
++	/* Step 1 - e is dh->pub_key */
++	dh_gen_key(kex->dh, kex->we_need * 8);
++
++	/* This is f, we initialise it now to make life easier */
++	dh_server_pub = BN_new();
++	if (dh_server_pub == NULL)
++		fatal("dh_server_pub == NULL");
++
++	token_ptr = GSS_C_NO_BUFFER;
++
++	do {
++		debug("Calling gss_init_sec_context");
++
++		maj_status = ssh_gssapi_init_ctx(ctxt,
++		    kex->gss_deleg_creds, token_ptr, &send_tok,
++		    &ret_flags);
++
++		if (GSS_ERROR(maj_status)) {
++			if (send_tok.length != 0) {
++				packet_start(SSH2_MSG_KEXGSS_CONTINUE);
++				packet_put_string(send_tok.value,
++				    send_tok.length);
++			}
++			fatal("gss_init_context failed");
++		}
++
++		/* If we've got an old receive buffer get rid of it */
++		if (token_ptr != GSS_C_NO_BUFFER)
++			free(recv_tok.value);
++
++		if (maj_status == GSS_S_COMPLETE) {
++			/* If mutual state flag is not true, kex fails */
++			if (!(ret_flags & GSS_C_MUTUAL_FLAG))
++				fatal("Mutual authentication failed");
++
++			/* If integ avail flag is not true kex fails */
++			if (!(ret_flags & GSS_C_INTEG_FLAG))
++				fatal("Integrity check failed");
++		}
++
++		/*
++		 * If we have data to send, then the last message that we
++		 * received cannot have been a 'complete'.
++		 */
++		if (send_tok.length != 0) {
++			if (first) {
++				packet_start(SSH2_MSG_KEXGSS_INIT);
++				packet_put_string(send_tok.value,
++				    send_tok.length);
++				packet_put_bignum2(kex->dh->pub_key);
++				first = 0;
++			} else {
++				packet_start(SSH2_MSG_KEXGSS_CONTINUE);
++				packet_put_string(send_tok.value,
++				    send_tok.length);
++			}
++			packet_send();
++			gss_release_buffer(&min_status, &send_tok);
++
++			/* If we've sent them data, they should reply */
++			do {
++				type = packet_read();
++				if (type == SSH2_MSG_KEXGSS_HOSTKEY) {
++					debug("Received KEXGSS_HOSTKEY");
++					if (serverhostkey)
++						fatal("Server host key received"
++						    "more than once");
++					serverhostkey =
++					    packet_get_string(&slen);
++				}
++			} while (type == SSH2_MSG_KEXGSS_HOSTKEY);
++
++			switch (type) {
++			case SSH2_MSG_KEXGSS_CONTINUE:
++				debug("Received GSSAPI_CONTINUE");
++				if (maj_status == GSS_S_COMPLETE)
++					fatal("GSSAPI Continue received from"
++					    "server when complete");
++				recv_tok.value = packet_get_string(&strlen);
++				recv_tok.length = strlen;
++				break;
++			case SSH2_MSG_KEXGSS_COMPLETE:
++				debug("Received GSSAPI_COMPLETE");
++				packet_get_bignum2(dh_server_pub);
++				msg_tok.value =  packet_get_string(&strlen);
++				msg_tok.length = strlen;
++
++				/* Is there a token included? */
++				if (packet_get_char()) {
++					recv_tok.value=
++					    packet_get_string(&strlen);
++					recv_tok.length = strlen;
++					/* If complete - protocol error */
++					if (maj_status == GSS_S_COMPLETE)
++						packet_disconnect("Protocol"
++						    " error: received token"
++						    " when complete");
++				} else {
++					/* No token included */
++					if (maj_status != GSS_S_COMPLETE)
++						packet_disconnect("Protocol"
++						    " error: did not receive"
++						    " final token");
++				}
++				break;
++			case SSH2_MSG_KEXGSS_ERROR:
++				debug("Received Error");
++				maj_status = packet_get_int();
++				min_status = packet_get_int();
++				msg = packet_get_string(NULL);
++				lang = packet_get_string(NULL);
++				fatal("GSSAPI Error: \n%.400s", msg);
++			default:
++				packet_disconnect("Protocol error: didn't"
++				    " expect packet type %d", type);
++			}
++			token_ptr = &recv_tok;
++		} else {
++			/* No data, and not complete */
++			if (maj_status != GSS_S_COMPLETE)
++				fatal("Not complete, and no token output");
++		}
++	} while (maj_status & GSS_S_CONTINUE_NEEDED);
++
++	/*
++	 * We _must_ have received a COMPLETE message in reply from the
++	 * server, which will have set dh_server_pub and msg_tok
++	 */
++
++	if (type != SSH2_MSG_KEXGSS_COMPLETE)
++		fatal("Didn't receive SSH2_MSG_KEXGSS_COMPLETE when expected");
++
++	/* Check f in range [1, p-1] */
++	if (!dh_pub_is_valid(kex->dh, dh_server_pub))
++		packet_disconnect("bad server public DH value");
++
++	/* compute K=f^x mod p */
++	klen = DH_size(kex->dh);
++	kbuf = xmalloc(klen);
++	kout = DH_compute_key(kbuf, dh_server_pub, kex->dh);
++	if (kout < 0)
++		fatal("DH_compute_key: failed");
++
++	shared_secret = BN_new();
++	if (shared_secret == NULL)
++		fatal("kexgss_client: BN_new failed");
++
++	if (BN_bin2bn(kbuf, kout, shared_secret) == NULL)
++		fatal("kexdh_client: BN_bin2bn failed");
++
++	memset(kbuf, 0, klen);
++	free(kbuf);
++
++	hashlen = sizeof (hash);
++	switch (kex->kex_type) {
++	case KEX_GSS_GRP1_SHA1:
++	case KEX_GSS_GRP14_SHA1:
++		kex_dh_hash(kex->client_version_string,
++		    kex->server_version_string,
++		    buffer_ptr(kex->my), buffer_len(kex->my),
++		    buffer_ptr(kex->peer), buffer_len(kex->peer),
++		    (serverhostkey ? serverhostkey : empty), slen,
++		    kex->dh->pub_key,	/* e */
++		    dh_server_pub,	/* f */
++		    shared_secret,	/* K */
++		    hash, &hashlen);
++		break;
++	case KEX_GSS_GEX_SHA1:
++		kexgex_hash(
++		    kex->hash_alg,
++		    kex->client_version_string,
++		    kex->server_version_string,
++		    buffer_ptr(kex->my), buffer_len(kex->my),
++		    buffer_ptr(kex->peer), buffer_len(kex->peer),
++		    (serverhostkey ? serverhostkey : empty), slen,
++		    min, nbits, max,
++		    kex->dh->p, kex->dh->g,
++		    kex->dh->pub_key,
++		    dh_server_pub,
++		    shared_secret,
++		    hash, &hashlen);
++		break;
++	default:
++		fatal("%s: Unexpected KEX type %d", __func__, kex->kex_type);
++	}
++
++	gssbuf.value = hash;
++	gssbuf.length = hashlen;
++
++	/* Verify that the hash matches the MIC we just got. */
++	if (GSS_ERROR(ssh_gssapi_checkmic(ctxt, &gssbuf, &msg_tok)))
++		packet_disconnect("Hash's MIC didn't verify");
++
++	free(msg_tok.value);
++
++	DH_free(kex->dh);
++	if (serverhostkey)
++		free(serverhostkey);
++	BN_clear_free(dh_server_pub);
++
++	/* save session id */
++	if (kex->session_id == NULL) {
++		kex->session_id_len = hashlen;
++		kex->session_id = xmalloc(kex->session_id_len);
++		memcpy(kex->session_id, hash, kex->session_id_len);
++	}
++
++	if (gss_kex_context == NULL)
++		gss_kex_context = ctxt;
++	else
++		ssh_gssapi_delete_ctx(&ctxt);
++
++	if ((r = kex_derive_keys_bn(ssh, hash, hashlen, shared_secret)) == 0)
++		r = kex_send_newkeys(ssh);
++	return (r);
++}
++
++#endif /* GSSAPI */
+diff --git a/kexgsss.c b/kexgsss.c
+new file mode 100644
+index 0000000..2009cd9
+--- /dev/null
++++ b/kexgsss.c
+@@ -0,0 +1,297 @@
++/*
++ * Copyright (c) 2001-2009 Simon Wilkinson. All rights reserved.
++ *
++ * Redistribution and use in source and binary forms, with or without
++ * modification, are permitted provided that the following conditions
++ * are met:
++ * 1. Redistributions of source code must retain the above copyright
++ *    notice, this list of conditions and the following disclaimer.
++ * 2. Redistributions in binary form must reproduce the above copyright
++ *    notice, this list of conditions and the following disclaimer in the
++ *    documentation and/or other materials provided with the distribution.
++ *
++ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR `AS IS'' AND ANY EXPRESS OR
++ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
++ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
++ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
++ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
++ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
++ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
++ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
++ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
++ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
++ */
++
++/*
++ * May 22, 2015
++ * In version 6.8 a new packet interface has been introduced to OpenSSH,
++ * while the old packet API has been provided in opacket.c.
++ * At this moment we are not rewritting GSS-API key exchange code to the new
++ * API, just adjusting it to still work with new struct ssh.
++ * Rewritting to the new API can be considered in the future.
++ */
++
++#include "includes.h"
++
++#ifdef GSSAPI
++
++#include <signal.h>	/* for sig_atomic_t in kex.h */
++#include <string.h>
++
++#include <openssl/crypto.h>
++#include <openssl/bn.h>
++
++#include "xmalloc.h"
++#include "buffer.h"
++#include "ssh2.h"
++#include "key.h"
++#include "cipher.h"
++#include "digest.h"
++#include "kex.h"
++#include "log.h"
++#include "packet.h"
++#include "dh.h"
++#include "ssh-gss.h"
++#include "monitor_wrap.h"
++
++int
++kexgss_server(struct ssh *ssh)
++{
++	OM_uint32 maj_status, min_status;
++
++	/*
++	 * Some GSSAPI implementations use the input value of ret_flags (an
++	 * output variable) as a means of triggering mechanism specific
++	 * features. Initializing it to zero avoids inadvertently
++	 * activating this non-standard behaviour.
++	 */
++
++	OM_uint32 ret_flags = 0;
++	gss_buffer_desc gssbuf, recv_tok, msg_tok;
++	gss_buffer_desc send_tok = GSS_C_EMPTY_BUFFER;
++	Gssctxt *ctxt = NULL;
++	uint_t slen, klen, kout;
++	uchar_t *kbuf;
++	DH *dh;
++	int min = -1, max = -1, nbits = -1;
++	BIGNUM *shared_secret = NULL;
++	BIGNUM *dh_client_pub = NULL;
++	int type = 0;
++	gss_OID oid;
++	char *mechs;
++	struct kex *kex = ssh->kex;
++	int r;
++	uchar_t hash[SSH_DIGEST_MAX_LENGTH];
++	size_t hashlen;
++
++	/* Initialise GSSAPI */
++
++	/*
++	 * If we're rekeying, privsep means that some of the private structures
++	 * in the GSSAPI code are no longer available. This kludges them back
++	 * into life
++	 */
++	if (!ssh_gssapi_oid_table_ok())
++		if ((mechs = ssh_gssapi_server_mechanisms()))
++			free(mechs);
++
++	debug2("%s: Identifying %s", __func__, kex->name);
++	oid = ssh_gssapi_id_kex(NULL, kex->name, kex->kex_type);
++	if (oid == GSS_C_NO_OID)
++		fatal("Unknown gssapi mechanism");
++
++	debug2("%s: Acquiring credentials", __func__);
++
++	if (GSS_ERROR(PRIVSEP(ssh_gssapi_server_ctx(&ctxt, oid))))
++		fatal("Unable to acquire credentials for the server");
++
++	switch (kex->kex_type) {
++	case KEX_GSS_GRP1_SHA1:
++		kex->dh = dh_new_group1();
++		break;
++	case KEX_GSS_GRP14_SHA1:
++		kex->dh = dh_new_group14();
++		break;
++	case KEX_GSS_GEX_SHA1:
++		debug("Doing group exchange");
++		packet_read_expect(SSH2_MSG_KEXGSS_GROUPREQ);
++		min = packet_get_int();
++		nbits = packet_get_int();
++		max = packet_get_int();
++		min = MAX(DH_GRP_MIN, min);
++		max = MIN(DH_GRP_MAX, max);
++		packet_check_eom();
++		if (max < min || nbits < min || max < nbits)
++			fatal("GSS_GEX, bad parameters: %d !< %d !< %d",
++			    min, nbits, max);
++		kex->dh = PRIVSEP(choose_dh(min, nbits, max));
++		if (kex->dh == NULL)
++			packet_disconnect("Protocol error:"
++			    " no matching group found");
++
++		packet_start(SSH2_MSG_KEXGSS_GROUP);
++		packet_put_bignum2(kex->dh->p);
++		packet_put_bignum2(kex->dh->g);
++		packet_send();
++
++		packet_write_wait();
++		break;
++	default:
++		fatal("%s: Unexpected KEX type %d", __func__, kex->kex_type);
++	}
++
++	dh_gen_key(kex->dh, kex->we_need * 8);
++
++	do {
++		debug("Wait SSH2_MSG_GSSAPI_INIT");
++		type = packet_read();
++		switch (type) {
++		case SSH2_MSG_KEXGSS_INIT:
++			if (dh_client_pub != NULL)
++				fatal("Received KEXGSS_INIT after"
++				    " initialising");
++			recv_tok.value = packet_get_string(&slen);
++			recv_tok.length = slen;
++
++			if ((dh_client_pub = BN_new()) == NULL)
++				fatal("dh_client_pub == NULL");
++
++			packet_get_bignum2(dh_client_pub);
++
++			/* Send SSH_MSG_KEXGSS_HOSTKEY here, if we want */
++			break;
++		case SSH2_MSG_KEXGSS_CONTINUE:
++			recv_tok.value = packet_get_string(&slen);
++			recv_tok.length = slen;
++			break;
++		default:
++			packet_disconnect(
++			    "Protocol error: didn't expect packet type %d",
++			    type);
++		}
++
++		maj_status = PRIVSEP(ssh_gssapi_accept_ctx(ctxt, &recv_tok,
++		    &send_tok, &ret_flags));
++
++		free(recv_tok.value);
++
++		if (maj_status != GSS_S_COMPLETE && send_tok.length == 0)
++			fatal("Zero length token output when incomplete");
++
++		if (dh_client_pub == NULL)
++			fatal("No client public key");
++
++		if (maj_status & GSS_S_CONTINUE_NEEDED) {
++			debug("Sending GSSAPI_CONTINUE");
++			packet_start(SSH2_MSG_KEXGSS_CONTINUE);
++			packet_put_string(send_tok.value, send_tok.length);
++			packet_send();
++			gss_release_buffer(&min_status, &send_tok);
++		}
++	} while (maj_status & GSS_S_CONTINUE_NEEDED);
++
++	if (GSS_ERROR(maj_status)) {
++		if (send_tok.length > 0) {
++			packet_start(SSH2_MSG_KEXGSS_CONTINUE);
++			packet_put_string(send_tok.value, send_tok.length);
++			packet_send();
++		}
++		fatal("accept_ctx died");
++	}
++
++	if (!(ret_flags & GSS_C_MUTUAL_FLAG))
++		fatal("Mutual Authentication flag wasn't set");
++
++	if (!(ret_flags & GSS_C_INTEG_FLAG))
++		fatal("Integrity flag wasn't set");
++
++	if (!dh_pub_is_valid(kex->dh, dh_client_pub))
++		packet_disconnect("bad client public DH value");
++
++	klen = DH_size(kex->dh);
++	kbuf = xmalloc(klen);
++	kout = DH_compute_key(kbuf, dh_client_pub, kex->dh);
++	if (kout < 0)
++		fatal("DH_compute_key: failed");
++
++	shared_secret = BN_new();
++	if (shared_secret == NULL)
++		fatal("kexgss_server: BN_new failed");
++
++	if (BN_bin2bn(kbuf, kout, shared_secret) == NULL)
++		fatal("kexgss_server: BN_bin2bn failed");
++
++	memset(kbuf, 0, klen);
++	free(kbuf);
++
++	hashlen = sizeof (hash);
++	switch (kex->kex_type) {
++	case KEX_GSS_GRP1_SHA1:
++	case KEX_GSS_GRP14_SHA1:
++		kex_dh_hash(
++		    kex->client_version_string, kex->server_version_string,
++		    buffer_ptr(kex->peer), buffer_len(kex->peer),
++		    buffer_ptr(kex->my), buffer_len(kex->my),
++		    NULL, 0, /* Change this if we start sending host keys */
++		    dh_client_pub, kex->dh->pub_key, shared_secret,
++		    hash, &hashlen);
++		break;
++	case KEX_GSS_GEX_SHA1:
++		kexgex_hash(
++		    kex->hash_alg,
++		    kex->client_version_string, kex->server_version_string,
++		    buffer_ptr(kex->peer), buffer_len(kex->peer),
++		    buffer_ptr(kex->my), buffer_len(kex->my),
++		    NULL, 0,
++		    min, nbits, max,
++		    kex->dh->p, kex->dh->g,
++		    dh_client_pub,
++		    kex->dh->pub_key,
++		    shared_secret,
++		    hash, &hashlen);
++		break;
++	default:
++		fatal("%s: Unexpected KEX type %d", __func__, kex->kex_type);
++	}
++
++	BN_clear_free(dh_client_pub);
++
++	if (kex->session_id == NULL) {
++		kex->session_id_len = hashlen;
++		kex->session_id = xmalloc(kex->session_id_len);
++		memcpy(kex->session_id, hash, kex->session_id_len);
++	}
++
++	gssbuf.value = hash;
++	gssbuf.length = hashlen;
++
++	if (GSS_ERROR(PRIVSEP(ssh_gssapi_sign(ctxt, &gssbuf, &msg_tok))))
++		fatal("Couldn't get MIC");
++
++	packet_start(SSH2_MSG_KEXGSS_COMPLETE);
++	packet_put_bignum2(kex->dh->pub_key);
++	packet_put_string(msg_tok.value, msg_tok.length);
++
++	if (send_tok.length != 0) {
++		packet_put_char(1); /* true */
++		packet_put_string(send_tok.value, send_tok.length);
++	} else {
++		packet_put_char(0); /* false */
++	}
++	packet_send();
++
++	gss_release_buffer(&min_status, &send_tok);
++	gss_release_buffer(&min_status, &msg_tok);
++
++	if (gss_kex_context == NULL)
++		gss_kex_context = ctxt;
++	else
++		ssh_gssapi_delete_ctx(&ctxt);
++
++	DH_free(kex->dh);
++
++	if ((r = kex_derive_keys_bn(ssh, hash, hashlen, shared_secret)) == 0)
++		r = kex_send_newkeys(ssh);
++	return (r);
++}
++#endif /* GSSAPI */
+diff --git a/monitor.c b/monitor.c
+index b3efbb0..7ac4c61 100644
+--- a/monitor.c
++++ b/monitor.c
+@@ -160,6 +160,7 @@ int mm_answer_gss_setup_ctx(int, Buffer *);
+ int mm_answer_gss_accept_ctx(int, Buffer *);
+ int mm_answer_gss_userok(int, Buffer *);
+ int mm_answer_gss_checkmic(int, Buffer *);
++int mm_answer_gss_sign(int, Buffer *);
+ #endif
+ 
+ #ifdef SSH_AUDIT_EVENTS
+@@ -244,11 +245,17 @@ struct mon_table mon_dispatch_proto20[] = {
+     {MONITOR_REQ_GSSSTEP, MON_ISAUTH, mm_answer_gss_accept_ctx},
+     {MONITOR_REQ_GSSUSEROK, MON_AUTH, mm_answer_gss_userok},
+     {MONITOR_REQ_GSSCHECKMIC, MON_ISAUTH, mm_answer_gss_checkmic},
++    {MONITOR_REQ_GSSSIGN, MON_ONCE, mm_answer_gss_sign},
+ #endif
+     {0, 0, NULL}
+ };
+ 
+ struct mon_table mon_dispatch_postauth20[] = {
++#ifdef GSSAPI
++    {MONITOR_REQ_GSSSETUP, 0, mm_answer_gss_setup_ctx},
++    {MONITOR_REQ_GSSSTEP, 0, mm_answer_gss_accept_ctx},
++    {MONITOR_REQ_GSSSIGN, 0, mm_answer_gss_sign},
++#endif
+ #ifdef WITH_OPENSSL
+     {MONITOR_REQ_MODULI, 0, mm_answer_moduli},
+ #endif
+@@ -363,6 +370,10 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor)
+ 		/* Permit requests for moduli and signatures */
+ 		monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1);
+ 		monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1);
++#ifdef GSSAPI
++		/* and for the GSSAPI key exchange */
++		monitor_permit(mon_dispatch, MONITOR_REQ_GSSSETUP, 1);
++#endif
+ 	} else {
+ 		mon_dispatch = mon_dispatch_proto15;
+ 
+@@ -502,6 +513,10 @@ monitor_child_postauth(struct monitor *pmonitor)
+ 		monitor_permit(mon_dispatch, MONITOR_REQ_MODULI, 1);
+ 		monitor_permit(mon_dispatch, MONITOR_REQ_SIGN, 1);
+ 		monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1);
++#ifdef GSSAPI
++		/* and for the GSSAPI key exchange */
++		monitor_permit(mon_dispatch, MONITOR_REQ_GSSSETUP, 1);
++#endif		
+ 	} else {
+ 		mon_dispatch = mon_dispatch_postauth15;
+ 		monitor_permit(mon_dispatch, MONITOR_REQ_TERM, 1);
+@@ -1927,6 +1942,13 @@ monitor_apply_keystate(struct monitor *pmonitor)
+ # endif
+ #endif /* WITH_OPENSSL */
+ 		kex->kex[KEX_C25519_SHA256] = kexc25519_server;
++#ifdef GSSAPI
++		if (options.gss_keyex) {
++			kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server;
++			kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server;
++			kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server;
++		}
++#endif
+ 		kex->load_host_public_key=&get_hostkey_public_by_type;
+ 		kex->load_host_private_key=&get_hostkey_private_by_type;
+ 		kex->host_key_index=&get_hostkey_index;
+@@ -2026,6 +2048,9 @@ mm_answer_gss_setup_ctx(int sock, Buffer *m)
+ 	OM_uint32 major;
+ 	u_int len;
+ 
++	if (!options.gss_authentication && !options.gss_keyex)
++		fatal("In GSSAPI monitor when GSSAPI is disabled");
++
+ 	goid.elements = buffer_get_string(m, &len);
+ 	goid.length = len;
+ 
+@@ -2053,6 +2078,9 @@ mm_answer_gss_accept_ctx(int sock, Buffer *m)
+ 	OM_uint32 flags = 0; /* GSI needs this */
+ 	u_int len;
+ 
++	if (!options.gss_authentication && !options.gss_keyex)
++		fatal("In GSSAPI monitor when GSSAPI is disabled");
++
+ 	in.value = buffer_get_string(m, &len);
+ 	in.length = len;
+ 	major = ssh_gssapi_accept_ctx(gsscontext, &in, &out, &flags);
+@@ -2070,6 +2098,7 @@ mm_answer_gss_accept_ctx(int sock, Buffer *m)
+ 		monitor_permit(mon_dispatch, MONITOR_REQ_GSSSTEP, 0);
+ 		monitor_permit(mon_dispatch, MONITOR_REQ_GSSUSEROK, 1);
+ 		monitor_permit(mon_dispatch, MONITOR_REQ_GSSCHECKMIC, 1);
++		monitor_permit(mon_dispatch, MONITOR_REQ_GSSSIGN, 1);
+ 	}
+ 	return (0);
+ }
+@@ -2081,6 +2110,9 @@ mm_answer_gss_checkmic(int sock, Buffer *m)
+ 	OM_uint32 ret;
+ 	u_int len;
+ 
++	if (!options.gss_authentication && !options.gss_keyex)
++		fatal("In GSSAPI monitor when GSSAPI is disabled");
++
+ 	gssbuf.value = buffer_get_string(m, &len);
+ 	gssbuf.length = len;
+ 	mic.value = buffer_get_string(m, &len);
+@@ -2107,6 +2139,9 @@ mm_answer_gss_userok(int sock, Buffer *m)
+ {
+ 	int authenticated;
+ 
++	if (!options.gss_authentication && !options.gss_keyex)
++		fatal("In GSSAPI monitor when GSSAPI is disabled");
++
+ 	authenticated = authctxt->valid && ssh_gssapi_userok(authctxt->user);
+ 
+ 	buffer_clear(m);
+@@ -2120,5 +2155,47 @@ mm_answer_gss_userok(int sock, Buffer *m)
+ 	/* Monitor loop will terminate if authenticated */
+ 	return (authenticated);
+ }
++
++int 
++mm_answer_gss_sign(int socket, Buffer *m)
++{
++	gss_buffer_desc data;
++	gss_buffer_desc hash = GSS_C_EMPTY_BUFFER;
++	OM_uint32 major, minor;
++	u_int len;
++
++	if (!options.gss_authentication && !options.gss_keyex)
++		fatal("In GSSAPI monitor when GSSAPI is disabled");
++
++	data.value = buffer_get_string(m, &len);
++	data.length = len;
++	if (data.length != 20) 
++		fatal("%s: data length incorrect: %d", __func__, 
++		    (int) data.length);
++
++	/* Save the session ID on the first time around */
++	if (session_id2_len == 0) {
++		session_id2_len = data.length;
++		session_id2 = xmalloc(session_id2_len);
++		memcpy(session_id2, data.value, session_id2_len);
++	}
++	major = ssh_gssapi_sign(gsscontext, &data, &hash);
++
++	free(data.value);
++
++	buffer_clear(m);
++	buffer_put_int(m, major);
++	buffer_put_string(m, hash.value, hash.length);
++
++	mm_request_send(socket, MONITOR_ANS_GSSSIGN, m);
++
++	gss_release_buffer(&minor, &hash);
++
++	/* Turn on getpwnam permissions */
++	monitor_permit(mon_dispatch, MONITOR_REQ_PWNAM, 1);
++
++	return (0);
++}
++
+ #endif /* GSSAPI */
+ 
+diff --git a/monitor.h b/monitor.h
+index da63e7d..1be1545 100644
+--- a/monitor.h
++++ b/monitor.h
+@@ -68,6 +68,9 @@ enum monitor_reqtype {
+ #ifdef PAM_ENHANCEMENT
+         MONITOR_REQ_AUTHMETHOD = 114,
+ #endif        
++#ifdef GSSAPI
++	MONITOR_REQ_GSSSIGN = 130, MONITOR_ANS_GSSSIGN = 131,
++#endif        
+ };
+ 
+ struct mm_master;
+diff --git a/monitor_wrap.c b/monitor_wrap.c
+index 95231a3..2b9ba06 100644
+--- a/monitor_wrap.c
++++ b/monitor_wrap.c
+@@ -1103,5 +1103,28 @@ mm_ssh_gssapi_userok(char *user)
+ 	debug3("%s: user %sauthenticated",__func__, authenticated ? "" : "not ");
+ 	return (authenticated);
+ }
++
++OM_uint32
++mm_ssh_gssapi_sign(Gssctxt *ctx, gss_buffer_desc *data, gss_buffer_desc *hash)
++{
++	Buffer m;
++	OM_uint32 major;
++	u_int len;
++
++	buffer_init(&m);
++	buffer_put_string(&m, data->value, data->length);
++
++	mm_request_send(pmonitor->m_recvfd, MONITOR_REQ_GSSSIGN, &m);
++	mm_request_receive_expect(pmonitor->m_recvfd, MONITOR_ANS_GSSSIGN, &m);
++
++	major = buffer_get_int(&m);
++	hash->value = buffer_get_string(&m, &len);
++	hash->length = len;
++
++	buffer_free(&m);
++
++	return(major);
++}
++
+ #endif /* GSSAPI */
+ 
+diff --git a/monitor_wrap.h b/monitor_wrap.h
+index de4a08f..5c9b2b7 100644
+--- a/monitor_wrap.h
++++ b/monitor_wrap.h
+@@ -60,6 +60,7 @@ OM_uint32 mm_ssh_gssapi_accept_ctx(Gssctxt *,
+    gss_buffer_desc *, gss_buffer_desc *, OM_uint32 *);
+ int mm_ssh_gssapi_userok(char *user);
+ OM_uint32 mm_ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t);
++OM_uint32 mm_ssh_gssapi_sign(Gssctxt *, gss_buffer_t, gss_buffer_t);
+ #endif
+ 
+ #ifdef USE_PAM
+diff --git a/readconf.c b/readconf.c
+index db37809..50254b6 100644
+--- a/readconf.c
++++ b/readconf.c
+@@ -147,6 +147,7 @@ typedef enum {
+ 	oClearAllForwardings, oNoHostAuthenticationForLocalhost,
+ 	oEnableSSHKeysign, oRekeyLimit, oVerifyHostKeyDNS, oConnectTimeout,
+ 	oAddressFamily, oGssAuthentication, oGssDelegateCreds,
++	oGssKeyEx,
+ 	oServerAliveInterval, oServerAliveCountMax, oIdentitiesOnly,
+ 	oSendEnv, oControlPath, oControlMaster, oControlPersist,
+ 	oHashKnownHosts,
+@@ -196,9 +197,11 @@ static struct {
+ #if defined(GSSAPI)
+ 	{ "gssapiauthentication", oGssAuthentication },
+ 	{ "gssapidelegatecredentials", oGssDelegateCreds },
++	{ "gssapikeyexchange", oGssKeyEx },
+ #else
+ 	{ "gssapiauthentication", oUnsupported },
+ 	{ "gssapidelegatecredentials", oUnsupported },
++	{ "gssapikeyexchange", oUnsupported },
+ #endif
+ 	{ "fallbacktorsh", oDeprecated },
+ 	{ "usersh", oDeprecated },
+@@ -929,6 +932,10 @@ parse_time:
+ 		intptr = &options->gss_authentication;
+ 		goto parse_flag;
+ 
++	case oGssKeyEx:
++		intptr = &options->gss_keyex;
++		goto parse_flag;
++
+ 	case oGssDelegateCreds:
+ 		intptr = &options->gss_deleg_creds;
+ 		goto parse_flag;
+@@ -1643,6 +1650,7 @@ initialize_options(Options * options)
+ 	options->pubkey_authentication = -1;
+ 	options->challenge_response_authentication = -1;
+ 	options->gss_authentication = -1;
++	options->gss_keyex = -1;
+ 	options->gss_deleg_creds = -1;
+ 	options->password_authentication = -1;
+ 	options->kbd_interactive_authentication = -1;
+@@ -1782,6 +1790,12 @@ fill_default_options(Options * options)
+ #else
+ 		options->gss_authentication = 0;
+ #endif
++	if (options->gss_keyex == -1)
++#ifdef OPTION_DEFAULT_VALUE
++		options->gss_keyex = 1;
++#else
++		options->gss_keyex = 0;
++#endif
+ 	if (options->gss_deleg_creds == -1)
+ 		options->gss_deleg_creds = 0;
+ 	if (options->password_authentication == -1)
+diff --git a/readconf.h b/readconf.h
+index b961309..10ba93a 100644
+--- a/readconf.h
++++ b/readconf.h
+@@ -45,6 +45,7 @@ typedef struct {
+ 	int     challenge_response_authentication;
+ 					/* Try S/Key or TIS, authentication. */
+ 	int     gss_authentication;	/* Try GSS authentication */
++	int     gss_keyex;		/* Try GSS key exchange */
+ 	int     gss_deleg_creds;	/* Delegate GSS credentials */
+ 	int     password_authentication;	/* Try password
+ 						 * authentication. */
+diff --git a/servconf.c b/servconf.c
+index 1a68479..53146af 100644
+--- a/servconf.c
++++ b/servconf.c
+@@ -117,6 +117,7 @@ initialize_server_options(ServerOptions *options)
+ 	options->kerberos_ticket_cleanup = -1;
+ 	options->kerberos_get_afs_token = -1;
+ 	options->gss_authentication=-1;
++	options->gss_keyex = -1;
+ 	options->gss_cleanup_creds = -1;
+ 	options->gss_strict_acceptor = -1;
+ 	options->password_authentication = -1;
+@@ -300,6 +301,12 @@ fill_default_server_options(ServerOptions *options)
+ #else
+ 		options->gss_authentication = 0;
+ #endif
++	if (options->gss_keyex == -1)
++#ifdef OPTION_DEFAULT_VALUE
++		options->gss_keyex = 1;
++#else
++		options->gss_keyex = 0;
++#endif
+ 	if (options->gss_cleanup_creds == -1)
+ 		options->gss_cleanup_creds = 1;
+ 	if (options->gss_strict_acceptor == -1)
+@@ -442,6 +449,7 @@ typedef enum {
+ 	sHostbasedUsesNameFromPacketOnly, sHostbasedAcceptedKeyTypes,
+ 	sHostKeyAlgorithms,
+ 	sClientAliveInterval, sClientAliveCountMax, sAuthorizedKeysFile,
++	sGssKeyEx,
+ 	sGssAuthentication, sGssCleanupCreds, sGssStrictAcceptor,
+ 	sAcceptEnv, sPermitTunnel,
+ 	sMatch, sPermitOpen, sForceCommand, sChrootDirectory,
+@@ -518,6 +526,7 @@ static struct {
+ 	{ "afstokenpassing", sUnsupported, SSHCFG_GLOBAL },
+ #ifdef GSSAPI
+ 	{ "gssapiauthentication", sGssAuthentication, SSHCFG_ALL },
++	{ "gssapikeyexchange", sGssKeyEx, SSHCFG_ALL },
+ #ifdef USE_GSS_STORE_CRED
+ 	{ "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL },
+ #else /* USE_GSS_STORE_CRED */
+@@ -526,6 +535,7 @@ static struct {
+ 	{ "gssapistrictacceptorcheck", sGssStrictAcceptor, SSHCFG_GLOBAL },
+ #else
+ 	{ "gssapiauthentication", sUnsupported, SSHCFG_ALL },
++	{ "gssapikeyexchange", sUnsupported, SSHCFG_ALL },
+ 	{ "gssapicleanupcredentials", sUnsupported, SSHCFG_GLOBAL },
+ 	{ "gssapistrictacceptorcheck", sUnsupported, SSHCFG_GLOBAL },
+ #endif
+@@ -1309,6 +1319,10 @@ process_server_config_line(ServerOptions *options, char *line,
+ 		intptr = &options->gss_authentication;
+ 		goto parse_flag;
+ 
++	case sGssKeyEx:
++		intptr = &options->gss_keyex;
++		goto parse_flag;
++
+ 	case sGssCleanupCreds:
+ 		intptr = &options->gss_cleanup_creds;
+ 		goto parse_flag;
+@@ -2355,6 +2369,7 @@ dump_config(ServerOptions *o)
+ #endif
+ #ifdef GSSAPI
+ 	dump_cfg_fmtint(sGssAuthentication, o->gss_authentication);
++	dump_cfg_fmtint(sGssKeyEx, o->gss_keyex);
+ 	dump_cfg_fmtint(sGssCleanupCreds, o->gss_cleanup_creds);
+ #endif
+ 	dump_cfg_fmtint(sPasswordAuthentication, o->password_authentication);
+diff --git a/servconf.h b/servconf.h
+index 8c86b57..2175645 100644
+--- a/servconf.h
++++ b/servconf.h
+@@ -122,6 +122,7 @@ typedef struct {
+ 	int     kerberos_get_afs_token;		/* If true, try to get AFS token if
+ 						 * authenticated with Kerberos. */
+ 	int     gss_authentication;	/* If true, permit GSSAPI authentication */
++	int     gss_keyex;		/* If true, permit GSSAPI key exchange */
+ 	int     gss_cleanup_creds;	/* If true, destroy cred cache on logout */
+ 	int     gss_strict_acceptor;	/* If true, restrict the GSSAPI acceptor name */
+ 	int     password_authentication;	/* If true, permit password
+diff --git a/ssh-gss.h b/ssh-gss.h
+index a99d7f0..43c33f9 100644
+--- a/ssh-gss.h
++++ b/ssh-gss.h
+@@ -61,6 +61,17 @@
+ 
+ #define SSH_GSS_OIDTYPE 0x06
+ 
++#define SSH2_MSG_KEXGSS_INIT                            30
++#define SSH2_MSG_KEXGSS_CONTINUE                        31
++#define SSH2_MSG_KEXGSS_COMPLETE                        32
++#define SSH2_MSG_KEXGSS_HOSTKEY                         33
++#define SSH2_MSG_KEXGSS_ERROR                           34
++#define SSH2_MSG_KEXGSS_GROUPREQ			40
++#define SSH2_MSG_KEXGSS_GROUP				41
++#define KEX_GSS_GRP1_SHA1_ID				"gss-group1-sha1-"
++#define KEX_GSS_GRP14_SHA1_ID				"gss-group14-sha1-"
++#define KEX_GSS_GEX_SHA1_ID				"gss-gex-sha1-"
++
+ typedef struct {
+ 	char *filename;
+ 	char *envvar;
+@@ -98,6 +109,7 @@ typedef struct {
+ } Gssctxt;
+ 
+ extern ssh_gssapi_mech *supported_mechs[];
++extern Gssctxt *gss_kex_context;
+ 
+ int  ssh_gssapi_check_oid(Gssctxt *, void *, size_t);
+ void ssh_gssapi_set_oid_data(Gssctxt *, void *, size_t);
+@@ -122,6 +134,11 @@ void ssh_gssapi_buildmic(Buffer *, const char *, const char *, const char *);
+ int ssh_gssapi_check_mechanism(Gssctxt **, gss_OID, const char *);
+ 
+ /* In the server */
++typedef int ssh_gssapi_check_fn(Gssctxt **, gss_OID, const char *);
++char *ssh_gssapi_client_mechanisms(const char *host);
++char *ssh_gssapi_kex_mechs(gss_OID_set, ssh_gssapi_check_fn *, const char *);
++gss_OID ssh_gssapi_id_kex(Gssctxt *, char *, int);
++int ssh_gssapi_server_check_mech(Gssctxt **,gss_OID, const char *);
+ OM_uint32 ssh_gssapi_server_ctx(Gssctxt **, gss_OID);
+ int ssh_gssapi_userok(char *name);
+ OM_uint32 ssh_gssapi_checkmic(Gssctxt *, gss_buffer_t, gss_buffer_t);
+@@ -129,6 +146,8 @@ void ssh_gssapi_do_child(char ***, u_int *);
+ void ssh_gssapi_cleanup_creds(void);
+ void ssh_gssapi_storecreds(void);
+ 
++char *ssh_gssapi_server_mechanisms(void);
++int ssh_gssapi_oid_table_ok();
+ #endif /* GSSAPI */
+ 
+ #endif /* _SSH_GSS_H */
+diff --git a/ssh_config b/ssh_config
+index 03a228f..ff42df6 100644
+--- a/ssh_config
++++ b/ssh_config
+@@ -26,6 +26,7 @@
+ #   HostbasedAuthentication no
+ #   GSSAPIAuthentication no
+ #   GSSAPIDelegateCredentials no
++#   GSSAPIKeyExchange yes
+ #   BatchMode no
+ #   CheckHostIP yes
+ #   AddressFamily any
+diff --git a/ssh_config.4 b/ssh_config.4
+index 720451e..016adda 100644
+--- a/ssh_config.4
++++ b/ssh_config.4
+@@ -757,6 +757,12 @@ Specifies whether user authentication based on GSSAPI is allowed.
+ The default on Solaris is
+ .Dq yes .
+ Note that this option applies to protocol version 2 only.
++.It Cm GSSAPIKeyExchange
++Specifies whether key exchange based on GSSAPI may be used. When using
++GSSAPI key exchange the server need not have a host key.
++The default on Solaris is
++.Dq yes .
++Note that this option applies to protocol version 2 only.
+ .It Cm GSSAPIDelegateCredentials
+ Forward (delegate) credentials to the server.
+ The default is
+diff --git a/sshconnect2.c b/sshconnect2.c
+index 95593b9..54ddccb 100644
+--- a/sshconnect2.c
++++ b/sshconnect2.c
+@@ -164,11 +164,34 @@ ssh_kex2(char *host, struct sockaddr *hostaddr, u_short port)
+ 	struct kex *kex;
+ 	int r;
+ 
++#ifdef GSSAPI
++	char *orig = NULL, *gss = NULL;
++	char *gss_host = NULL;
++#endif
++
+ 	xxx_host = host;
+ 	xxx_hostaddr = hostaddr;
+ 
+ 	myproposal[PROPOSAL_KEX_ALGS] = compat_kex_proposal(
+ 	    options.kex_algorithms);
++
++#ifdef GSSAPI
++	if (options.gss_keyex) {
++		/* Add the GSSAPI mechanisms currently supported on this 
++		 * client to the key exchange algorithm proposal */
++		orig = myproposal[PROPOSAL_KEX_ALGS];
++
++		gss_host = (char *)get_canonical_hostname(1);
++
++		gss = ssh_gssapi_client_mechanisms(gss_host);
++		if (gss) {
++			debug("Offering GSSAPI proposal: %s", gss);
++			xasprintf(&myproposal[PROPOSAL_KEX_ALGS],
++			    "%s,%s", gss, orig);
++		}
++	}
++#endif
++
+ 	myproposal[PROPOSAL_ENC_ALGS_CTOS] =
+ 	    compat_cipher_proposal(options.ciphers);
+ 	myproposal[PROPOSAL_ENC_ALGS_STOC] =
+@@ -197,6 +220,17 @@ ssh_kex2(char *host, struct sockaddr *hostaddr, u_short port)
+ 		    order_hostkeyalgs(host, hostaddr, port));
+ 	}
+ 
++#ifdef GSSAPI
++	/* If we've got GSSAPI algorithms, then we also support the
++	 * 'null' hostkey, as a last resort */
++	if (options.gss_keyex && gss) {
++		orig = myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS];
++		xasprintf(&myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS], 
++		    "%s,null", orig);
++		free(gss);
++	}
++#endif
++
+ 	if (options.rekey_limit || options.rekey_interval)
+ 		packet_set_rekey_limits((u_int32_t)options.rekey_limit,
+ 		    (time_t)options.rekey_interval);
+@@ -215,9 +249,22 @@ ssh_kex2(char *host, struct sockaddr *hostaddr, u_short port)
+ # endif
+ #endif
+ 	kex->kex[KEX_C25519_SHA256] = kexc25519_client;
++#ifdef GSSAPI
++	if (options.gss_keyex) {
++		kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_client;
++		kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_client;
++		kex->kex[KEX_GSS_GEX_SHA1] = kexgss_client;
++	}
++#endif
+ 	kex->client_version_string=client_version_string;
+ 	kex->server_version_string=server_version_string;
+ 	kex->verify_host_key=&verify_host_key_callback;
++#ifdef GSSAPI
++	if (options.gss_keyex) {
++		kex->gss_deleg_creds = options.gss_deleg_creds;
++		kex->gss_host = gss_host;
++	}
++#endif
+ 
+ 	dispatch_run(DISPATCH_BLOCK, &kex->done, active_state);
+ 
+@@ -310,6 +357,7 @@ int	input_gssapi_token(int type, u_int32_t, void *);
+ int	input_gssapi_hash(int type, u_int32_t, void *);
+ int	input_gssapi_error(int, u_int32_t, void *);
+ int	input_gssapi_errtok(int, u_int32_t, void *);
++int	userauth_gsskeyex(Authctxt *authctxt);
+ #endif
+ 
+ void	userauth(Authctxt *, char *);
+@@ -325,6 +373,11 @@ static char *authmethods_get(void);
+ 
+ Authmethod authmethods[] = {
+ #ifdef GSSAPI
++	{"gssapi-keyex",
++		userauth_gsskeyex,
++		NULL,
++		&options.gss_authentication,
++		NULL},
+ 	{"gssapi-with-mic",
+ 		userauth_gssapi,
+ 		NULL,
+@@ -649,7 +702,10 @@ userauth_gssapi(Authctxt *authctxt)
+ 	 * once. */
+ 
+ 	if (gss_supported == NULL)
+-		gss_indicate_mechs(&min, &gss_supported);
++		if (GSS_ERROR(gss_indicate_mechs(&min, &gss_supported))) {
++			gss_supported = NULL;
++			return 0;
++		}
+ 
+ 	/* Check to see if the mechanism is usable before we offer it */
+ 	while (mech < gss_supported->count && !ok) {
+@@ -753,8 +809,8 @@ input_gssapi_response(int type, u_int32_t plen, void *ctxt)
+ {
+ 	Authctxt *authctxt = ctxt;
+ 	Gssctxt *gssctxt;
+-	int oidlen;
+-	char *oidv;
++	u_int oidlen;
++	u_char *oidv;
+ 
+ 	if (authctxt == NULL)
+ 		fatal("input_gssapi_response: no authentication context");
+@@ -867,6 +923,48 @@ input_gssapi_error(int type, u_int32_t plen, void *ctxt)
+ 	free(lang);
+ 	return 0;
+ }
++
++int
++userauth_gsskeyex(Authctxt *authctxt)
++{
++	Buffer b;
++	gss_buffer_desc gssbuf;
++	gss_buffer_desc mic = GSS_C_EMPTY_BUFFER;
++	OM_uint32 ms;
++
++	static int attempt = 0;
++	if (attempt++ >= 1)
++		return (0);
++
++	if (gss_kex_context == NULL) {
++		debug("No valid Key exchange context"); 
++		return (0);
++	}
++
++	ssh_gssapi_buildmic(&b, authctxt->server_user, authctxt->service,
++	    "gssapi-keyex");
++
++	gssbuf.value = buffer_ptr(&b);
++	gssbuf.length = buffer_len(&b);
++
++	if (GSS_ERROR(ssh_gssapi_sign(gss_kex_context, &gssbuf, &mic))) {
++		buffer_free(&b);
++		return (0);
++	}
++
++	packet_start(SSH2_MSG_USERAUTH_REQUEST);
++	packet_put_cstring(authctxt->server_user);
++	packet_put_cstring(authctxt->service);
++	packet_put_cstring(authctxt->method->name);
++	packet_put_string(mic.value, mic.length);
++	packet_send();
++
++	buffer_free(&b);
++	gss_release_buffer(&ms, &mic);
++
++	return (1);
++}
++
+ #endif /* GSSAPI */
+ 
+ int
+diff --git a/sshd.c b/sshd.c
+index 87032ec..6215b2c 100644
+--- a/sshd.c
++++ b/sshd.c
+@@ -1833,10 +1833,13 @@ main(int ac, char **av)
+ 		logit("Disabling protocol version 1. Could not load host key");
+ 		options.protocol &= ~SSH_PROTO_1;
+ 	}
++#ifndef GSSAPI
++	/* The GSSAPI key exchange can run without a host key */
+ 	if ((options.protocol & SSH_PROTO_2) && !sensitive_data.have_ssh2_key) {
+ 		logit("Disabling protocol version 2. Could not load host key");
+ 		options.protocol &= ~SSH_PROTO_2;
+ 	}
++#endif
+ 	if (!(options.protocol & (SSH_PROTO_1|SSH_PROTO_2))) {
+ 		logit("sshd: no hostkeys available -- exiting.");
+ 		exit(1);
+@@ -2594,6 +2597,48 @@ do_ssh2_kex(void)
+ 	myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = compat_pkalg_proposal(
+ 	    list_hostkey_types());
+ 
++#ifdef GSSAPI
++	{
++	char *orig;
++	char *gss = NULL;
++	char *newstr = NULL;
++	orig = myproposal[PROPOSAL_KEX_ALGS];
++
++	/* 
++	 * If we don't have a host key, then there's no point advertising
++	 * the other key exchange algorithms
++	 */
++
++	if (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS]) == 0)
++		orig = NULL;
++
++	if (options.gss_keyex)
++		gss = ssh_gssapi_server_mechanisms();
++	else
++		gss = NULL;
++
++	if (gss && orig)
++		xasprintf(&newstr, "%s,%s", gss, orig);
++	else if (gss)
++		newstr = gss;
++	else if (orig)
++		newstr = orig;
++
++	/* 
++	 * If we've got GSSAPI mechanisms, then we've got the 'null' host
++	 * key alg, but we can't tell people about it unless its the only
++  	 * host key algorithm we support
++	 */
++	if (gss && (strlen(myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS])) == 0)
++		myproposal[PROPOSAL_SERVER_HOST_KEY_ALGS] = "null";
++
++	if (newstr)
++		myproposal[PROPOSAL_KEX_ALGS] = newstr;
++	else
++		fatal("No supported key exchange algorithms");
++	}
++#endif
++
+ 	/* start key exchange */
+ 	if ((r = kex_setup(active_state, myproposal)) != 0)
+ 		fatal("kex_setup: %s", ssh_err(r));
+@@ -2608,6 +2653,13 @@ do_ssh2_kex(void)
+ # endif
+ #endif
+ 	kex->kex[KEX_C25519_SHA256] = kexc25519_server;
++#ifdef GSSAPI
++	if (options.gss_keyex) {
++		kex->kex[KEX_GSS_GRP1_SHA1] = kexgss_server;
++		kex->kex[KEX_GSS_GRP14_SHA1] = kexgss_server;
++		kex->kex[KEX_GSS_GEX_SHA1] = kexgss_server;
++	}
++#endif
+ 	kex->server = 1;
+ 	kex->client_version_string=client_version_string;
+ 	kex->server_version_string=server_version_string;
+diff --git a/sshd_config b/sshd_config
+index 4d77f05..611656b 100644
+--- a/sshd_config
++++ b/sshd_config
+@@ -82,8 +82,9 @@ AuthorizedKeysFile	.ssh/authorized_keys
+ #KerberosGetAFSToken no
+ 
+ # GSSAPI options
+-#GSSAPIAuthentication no
++#GSSAPIAuthentication yes
+ #GSSAPICleanupCredentials yes
++#GSSAPIKeyExchange yes
+ 
+ # Set this to 'yes' to enable PAM authentication, account processing,
+ # and session processing. If this is enabled, PAM authentication will
+diff --git a/sshd_config.4 b/sshd_config.4
+index 03c5b52..bd70a68 100644
+--- a/sshd_config.4
++++ b/sshd_config.4
+@@ -621,6 +621,12 @@ Specifies whether user authentication based on GSSAPI is allowed.
+ The default on Solaris is
+ .Dq yes .
+ Note that this option applies to protocol version 2 only.
++.It Cm GSSAPIKeyExchange
++Specifies whether key exchange based on GSSAPI is allowed. GSSAPI key exchange
++doesn't rely on ssh keys to verify host identity.
++The default on Solaris is
++.Dq yes .
++Note that this option applies to protocol version 2 only.
+ .It Cm GSSAPICleanupCredentials
+ Specifies whether to automatically destroy the user's credentials cache
+ on logout.
+diff --git a/sshkey.c b/sshkey.c
+index 32dd8f2..afe5579 100644
+--- a/sshkey.c
++++ b/sshkey.c
+@@ -112,6 +112,7 @@ static const struct keytype keytypes[] = {
+ #  endif /* OPENSSL_HAS_NISTP521 */
+ # endif /* OPENSSL_HAS_ECC */
+ #endif /* WITH_OPENSSL */
++	{ "null", "null", KEY_NULL, 0, 0 },
+ 	{ NULL, NULL, -1, -1, 0 }
+ };
+ 
+diff --git a/sshkey.h b/sshkey.h
+index c8d3cdd..47bd017 100644
+--- a/sshkey.h
++++ b/sshkey.h
+@@ -62,6 +62,9 @@ enum sshkey_types {
+ 	KEY_DSA_CERT,
+ 	KEY_ECDSA_CERT,
+ 	KEY_ED25519_CERT,
++	KEY_RSA_CERT_V00,
++	KEY_DSA_CERT_V00,
++	KEY_NULL,
+ 	KEY_UNSPEC
+ };
+ 
+-- 
+2.5.4 (Apple Git-61)
+
--- old/build/openssh/patches/0016-Enable-login-to-a-role-if-PAM-is-ok-with-it.patch	Wed Feb 10 16:25:01 2016
+++ /dev/null	Wed Feb 10 16:25:01 2016
@@ -1,162 +0,0 @@
-From 7332e7d5627a72f1587bca85f3fd37f42b419754 Mon Sep 17 00:00:00 2001
-From: oracle <solaris@oracle.com>
-Date: Mon, 3 Aug 2015 14:38:19 -0700
-Subject: [PATCH 16/30] Enable login to a role if PAM is ok with it
-
----
- auth-pam.c        | 14 ++++++++++++++
- auth-pam.h        |  3 +++
- auth.h            |  3 +++
- auth2-hostbased.c | 10 ++++++++++
- auth2.c           |  8 ++++++++
- monitor.c         | 15 ++++++++++++++-
- 6 files changed, 52 insertions(+), 1 deletion(-)
-
-diff --git a/auth-pam.c b/auth-pam.c
-index 7bdee5c..6470d5e 100644
---- a/auth-pam.c
-+++ b/auth-pam.c
-@@ -1038,6 +1038,20 @@ do_pam_account(void)
- 	return (sshpam_account_status);
- }
- 
-+#ifdef HAVE_PAM_AUSER
-+void
-+do_pam_set_auser(const char* auser)
-+{
-+	if (auser != NULL) {
-+		debug("PAM: setting PAM_AUSER to \"%s\"", auser);
-+		sshpam_err = pam_set_item(sshpam_handle, PAM_AUSER, auser);
-+		if (sshpam_err != PAM_SUCCESS)
-+			error("PAM: failed to set PAM_AUSER: %s",
-+			    pam_strerror(sshpam_handle, sshpam_err));
-+	}
-+}
-+#endif
-+
- void
- do_pam_set_tty(const char *tty)
- {
-diff --git a/auth-pam.h b/auth-pam.h
-index a1a2b52..6c41fd9 100644
---- a/auth-pam.h
-+++ b/auth-pam.h
-@@ -35,6 +35,9 @@ void start_pam(Authctxt *);
- void finish_pam(void);
- u_int do_pam_account(void);
- void do_pam_session(void);
-+#ifdef HAVE_PAM_AUSER
-+void do_pam_set_auser(const char *);
-+#endif
- void do_pam_set_tty(const char *);
- void do_pam_setcred(int );
- void do_pam_chauthtok(void);
-diff --git a/auth.h b/auth.h
-index a0e41a4..c336cf0 100644
---- a/auth.h
-+++ b/auth.h
-@@ -84,6 +84,9 @@ struct Authctxt {
- #ifdef PAM_ENHANCEMENT
-         char            *authmethod_name;
- #endif 
-+#ifdef HAVE_PAM_AUSER
-+	char		*auser;
-+#endif 
- };
- /*
-  * Every authentication method has to handle authentication requests for
-diff --git a/auth2-hostbased.c b/auth2-hostbased.c
-index e2327cf..c0fcc4d 100644
---- a/auth2-hostbased.c
-+++ b/auth2-hostbased.c
-@@ -85,6 +85,9 @@ userauth_hostbased(Authctxt *authctxt)
- 	buffer_dump(&b);
- 	buffer_free(&b);
- #endif
-+#ifdef HAVE_PAM_AUSER
-+	authctxt->auser = NULL;
-+#endif
- 	pktype = key_type_from_name(pkalg);
- 	if (pktype == KEY_UNSPEC) {
- 		/* this is perfectly legal */
-@@ -142,6 +145,13 @@ userauth_hostbased(Authctxt *authctxt)
- 			buffer_len(&b))) == 1)
- 		authenticated = 1;
- 
-+#ifdef HAVE_PAM_AUSER
-+	if (authenticated) {
-+		authctxt->auser = cuser;
-+		cuser = NULL;
-+	}
-+#endif
-+
- 	buffer_free(&b);
- done:
- 	debug2("userauth_hostbased: authenticated %d", authenticated);
-diff --git a/auth2.c b/auth2.c
-index 5a3ef1b..b456237 100644
---- a/auth2.c
-+++ b/auth2.c
-@@ -339,6 +339,14 @@ userauth_finish(Authctxt *authctxt, int authenticated, const char *method,
- #endif
- 	}
- 
-+#ifdef HAVE_PAM_AUSER
-+	if (!use_privsep) {
-+		do_pam_set_auser(authctxt->auser);
-+		free(authctxt->auser);
-+		authctxt->auser = NULL;	
-+	}
-+#endif
-+
- 	if (authenticated && options.num_auth_methods != 0) {
- 
- #if defined(USE_PAM) && defined(PAM_ENHANCEMENT)
-diff --git a/monitor.c b/monitor.c
-index 7ac4c61..20ed152 100644
---- a/monitor.c
-+++ b/monitor.c
-@@ -461,6 +461,12 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor)
- 		}
- 	}
- 
-+#if defined(HAVE_PAM_AUSER) && defined(USE_PAM)
-+	if (hostbased_cuser != NULL) {
-+		free(hostbased_cuser);
-+		hostbased_cuser = NULL;
-+	}
-+#endif
- 	if (!authctxt->valid)
- 		fatal("%s: authenticated invalid user", __func__);
- 	if (strcmp(auth_method, "unknown") == 0)
-@@ -694,12 +700,14 @@ monitor_reset_key_state(void)
- {
- 	/* reset state */
- 	free(key_blob);
-+#if !defined(HAVE_PAM_AUSER) || !defined(USE_PAM)
- 	free(hostbased_cuser);
-+	hostbased_cuser = NULL;
-+#endif
- 	free(hostbased_chost);
- 	key_blob = NULL;
- 	key_bloblen = 0;
- 	key_blobtype = MM_NOKEY;
--	hostbased_cuser = NULL;
- 	hostbased_chost = NULL;
- }
- 
-@@ -1146,6 +1154,11 @@ mm_answer_pam_account(int sock, Buffer *m)
- 	if (!options.use_pam)
- 		fatal("UsePAM not set, but ended up in %s anyway", __func__);
- 
-+#ifdef HAVE_PAM_AUSER
-+	if (hostbased_cuser != NULL)
-+		do_pam_set_auser(hostbased_cuser);
-+#endif
-+
- 	ret = do_pam_account();
- 
- 	buffer_put_int(m, ret);
--- 
-2.3.2 (Apple Git-55)
-
--- /dev/null	Wed Feb 10 16:25:01 2016
+++ new/build/openssh/patches/0017-Enable-login-to-a-role-if-PAM-is-ok-with-it.patch	Wed Feb 10 16:25:01 2016
@@ -0,0 +1,162 @@
+From 101a7bf94901c79603da5750d325f9de67fe3413 Mon Sep 17 00:00:00 2001
+From: oracle <solaris@oracle.com>
+Date: Mon, 3 Aug 2015 14:38:19 -0700
+Subject: [PATCH 17/36] Enable login to a role if PAM is ok with it
+
+---
+ auth-pam.c        | 14 ++++++++++++++
+ auth-pam.h        |  3 +++
+ auth.h            |  3 +++
+ auth2-hostbased.c | 10 ++++++++++
+ auth2.c           |  8 ++++++++
+ monitor.c         | 15 ++++++++++++++-
+ 6 files changed, 52 insertions(+), 1 deletion(-)
+
+diff --git a/auth-pam.c b/auth-pam.c
+index 7bdee5c..6470d5e 100644
+--- a/auth-pam.c
++++ b/auth-pam.c
+@@ -1038,6 +1038,20 @@ do_pam_account(void)
+ 	return (sshpam_account_status);
+ }
+ 
++#ifdef HAVE_PAM_AUSER
++void
++do_pam_set_auser(const char* auser)
++{
++	if (auser != NULL) {
++		debug("PAM: setting PAM_AUSER to \"%s\"", auser);
++		sshpam_err = pam_set_item(sshpam_handle, PAM_AUSER, auser);
++		if (sshpam_err != PAM_SUCCESS)
++			error("PAM: failed to set PAM_AUSER: %s",
++			    pam_strerror(sshpam_handle, sshpam_err));
++	}
++}
++#endif
++
+ void
+ do_pam_set_tty(const char *tty)
+ {
+diff --git a/auth-pam.h b/auth-pam.h
+index a1a2b52..6c41fd9 100644
+--- a/auth-pam.h
++++ b/auth-pam.h
+@@ -35,6 +35,9 @@ void start_pam(Authctxt *);
+ void finish_pam(void);
+ u_int do_pam_account(void);
+ void do_pam_session(void);
++#ifdef HAVE_PAM_AUSER
++void do_pam_set_auser(const char *);
++#endif
+ void do_pam_set_tty(const char *);
+ void do_pam_setcred(int );
+ void do_pam_chauthtok(void);
+diff --git a/auth.h b/auth.h
+index a0e41a4..c336cf0 100644
+--- a/auth.h
++++ b/auth.h
+@@ -84,6 +84,9 @@ struct Authctxt {
+ #ifdef PAM_ENHANCEMENT
+         char            *authmethod_name;
+ #endif 
++#ifdef HAVE_PAM_AUSER
++	char		*auser;
++#endif 
+ };
+ /*
+  * Every authentication method has to handle authentication requests for
+diff --git a/auth2-hostbased.c b/auth2-hostbased.c
+index e2327cf..c0fcc4d 100644
+--- a/auth2-hostbased.c
++++ b/auth2-hostbased.c
+@@ -85,6 +85,9 @@ userauth_hostbased(Authctxt *authctxt)
+ 	buffer_dump(&b);
+ 	buffer_free(&b);
+ #endif
++#ifdef HAVE_PAM_AUSER
++	authctxt->auser = NULL;
++#endif
+ 	pktype = key_type_from_name(pkalg);
+ 	if (pktype == KEY_UNSPEC) {
+ 		/* this is perfectly legal */
+@@ -142,6 +145,13 @@ userauth_hostbased(Authctxt *authctxt)
+ 			buffer_len(&b))) == 1)
+ 		authenticated = 1;
+ 
++#ifdef HAVE_PAM_AUSER
++	if (authenticated) {
++		authctxt->auser = cuser;
++		cuser = NULL;
++	}
++#endif
++
+ 	buffer_free(&b);
+ done:
+ 	debug2("userauth_hostbased: authenticated %d", authenticated);
+diff --git a/auth2.c b/auth2.c
+index 5a3ef1b..b456237 100644
+--- a/auth2.c
++++ b/auth2.c
+@@ -339,6 +339,14 @@ userauth_finish(Authctxt *authctxt, int authenticated, const char *method,
+ #endif
+ 	}
+ 
++#ifdef HAVE_PAM_AUSER
++	if (!use_privsep) {
++		do_pam_set_auser(authctxt->auser);
++		free(authctxt->auser);
++		authctxt->auser = NULL;	
++	}
++#endif
++
+ 	if (authenticated && options.num_auth_methods != 0) {
+ 
+ #if defined(USE_PAM) && defined(PAM_ENHANCEMENT)
+diff --git a/monitor.c b/monitor.c
+index 7ac4c61..20ed152 100644
+--- a/monitor.c
++++ b/monitor.c
+@@ -461,6 +461,12 @@ monitor_child_preauth(Authctxt *_authctxt, struct monitor *pmonitor)
+ 		}
+ 	}
+ 
++#if defined(HAVE_PAM_AUSER) && defined(USE_PAM)
++	if (hostbased_cuser != NULL) {
++		free(hostbased_cuser);
++		hostbased_cuser = NULL;
++	}
++#endif
+ 	if (!authctxt->valid)
+ 		fatal("%s: authenticated invalid user", __func__);
+ 	if (strcmp(auth_method, "unknown") == 0)
+@@ -694,12 +700,14 @@ monitor_reset_key_state(void)
+ {
+ 	/* reset state */
+ 	free(key_blob);
++#if !defined(HAVE_PAM_AUSER) || !defined(USE_PAM)
+ 	free(hostbased_cuser);
++	hostbased_cuser = NULL;
++#endif
+ 	free(hostbased_chost);
+ 	key_blob = NULL;
+ 	key_bloblen = 0;
+ 	key_blobtype = MM_NOKEY;
+-	hostbased_cuser = NULL;
+ 	hostbased_chost = NULL;
+ }
+ 
+@@ -1146,6 +1154,11 @@ mm_answer_pam_account(int sock, Buffer *m)
+ 	if (!options.use_pam)
+ 		fatal("UsePAM not set, but ended up in %s anyway", __func__);
+ 
++#ifdef HAVE_PAM_AUSER
++	if (hostbased_cuser != NULL)
++		do_pam_set_auser(hostbased_cuser);
++#endif
++
+ 	ret = do_pam_account();
+ 
+ 	buffer_put_int(m, ret);
+-- 
+2.5.4 (Apple Git-61)
+
--- old/build/openssh/patches/0017-PAM-setcred-failures.patch	Wed Feb 10 16:25:01 2016
+++ /dev/null	Wed Feb 10 16:25:01 2016
@@ -1,65 +0,0 @@
-From 74f9ed4532e569d8fe477ebfae5dc69a3f5dd398 Mon Sep 17 00:00:00 2001
-From: oracle <solaris@oracle.com>
-Date: Mon, 3 Aug 2015 14:38:26 -0700
-Subject: [PATCH 17/30] PAM setcred failures
-
-#
-# This patch contains bug fixes to the PAM credential and session operations.
-# In the original OpenSSH, the server only gives warnings and still allows
-# users to log in when pam_setcred() or pam_open_session() fail, if user auth
-# method is not keyboard-interactive or password.  This is not a correct
-# behavior. The server should just fatal out, when these functions fail.
-#
-# We have contributed back these bug fixes to the OpenSSH upstream community.
-# For more information, see https://bugzilla.mindrot.org/show_bug.cgi?id=2399
-# In the future, if these bug fixes are accepted by the upsteam in a later
-# release, we will remove this patch when we upgrade to that release.
-#
----
- auth-pam.c | 13 +++++++++++++
- 1 file changed, 13 insertions(+)
-
-diff --git a/auth-pam.c b/auth-pam.c
-index 6470d5e..2124546 100644
---- a/auth-pam.c
-+++ b/auth-pam.c
-@@ -1083,12 +1083,19 @@ do_pam_setcred(int init)
- 		sshpam_cred_established = 1;
- 		return;
- 	}
-+
-+#ifdef PAM_BUGFIX
-+	/* Server will fatal out when pam_setcred() failed. */
-+	fatal("PAM: pam_setcred(): %s", pam_strerror(sshpam_handle,
-+	    sshpam_err));
-+#else /* orig */
- 	if (sshpam_authenticated)
- 		fatal("PAM: pam_setcred(): %s",
- 		    pam_strerror(sshpam_handle, sshpam_err));
- 	else
- 		debug("PAM: pam_setcred(): %s",
- 		    pam_strerror(sshpam_handle, sshpam_err));
-+#endif /* PAM_BUGFIX */
- }
- 
- static int
-@@ -1181,10 +1188,16 @@ do_pam_session(void)
- 	if (sshpam_err == PAM_SUCCESS)
- 		sshpam_session_open = 1;
- 	else {
-+#ifdef PAM_BUGFIX
-+		/* Server will fatal out when pam_open_session() failed */
-+		fatal("PAM: pam_open_session(): %s",
-+		    pam_strerror(sshpam_handle, sshpam_err));
-+#else /* orig */
- 		sshpam_session_open = 0;
- 		disable_forwarding();
- 		error("PAM: pam_open_session(): %s",
- 		    pam_strerror(sshpam_handle, sshpam_err));
-+#endif /* PAM_BUGFIX */
- 	}
- 
- }
--- 
-2.3.2 (Apple Git-55)
-
--- /dev/null	Wed Feb 10 16:25:01 2016
+++ new/build/openssh/patches/0018-PAM-setcred-failures.patch	Wed Feb 10 16:25:01 2016
@@ -0,0 +1,65 @@
+From d6bad830599b2a95150370954576800b4c6e8947 Mon Sep 17 00:00:00 2001
+From: oracle <solaris@oracle.com>
+Date: Mon, 3 Aug 2015 14:38:26 -0700
+Subject: [PATCH 18/36] PAM setcred failures
+
+#
+# This patch contains bug fixes to the PAM credential and session operations.
+# In the original OpenSSH, the server only gives warnings and still allows
+# users to log in when pam_setcred() or pam_open_session() fail, if user auth
+# method is not keyboard-interactive or password.  This is not a correct
+# behavior. The server should just fatal out, when these functions fail.
+#
+# We have contributed back these bug fixes to the OpenSSH upstream community.
+# For more information, see https://bugzilla.mindrot.org/show_bug.cgi?id=2399
+# In the future, if these bug fixes are accepted by the upsteam in a later
+# release, we will remove this patch when we upgrade to that release.
+#
+---
+ auth-pam.c | 13 +++++++++++++
+ 1 file changed, 13 insertions(+)
+
+diff --git a/auth-pam.c b/auth-pam.c
+index 6470d5e..2124546 100644
+--- a/auth-pam.c
++++ b/auth-pam.c
+@@ -1083,12 +1083,19 @@ do_pam_setcred(int init)
+ 		sshpam_cred_established = 1;
+ 		return;
+ 	}
++
++#ifdef PAM_BUGFIX
++	/* Server will fatal out when pam_setcred() failed. */
++	fatal("PAM: pam_setcred(): %s", pam_strerror(sshpam_handle,
++	    sshpam_err));
++#else /* orig */
+ 	if (sshpam_authenticated)
+ 		fatal("PAM: pam_setcred(): %s",
+ 		    pam_strerror(sshpam_handle, sshpam_err));
+ 	else
+ 		debug("PAM: pam_setcred(): %s",
+ 		    pam_strerror(sshpam_handle, sshpam_err));
++#endif /* PAM_BUGFIX */
+ }
+ 
+ static int
+@@ -1181,10 +1188,16 @@ do_pam_session(void)
+ 	if (sshpam_err == PAM_SUCCESS)
+ 		sshpam_session_open = 1;
+ 	else {
++#ifdef PAM_BUGFIX
++		/* Server will fatal out when pam_open_session() failed */
++		fatal("PAM: pam_open_session(): %s",
++		    pam_strerror(sshpam_handle, sshpam_err));
++#else /* orig */
+ 		sshpam_session_open = 0;
+ 		disable_forwarding();
+ 		error("PAM: pam_open_session(): %s",
+ 		    pam_strerror(sshpam_handle, sshpam_err));
++#endif /* PAM_BUGFIX */
+ 	}
+ 
+ }
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:01 2016
+++ new/build/openssh/patches/0019-Don-t-call-do_pam_setcred-twice.patch	Wed Feb 10 16:25:01 2016
@@ -0,0 +1,47 @@
+From 5d88117bbbf58eab0895f532202ff1c46016ec0f Mon Sep 17 00:00:00 2001
+From: oracle <solaris@oracle.com>
+Date: Mon, 3 Aug 2015 14:38:41 -0700
+Subject: [PATCH 19/36] Don't call do_pam_setcred twice
+
+# This issue has been raised with the upstream OpenSSH community:
+#
+# 2426 OpenSSH doesn't need the second call to do_pam_setcred() on non-Linux
+#      platforms
+# https://bugzilla.mindrot.org/show_bug.cgi?id=2426
+#
+# The OpenSSH maintainers added a call to do_pam_setcred() in
+# platform_setusercontext_post_groups() with no corresponding bugID along with
+# a befuddling comment that initgroups(3C) wipes out supplementary groups:
+#
+#https://anongit.mindrot.org/openssh.git/commit/platform.c?id=cc12418e18242ce1f61d7035da4956274ba13a96
+#
+# This only applies in the Linux world if the LinuxPAM pam_group(8) module
+# has been installed and configured which allows one to assign additional
+# secondary groups to a user using /etc/security/group.conf in addition to
+# /etc/group.  To confuse things a bit more, there is an OpenPAM PAM module
+# of the same name, pam_group(8), which has different functionality, it
+# performs access control based on group membership.
+#
+# In short, this additional call to do_pam_setcred() is Linux-specific and
+# shouldn't be called on Solaris.
+#
+---
+ platform.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/platform.c b/platform.c
+index ee313da..8362a08 100644
+--- a/platform.c
++++ b/platform.c
+@@ -145,7 +145,7 @@ platform_setusercontext(struct passwd *pw)
+ void
+ platform_setusercontext_post_groups(struct passwd *pw)
+ {
+-#if !defined(HAVE_LOGIN_CAP) && defined(USE_PAM)
++#if !defined(HAVE_LOGIN_CAP) && defined(USE_PAM) && !defined(PAM_SUN_CODEBASE)
+ 	/*
+ 	 * PAM credentials may take the form of supplementary groups.
+ 	 * These will have been wiped by the above initgroups() call.
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:01 2016
+++ new/build/openssh/patches/0020-Per-session-xauthfile.patch	Wed Feb 10 16:25:01 2016
@@ -0,0 +1,230 @@
+From 885edd4c7c2e7f77debc253b1d097387bed0d96b Mon Sep 17 00:00:00 2001
+From: oracle <solaris@oracle.com>
+Date: Tue, 22 Dec 2015 17:12:50 -0800
+Subject: [PATCH 20/36] Per-session xauthfile
+
+This patch is to fix a X11 connection failure when a user's home directory
+is read-only.
+
+We have contributed back this fix to the OpenSSH upstream community. For
+more information, see https://bugzilla.mindrot.org/show_bug.cgi?id=2440
+In the future, if this fix is accepted by the upsteam in a later release, we
+will remove this patch when we upgrade to that release.
+---
+ session.c | 129 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ session.h |   3 ++
+ 2 files changed, 132 insertions(+)
+
+diff --git a/session.c b/session.c
+index 5a64715..ab0ac1c 100644
+--- a/session.c
++++ b/session.c
+@@ -62,6 +62,10 @@
+ #include <unistd.h>
+ #include <limits.h>
+ 
++#ifdef PER_SESSION_XAUTHFILE
++#include <libgen.h>
++#endif
++
+ #include "openbsd-compat/sys-queue.h"
+ #include "xmalloc.h"
+ #include "ssh.h"
+@@ -132,6 +136,11 @@ static void do_authenticated2(Authctxt *);
+ 
+ static int session_pty_req(Session *);
+ 
++#ifdef PER_SESSION_XAUTHFILE
++void   session_xauthfile_cleanup(Session *);
++void   cleanup_all_session_xauthfile();
++#endif
++
+ /* import */
+ extern ServerOptions options;
+ extern char *__progname;
+@@ -1218,6 +1227,11 @@ do_setup_env(Session *s, const char *shell)
+ 	if (getenv("TZ"))
+ 		child_set_env(&env, &envsize, "TZ", getenv("TZ"));
+ 
++#ifdef PER_SESSION_XAUTHFILE
++        if (s->auth_file != NULL)
++                child_set_env(&env, &envsize, "XAUTHORITY", s->auth_file);
++#endif
++
+ 	/* Set custom environment options from RSA authentication. */
+ 	if (!options.use_login) {
+ 		while (custom_environment) {
+@@ -2170,6 +2184,11 @@ session_x11_req(Session *s)
+ {
+ 	int success;
+ 
++#ifdef PER_SESSION_XAUTHFILE
++	int fd;
++	char xauthdir[] = "/tmp/ssh-xauth-XXXXXX";
++#endif
++
+ 	if (s->auth_proto != NULL || s->auth_data != NULL) {
+ 		error("session_x11_req: session %d: "
+ 		    "x11 forwarding already active", s->self);
+@@ -2181,13 +2200,71 @@ session_x11_req(Session *s)
+ 	s->screen = packet_get_int();
+ 	packet_check_eom();
+ 
++#ifdef PER_SESSION_XAUTHFILE
++	/*
++	 * Create per session X authority file in the /tmp directory.
++	 *
++	 * If mkdtemp() or open() fails then s->auth_file remains NULL which
++	 * means that we won't set XAUTHORITY variable in child's environment
++	 * and xauth(1) will use the default location for the authority file.
++	 */
++	if (mkdtemp(xauthdir) != NULL) {
++		s->auth_file = xmalloc(MAXPATHLEN);
++		if (snprintf(s->auth_file, MAXPATHLEN, "%s/xauthfile",
++		    xauthdir) >= MAXPATHLEN) {
++			error("temporary X authority file name was too long "
++			    "for the buffer allocated");
++			success = 0;
++			goto out;
++		}
++		/*
++		 * we don't want that "creating new authority file" message to
++		 * be printed by xauth(1) so we must create that file
++		 * beforehand.
++		 */
++		if ((fd = open(s->auth_file, O_CREAT | O_EXCL | O_RDONLY,
++		    S_IRUSR | S_IWUSR)) == -1) {
++			error("failed to create the temporary X authority "
++			    "file %s: %.100s; will use the default one",
++			    s->auth_file, strerror(errno));
++			free(s->auth_file);
++			s->auth_file = NULL;
++			if (rmdir(xauthdir) == -1) {
++				error("cannot remove xauth directory "
++				    "%s: %.100s", xauthdir, strerror(errno));
++			}
++		} else {
++			if (close(fd) != 0) {
++				error("close() failed on temporary X authority "
++				    "file: %s", strerror(errno));
++				success = 0;
++				goto out;
++			}
++			debug("temporary X authority file %s created",
++			    s->auth_file);
++			debug("session number = %d", s->self);
++		}
++	} else {
++		error("failed to create a directory for the temporary X "
++		    "authority file: %.100s; will use the default xauth file",
++		    strerror(errno));
++	}
++#endif
++
+ 	success = session_setup_x11fwd(s);
++
++out:
+ 	if (!success) {
+ 		free(s->auth_proto);
+ 		free(s->auth_data);
+ 		s->auth_proto = NULL;
+ 		s->auth_data = NULL;
++#ifdef PER_SESSION_XAUTHFILE
++		free(s->auth_file);
++		s->auth_file = NULL;
++#endif
+ 	}
++
+ 	return success;
+ }
+ 
+@@ -2378,6 +2455,51 @@ session_pty_cleanup(Session *s)
+ 	PRIVSEP(session_pty_cleanup2(s));
+ }
+ 
++#ifdef PER_SESSION_XAUTHFILE
++/*
++ * We use a different temporary X authority file per session so we should
++ * remove those files when cleanup_exit() is called.
++ */
++void
++session_xauthfile_cleanup(Session *s)
++{
++	if (s == NULL || s->auth_file == NULL) {
++		return;
++	}
++
++	debug("session_xauthfile_cleanup: session %d removing %s", s->self,
++	    s->auth_file);
++
++	if (unlink(s->auth_file) == -1) {
++		error("session_xauthfile_cleanup: cannot remove xauth file "
++		    "%s: %.100s", s->auth_file, strerror(errno));
++		return;
++	}
++
++	/* dirname() will modify s->auth_file but that's ok */
++	if (rmdir(dirname(s->auth_file)) == -1) {
++		error("session_xauthfile_cleanup: "
++		    "cannot remove xauth directory %s: %.100s",
++		    s->auth_file, strerror(errno));
++		return;
++	}
++	free(s->auth_file);
++	s->auth_file = NULL;
++}
++
++/*
++ * This is called by do_cleanup() when cleanup_exit() is called. 
++ */
++void
++cleanup_all_session_xauthfile()
++{
++	int i;
++	for (i = 0; i < sessions_nalloc; i++) {
++                session_xauthfile_cleanup(&sessions[i]);
++	}
++}
++#endif
++
+ static char *
+ sig2name(int sig)
+ {
+@@ -2512,6 +2634,9 @@ session_close(Session *s)
+ 	free(s->auth_display);
+ 	free(s->auth_data);
+ 	free(s->auth_proto);
++#ifdef PER_SESSION_XAUTHFILE
++	session_xauthfile_cleanup(s);
++#endif
+ 	free(s->subsys);
+ 	if (s->env != NULL) {
+ 		for (i = 0; i < s->num_env; i++) {
+@@ -2763,6 +2888,10 @@ do_cleanup(Authctxt *authctxt)
+ 	/* remove agent socket */
+ 	auth_sock_cleanup_proc(authctxt->pw);
+ 
++#ifdef PER_SESSION_XAUTHFILE
++	cleanup_all_session_xauthfile();
++#endif
++
+ 	/*
+ 	 * Cleanup ptys/utmp only if privsep is disabled,
+ 	 * or if running in monitor.
+diff --git a/session.h b/session.h
+index 6a2f35e..276cd04 100644
+--- a/session.h
++++ b/session.h
+@@ -49,6 +49,9 @@ struct Session {
+ 	char	*auth_display;
+ 	char	*auth_proto;
+ 	char	*auth_data;
++#ifdef PER_SESSION_XAUTHFILE
++	char    *auth_file;	/* xauth(1) authority file */
++#endif
+ 	int	single_connection;
+ 
+ 	/* proto 2 */
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:01 2016
+++ new/build/openssh/patches/0021-PubKeyPlugin-support.patch	Wed Feb 10 16:25:01 2016
@@ -0,0 +1,259 @@
+From 3940b5d3e954d472b52da4aed4f8e6f3725411d2 Mon Sep 17 00:00:00 2001
+From: Alex Wilson <alex.wilson@joyent.com>
+Date: Mon, 3 Aug 2015 16:27:44 -0700
+Subject: [PATCH 21/36] PubKeyPlugin support
+
+This adds the PubKeyPlugin directive and associated code from
+SunSSH, allowing an in-process shared library to be called
+into to check public keys for authentication.
+---
+ auth2-pubkey.c | 139 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ servconf.c     |  15 +++++++
+ servconf.h     |   1 +
+ 3 files changed, 155 insertions(+)
+
+diff --git a/auth2-pubkey.c b/auth2-pubkey.c
+index 5aa319c..77b00f7 100644
+--- a/auth2-pubkey.c
++++ b/auth2-pubkey.c
+@@ -22,6 +22,11 @@
+  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+  */
++/*
++ * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
++ * Copyright 2015 Joyent, Inc.
++ * Use is subject to license terms.
++ */
+ 
+ #include "includes.h"
+ 
+@@ -42,11 +47,13 @@
+ #include <time.h>
+ #include <unistd.h>
+ #include <limits.h>
++#include <dlfcn.h>
+ 
+ #include "xmalloc.h"
+ #include "ssh.h"
+ #include "ssh2.h"
+ #include "packet.h"
++#include "digest.h"
+ #include "buffer.h"
+ #include "log.h"
+ #include "misc.h"
+@@ -74,6 +81,15 @@ extern ServerOptions options;
+ extern u_char *session_id2;
+ extern u_int session_id2_len;
+ 
++static const char *RSA_SYM_NAME = "sshd_user_rsa_key_allowed";
++static const char *ECDSA_SYM_NAME = "sshd_user_ecdsa_key_allowed";
++typedef int (*RSA_SYM)(struct passwd *, RSA *, const char *);
++typedef int (*ECDSA_SYM)(struct passwd *, EC_KEY *, const char *);
++
++static const char *UNIV_SYM_NAME = "sshd_user_key_allowed";
++typedef int (*UNIV_SYM)(struct passwd *, const char *,
++    const u_char *, size_t);
++
+ static int
+ userauth_pubkey(Authctxt *authctxt)
+ {
+@@ -1030,6 +1046,125 @@ user_key_command_allowed2(struct passwd *user_pw, Key *key)
+ 	return found_key;
+ }
+ 
++/**
++ * Checks whether or not access is allowed based on a plugin specified
++ * in sshd_config (PubKeyPlugin).
++ *
++ * Note that this expects a symbol in the loaded library that takes
++ * the current user (pwd entry), the current RSA key and it's fingerprint.
++ * The symbol is expected to return 1 on success and 0 on failure.
++ *
++ * While we could optimize this code to dlopen once in the process' lifetime,
++ * sshd is already a slow beast, so this is really not a concern.
++ * The overhead is basically a rounding error compared to everything else, and
++ * it keeps this code minimally invasive.
++ */
++static int
++user_key_allowed_from_plugin(struct passwd *pw, Key *key)
++{
++	RSA_SYM rsa_sym = NULL;
++	ECDSA_SYM ecdsa_sym = NULL;
++	UNIV_SYM univ_sym = NULL;
++	char *fp = NULL;
++	char *argfp = NULL;
++	void *handle = NULL;
++	int success = 0;
++
++	if (options.pubkey_plugin == NULL || pw == NULL || key == NULL ||
++	    (key->type != KEY_RSA && key->type != KEY_RSA1 &&
++	    key->type != KEY_DSA && key->type != KEY_ECDSA))
++		return success;
++
++	handle = dlopen(options.pubkey_plugin, RTLD_NOW);
++	if (handle == NULL) {
++		debug("Unable to open library %s: %s", options.pubkey_plugin,
++		dlerror());
++		goto out;
++	}
++
++	/*
++	 * If we have the new-style universal symbol for checking keys, use
++	 * that instead of the old-style per-key-type symbols.
++	 */
++	univ_sym = (UNIV_SYM)dlsym(handle, UNIV_SYM_NAME);
++	if (univ_sym != NULL) {
++		u_char *blob;
++		const char *type = sshkey_type(key);
++		size_t len = 0;
++		if (sshkey_to_blob(key, &blob, &len) != 0) {
++			debug("failed to convert key to rfc4253 format");
++			goto out;
++		}
++		debug("Invoking %s from %s", UNIV_SYM_NAME,
++		    options.pubkey_plugin);
++		success = (*univ_sym)(pw, type, blob, len);
++		debug("pubkeyplugin returned: %d", success);
++		goto out;
++	}
++
++	/* Otherwise, continue with the old-style fingerprint symbols. */
++	fp = sshkey_fingerprint(key, SSH_DIGEST_MD5, SSH_FP_HEX);
++	if (fp == NULL) {
++		debug("failed to generate fingerprint");
++		goto out;
++	}
++	if (strncmp(fp, "MD5:", 4) != 0) {
++		debug("fingerprint not in MD5:hex format");
++		goto out;
++	}
++	/* give the plugin the string without leading MD5: */
++	argfp = fp + 4;
++
++	switch (key->type) {
++	case KEY_RSA1:
++	case KEY_RSA:
++		rsa_sym = (RSA_SYM)dlsym(handle, RSA_SYM_NAME);
++		if (rsa_sym == NULL) {
++			debug("Unable to resolve symbol %s: %s", RSA_SYM_NAME,
++			dlerror());
++			goto out;
++		}
++		debug2("Invoking %s from %s", RSA_SYM_NAME,
++		    options.pubkey_plugin);
++		success = (*rsa_sym)(pw, key->rsa, argfp);
++		break;
++	case KEY_ECDSA:
++		ecdsa_sym = (ECDSA_SYM)dlsym(handle, ECDSA_SYM_NAME);
++		if (ecdsa_sym == NULL) {
++			debug("Unable to resolve symbol %s: %s", ECDSA_SYM_NAME,
++			dlerror());
++			goto out;
++		}
++		debug2("Invoking %s from %s", ECDSA_SYM_NAME,
++		    options.pubkey_plugin);
++		success = (*ecdsa_sym)(pw, key->ecdsa, argfp);
++		break;
++	default:
++		debug2("user_key_plugins only support RSA and ECDSA keys");
++	}
++
++	debug("pubkeyplugin returned: %d", success);
++
++out:
++	if (handle != NULL) {
++		dlclose(handle);
++		ecdsa_sym = NULL;
++		rsa_sym = NULL;
++		univ_sym = NULL;
++		handle = NULL;
++	}
++
++	if (success)
++		verbose("Found matching %s key: %s", key_type(key), fp);
++
++	if (fp != NULL) {
++		free(fp);
++		fp = NULL;
++	}
++
++	return success;
++}
++
+ /*
+  * Check whether key authenticates and authorises the user.
+  */
+@@ -1048,6 +1183,10 @@ user_key_allowed(struct passwd *pw, Key *key, int auth_attempt)
+ 	if (success)
+ 		return success;
+ 
++	success = user_key_allowed_from_plugin(pw, key);
++	if (success > 0)
++		return success;
++
+ 	success = user_key_command_allowed2(pw, key);
+ 	if (success > 0)
+ 		return success;
+diff --git a/servconf.c b/servconf.c
+index 53146af..dca59fd 100644
+--- a/servconf.c
++++ b/servconf.c
+@@ -182,6 +182,7 @@ initialize_server_options(ServerOptions *options)
+ 	 */
+ 	options->pam_service_per_authmethod = 1;
+ #endif
++	options->pubkey_plugin = NULL;
+ }
+ 
+ /* Returns 1 if a string option is unset or set to "none" or 0 otherwise. */
+@@ -465,6 +466,7 @@ typedef enum {
+ 	sAuthenticationMethods, sHostKeyAgent, sPermitUserRC,
+ 	sStreamLocalBindMask, sStreamLocalBindUnlink,
+ 	sAllowStreamLocalForwarding, sFingerprintHash,
++	sPubKeyPlugin,
+ 	sDeprecated, sUnsupported
+ } ServerOpCodes;
+ 
+@@ -640,6 +642,7 @@ static struct {
+ 	{ "streamlocalbindunlink", sStreamLocalBindUnlink, SSHCFG_ALL },
+ 	{ "allowstreamlocalforwarding", sAllowStreamLocalForwarding, SSHCFG_ALL },
+ 	{ "fingerprinthash", sFingerprintHash, SSHCFG_GLOBAL },
++	{ "pubkeyplugin", sPubKeyPlugin, SSHCFG_ALL },
+ 	{ NULL, sBadOption, 0 }
+ };
+ 
+@@ -1966,6 +1969,18 @@ process_server_config_line(ServerOptions *options, char *line,
+ 		}
+ 		break;
+ 
++	case sPubKeyPlugin:
++		/*
++		 * Can't use parse_filename, as we need to support plain
++		 * names which dlopen will find on our lib path.
++		 */
++		arg = strdelim(&cp);
++		if (!arg || *arg == '\0')
++			fatal("%s line %d: missing file name.",
++			    filename, linenum);
++		options->pubkey_plugin = xstrdup(arg);
++		break;
++
+ 	case sDeprecated:
+ 		logit("%s line %d: Deprecated option %s",
+ 		    filename, linenum, arg);
+diff --git a/servconf.h b/servconf.h
+index 2175645..80e152f 100644
+--- a/servconf.h
++++ b/servconf.h
+@@ -206,6 +206,7 @@ typedef struct {
+ #endif
+         
+ 	int	fingerprint_hash;
++	char   *pubkey_plugin;
+ }       ServerOptions;
+ 
+ /* Information about the incoming connection as used by Match */
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:02 2016
+++ new/build/openssh/patches/0022-Compatibility-fix-for-ListenAddress.patch	Wed Feb 10 16:25:02 2016
@@ -0,0 +1,43 @@
+From c7acfe5514af7151bb574eff62aa3d8997d51843 Mon Sep 17 00:00:00 2001
+From: Alex Wilson <alex.wilson@joyent.com>
+Date: Mon, 3 Aug 2015 17:27:41 -0700
+Subject: [PATCH 22/36] Compatibility fix for "ListenAddress ::"
+
+In SunSSH, a config that specifies only "ListenAddress ::" in
+fact will listen on both IPv4 and IPv6.
+---
+ servconf.c | 15 +++++++++++++--
+ 1 file changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/servconf.c b/servconf.c
+index dca59fd..a0edff2 100644
+--- a/servconf.c
++++ b/servconf.c
+@@ -762,11 +762,22 @@ process_queued_listen_addrs(ServerOptions *options)
+ 		options->address_family = AF_UNSPEC;
+ 
+ 	for (i = 0; i < options->num_queued_listens; i++) {
+-		add_listen_addr(options, options->queued_listen_addrs[i],
+-		    options->queued_listen_ports[i]);
++		/*
++		 * To retain backwards compat with SunSSH, convert any listener
++		 * on :: into a listener of unspecified AF (so it listens on
++		 * v4 too)
++		 */
++		if (strcmp(options->queued_listen_addrs[i], "::") == 0) {
++			add_listen_addr(options, NULL,
++			    options->queued_listen_ports[i]);
++		} else {
++			add_listen_addr(options, options->queued_listen_addrs[i],
++			    options->queued_listen_ports[i]);
++		}
+ 		free(options->queued_listen_addrs[i]);
+ 		options->queued_listen_addrs[i] = NULL;
+ 	}
++
+ 	free(options->queued_listen_addrs);
+ 	options->queued_listen_addrs = NULL;
+ 	free(options->queued_listen_ports);
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:02 2016
+++ new/build/openssh/patches/0023-Hack-around-umac_ctx-name-punning.patch	Wed Feb 10 16:25:02 2016
@@ -0,0 +1,35 @@
+From a568c15ab17ad86878c2260ff8d4f8f6c64924d5 Mon Sep 17 00:00:00 2001
+From: Alex Wilson <alex.wilson@joyent.com>
+Date: Wed, 5 Aug 2015 10:57:08 -0700
+Subject: [PATCH 23/36] Hack around umac_ctx name-punning
+
+OpenSSH builds the file umac.c twice, once as is, and once using
+the preprocessor to rename everything to umac128_*.
+
+Unfortunately, it does not rename the struct umac_ctx, which ends
+up being used by both .o files to talk about completely different
+structs (the preprocessor macros change its size).
+
+This only matters if you care about DWARF/CTF type information,
+which we do, so we add an extra -D to rename the struct in the
+second build of umac.c.
+---
+ Makefile.in | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/Makefile.in b/Makefile.in
+index 0148742..66c4585 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -228,7 +228,7 @@ umac128.o:	umac.c
+ 	$(CC) $(CFLAGS) $(CPPFLAGS) -o umac128.o -c $(srcdir)/umac.c \
+ 	    -DUMAC_OUTPUT_LEN=16 -Dumac_new=umac128_new \
+ 	    -Dumac_update=umac128_update -Dumac_final=umac128_final \
+-	    -Dumac_delete=umac128_delete
++	    -Dumac_delete=umac128_delete -Dumac_ctx=umac128_ctx
+ 
+ # dtrace sftp
+ sftp_provider.h: $(srcdir)/sftp_provider.d
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:02 2016
+++ new/build/openssh/patches/0024-Try-to-create-privsep-chroot-dir-if-it-doesn-t-exist.patch	Wed Feb 10 16:25:02 2016
@@ -0,0 +1,51 @@
+From 4358f75a31f2518fe6fa9e129e4bb23f1a3071b1 Mon Sep 17 00:00:00 2001
+From: Alex Wilson <alex.wilson@joyent.com>
+Date: Wed, 5 Aug 2015 12:25:15 -0700
+Subject: [PATCH 24/36] Try to create privsep chroot dir if it doesn't exist
+ yet
+
+---
+ sshd.c | 25 ++++++++++++++++++++++---
+ 1 file changed, 22 insertions(+), 3 deletions(-)
+
+diff --git a/sshd.c b/sshd.c
+index 6215b2c..f19b398 100644
+--- a/sshd.c
++++ b/sshd.c
+@@ -1917,11 +1917,30 @@ main(int ac, char **av)
+ 
+ 	if (use_privsep) {
+ 		struct stat st;
++		int rc;
+ 
+ 		if ((stat(_PATH_PRIVSEP_CHROOT_DIR, &st) == -1) ||
+-		    (S_ISDIR(st.st_mode) == 0))
+-			fatal("Missing privilege separation directory: %s",
+-			    _PATH_PRIVSEP_CHROOT_DIR);
++		    (S_ISDIR(st.st_mode) == 0)) {
++			rc = mkdir(_PATH_PRIVSEP_CHROOT_DIR, 0755);
++			if (rc == 0) {
++				/*
++				 * If mkdir works, try stat again, so the
++				 * permissions check below can work.
++				 */
++				rc = stat(_PATH_PRIVSEP_CHROOT_DIR, &st);
++				if (rc == 0 && S_ISDIR(st.st_mode) == 0) {
++					rc = -1;
++					errno = ENOTDIR;
++				}
++			}
++
++			if (rc != 0) {
++				fatal("Failed to create privilege separation "
++				    "directory %s: %s",
++				    _PATH_PRIVSEP_CHROOT_DIR,
++				    strerror(errno));
++			}
++		}
+ 
+ #ifdef HAVE_CYGWIN
+ 		if (check_ntsec(_PATH_PRIVSEP_CHROOT_DIR) &&
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:02 2016
+++ new/build/openssh/patches/0025-Add-SMF-manifest-and-method-and-install-them.patch	Wed Feb 10 16:25:02 2016
@@ -0,0 +1,344 @@
+From 06a23d2cea6e57cca82c47e14a7b6d038b8e4286 Mon Sep 17 00:00:00 2001
+From: Alex Wilson <alex.wilson@joyent.com>
+Date: Fri, 7 Aug 2015 12:19:47 -0700
+Subject: [PATCH 25/36] Add SMF manifest and method, and install them
+
+---
+ Makefile.in      |   6 ++
+ smf/manifest.xml | 169 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ smf/method.sh    | 121 +++++++++++++++++++++++++++++++++++++++
+ 3 files changed, 296 insertions(+)
+ create mode 100644 smf/manifest.xml
+ create mode 100644 smf/method.sh
+
+diff --git a/Makefile.in b/Makefile.in
+index 66c4585..7130542 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -27,6 +27,8 @@ SFTP_SERVER=$(libexecdir)/sftp-server
+ SSH_KEYSIGN=$(libexecdir)/ssh-keysign
+ SSH_PKCS11_HELPER=$(libexecdir)/ssh-pkcs11-helper
+ ROOTDLIBDIR64=$(DESTDIR)/usr/lib/dtrace/64
++SMFMETHODDIR=$(DESTDIR)/lib/svc/method
++SMFNETMANIDIR=$(DESTDIR)/lib/svc/manifest/network
+ PRIVSEP_PATH=@PRIVSEP_PATH@
+ SSH_PRIVSEP_USER=@SSH_PRIVSEP_USER@
+ STRIP_OPT=@STRIP_OPT@
+@@ -359,6 +361,10 @@ install-files:
+ 	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/slogin.1
+ 	ln -s ./ssh.1 $(DESTDIR)$(mandir)/$(mansubdir)1/slogin.1
+ 	mkdir -p $(ROOTDLIBDIR64) && cp $(srcdir)/sftp64.d $(ROOTDLIBDIR64)/sftp64.d
++	$(srcdir)/mkinstalldirs $(SMFMETHODDIR)
++	$(srcdir)/mkinstalldirs $(SMFNETMANIDIR)
++	$(INSTALL) -m 555 smf/method.sh $(SMFMETHODDIR)/sshd
++	$(INSTALL) -m 444 smf/manifest.xml $(SMFNETMANIDIR)/ssh.xml
+ 
+ install-sysconf:
+ 	if [ ! -d $(DESTDIR)$(sysconfdir) ]; then \
+diff --git a/smf/manifest.xml b/smf/manifest.xml
+new file mode 100644
+index 0000000..5045296
+--- /dev/null
++++ b/smf/manifest.xml
+@@ -0,0 +1,169 @@
++<?xml version="1.0"?>
++<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
++<!--
++	CDDL HEADER START
++
++	The contents of this file are subject to the terms of the
++	Common Development and Distribution License (the "License").
++	You may not use this file except in compliance with the License.
++
++	You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
++	or http://www.opensolaris.org/os/licensing.
++	See the License for the specific language governing permissions
++	and limitations under the License.
++
++	When distributing Covered Code, include this CDDL HEADER in each
++	file and include the License file at usr/src/OPENSOLARIS.LICENSE.
++	If applicable, add the following below this CDDL HEADER, with the
++	fields enclosed by brackets "[]" replaced with your own identifying
++	information: Portions Copyright [yyyy] [name of copyright owner]
++
++	CDDL HEADER END
++
++	Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
++	Use is subject to license terms.
++
++	NOTE:  This service manifest is not editable; its contents will
++	be overwritten by package or patch operations, including
++	operating system upgrade.  Make customizations in a different
++	file.
++-->
++
++<service_bundle type='manifest' name='SUNWsshdr:ssh'>
++
++<service
++	name='network/ssh'
++	type='service'
++	version='1'>
++
++	<create_default_instance enabled='false' />
++
++	<single_instance />
++
++	<dependency name='fs-local'
++		grouping='require_all'
++		restart_on='none'
++		type='service'>
++		<service_fmri
++			value='svc:/system/filesystem/local' />
++	</dependency>
++
++	<dependency name='fs-autofs'
++		grouping='optional_all'
++		restart_on='none'
++		type='service'>
++		<service_fmri value='svc:/system/filesystem/autofs' />
++	</dependency>
++
++	<dependency name='net-loopback'
++		grouping='require_all'
++		restart_on='none'
++		type='service'>
++		<service_fmri value='svc:/network/loopback' />
++	</dependency>
++
++	<dependency name='net-physical'
++		grouping='require_all'
++		restart_on='none'
++		type='service'>
++		<service_fmri value='svc:/network/physical' />
++	</dependency>
++
++	<dependency name='cryptosvc'
++		grouping='require_all'
++		restart_on='none'
++		type='service'>
++		<service_fmri value='svc:/system/cryptosvc' />
++	</dependency>
++
++	<dependency name='utmp'
++		grouping='require_all'
++		restart_on='none'
++		type='service'>
++		<service_fmri value='svc:/system/utmp' />
++	</dependency>
++
++	<dependency name='network_ipfilter'
++		grouping='optional_all'
++		restart_on='error'
++		type='service'>
++		<service_fmri value='svc:/network/ipfilter:default' />
++	</dependency>
++
++	<dependency name='config_data'
++		grouping='require_all'
++		restart_on='restart'
++		type='path'>
++		<service_fmri
++		    value='file://localhost/etc/ssh/sshd_config' />
++	</dependency>
++
++	<dependent
++		name='ssh_multi-user-server'
++		grouping='optional_all'
++		restart_on='none'>
++			<service_fmri
++			    value='svc:/milestone/multi-user-server' />
++	</dependent>
++
++	<exec_method
++		type='method'
++		name='start'
++		exec='/lib/svc/method/sshd start'
++		timeout_seconds='60'/>
++
++	<exec_method
++		type='method'
++		name='stop'
++		exec=':kill'
++		timeout_seconds='60' />
++
++	<exec_method
++		type='method'
++		name='refresh'
++		exec='/lib/svc/method/sshd restart'
++		timeout_seconds='60' />
++
++	<property_group name='startd'
++		type='framework'>
++		<!-- sub-process core dumps shouldn't restart session -->
++		<propval name='ignore_error'
++		    type='astring' value='core,signal' />
++	</property_group>
++
++        <property_group name='general' type='framework'>
++                <!-- to start stop sshd -->
++                <propval name='action_authorization' type='astring'
++                        value='solaris.smf.manage.ssh' />
++        </property_group>
++
++	<property_group name='firewall_context' type='com.sun,fw_definition'>
++		<propval name='name' type='astring' value='ssh' />
++		<propval name='ipf_method' type='astring'
++		    value='/lib/svc/method/sshd ipfilter' />
++	</property_group>
++
++	<property_group name='firewall_config' type='com.sun,fw_configuration'>
++		<propval name='policy' type='astring' value='use_global' />
++		<propval name='apply_to' type='astring' value='' />
++		<propval name='exceptions' type='astring' value='' />
++		<propval name='value_authorization' type='astring'
++			value='solaris.smf.value.firewall.config' />
++	</property_group>
++
++	<stability value='Unstable' />
++
++	<template>
++		<common_name>
++			<loctext xml:lang='C'>
++			SSH server
++			</loctext>
++		</common_name>
++		<documentation>
++			<manpage title='sshd' section='1M' manpath='/usr/share/man' />
++		</documentation>
++	</template>
++
++</service>
++
++</service_bundle>
+\ No newline at end of file
+diff --git a/smf/method.sh b/smf/method.sh
+new file mode 100644
+index 0000000..e91ed55
+--- /dev/null
++++ b/smf/method.sh
+@@ -0,0 +1,121 @@
++#!/sbin/sh
++#
++# Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
++# Use is subject to license terms.
++#
++
++. /lib/svc/share/ipf_include.sh
++. /lib/svc/share/smf_include.sh
++
++SSHDIR=/etc/ssh
++SSHKEYDIR=/var/ssh
++KEYGEN="/usr/bin/ssh-keygen -q"
++PIDFILE=/var/run/sshd.pid
++
++# Checks to see if RSA, and DSA host keys are available
++# if any of these keys are not present, the respective keys are created.
++create_key()
++{
++	keypath=$1
++	keytype=$2
++
++	if [ ! -f $keypath ]; then
++		#
++		# HostKey keywords in sshd_config may be preceded or
++		# followed by a mix of any number of space or tabs,
++		# and optionally have an = between keyword and
++		# argument.  We use two grep invocations such that we
++		# can match HostKey case insensitively but still have
++		# the case of the path name be significant, keeping
++		# the pattern somewhat more readable.
++		#
++		# The character classes below contain one literal
++		# space and one literal tab.
++		#
++		grep -i "^[ 	]*HostKey[ 	]*=\{0,1\}[ 	]*$keypath" \
++		    $SSHDIR/sshd_config | grep "$keypath" > /dev/null 2>&1
++
++		if [ $? -eq 0 ]; then
++			echo Creating new $keytype public/private host key pair
++			$KEYGEN -f $keypath -t $keytype -N ''
++			if [ $? -ne 0 ]; then
++				echo "Could not create $keytype key: $keypath"
++				exit $SMF_EXIT_ERR_CONFIG
++			fi
++		fi
++	fi
++}
++
++create_ipf_rules()
++{
++	FMRI=$1
++	ipf_file=`fmri_to_file ${FMRI} $IPF_SUFFIX`
++	policy=`get_policy ${FMRI}`
++
++	#
++	# Get port from /etc/ssh/sshd_config
++	#
++	tports=`grep "^Port" /etc/ssh/sshd_config 2>/dev/null | \
++	    awk '{print $2}'`
++
++	echo "# $FMRI" >$ipf_file
++	for port in $tports; do
++		generate_rules $FMRI $policy "tcp" "any" $port $ipf_file
++	done
++}
++
++# This script is being used for two purposes: as part of an SMF
++# start/stop/refresh method, and as a sysidconfig(1M)/sys-unconfig(1M)
++# application.
++#
++# Both, the SMF methods and sysidconfig/sys-unconfig use different
++# arguments..
++
++case $1 in
++	# sysidconfig/sys-unconfig arguments (-c and -u)
++'-c')
++	create_key $SSHDIR/ssh_host_rsa_key rsa
++	create_key $SSHDIR/ssh_host_dsa_key dsa
++	create_key $SSHDIR/ssh_host_ecdsa_key ecdsa
++	create_key $SSHDIR/ssh_host_ed25519_key ed25519
++	;;
++
++'-u')
++	# sys-unconfig(1M) knows how to remove ssh host keys, so there's
++	# nothing to do here.
++	:
++	;;
++
++	# SMF arguments (start and restart [really "refresh"])
++
++'ipfilter')
++	create_ipf_rules $2
++	;;
++
++'start')
++	#
++	# If host keys don't exist when the service is started, create
++	# them; sysidconfig is not run in every situation (such as on
++	# the install media).
++	#
++	create_key $SSHKEYDIR/ssh_host_rsa_key rsa
++	create_key $SSHKEYDIR/ssh_host_dsa_key dsa
++	create_key $SSHKEYDIR/ssh_host_ecdsa_key ecdsa
++	create_key $SSHKEYDIR/ssh_host_ed25519_key ed25519
++
++	/usr/lib/ssh/sshd
++	;;
++
++'restart')
++	if [ -f "$PIDFILE" ]; then
++		/usr/bin/kill -HUP `/usr/bin/cat $PIDFILE`
++	fi
++	;;
++
++*)
++	echo "Usage: $0 { start | restart }"
++	exit 1
++	;;
++esac
++
++exit $?
+\ No newline at end of file
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:02 2016
+++ new/build/openssh/patches/0027-Add-with-key-dir-configure-option-to-place-SSH-host-.patch	Wed Feb 10 16:25:02 2016
@@ -0,0 +1,126 @@
+From 977c5b82db3659f87ef74094bb68782035fdcf17 Mon Sep 17 00:00:00 2001
+From: Alex Wilson <alex.wilson@joyent.com>
+Date: Fri, 7 Aug 2015 13:32:53 -0700
+Subject: [PATCH 27/36] Add --with-key-dir configure option to place SSH host
+ keys
+
+---
+ Makefile.in  | 12 +++++++-----
+ configure.ac | 16 ++++++++++++++++
+ pathnames.h  | 16 ++++++++++------
+ 3 files changed, 33 insertions(+), 11 deletions(-)
+
+diff --git a/Makefile.in b/Makefile.in
+index 7130542..5e05771 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -18,6 +18,7 @@ sysconfdir=@sysconfdir@
+ piddir=@piddir@
+ srcdir=@srcdir@
+ top_srcdir=@top_srcdir@
++keydir=@keydir@
+ 
+ DESTDIR=
+ VPATH=@srcdir@
+@@ -132,11 +133,11 @@ PATHSUBS	= \
+ 	-e 's|/etc/ssh/sshd_config|$(sysconfdir)/sshd_config|g' \
+ 	-e 's|/usr/libexec|$(libexecdir)|g' \
+ 	-e 's|/etc/shosts.equiv|$(sysconfdir)/shosts.equiv|g' \
+-	-e 's|/etc/ssh/ssh_host_key|$(sysconfdir)/ssh_host_key|g' \
+-	-e 's|/etc/ssh/ssh_host_ecdsa_key|$(sysconfdir)/ssh_host_ecdsa_key|g' \
+-	-e 's|/etc/ssh/ssh_host_dsa_key|$(sysconfdir)/ssh_host_dsa_key|g' \
+-	-e 's|/etc/ssh/ssh_host_rsa_key|$(sysconfdir)/ssh_host_rsa_key|g' \
+-	-e 's|/etc/ssh/ssh_host_ed25519_key|$(sysconfdir)/ssh_host_ed25519_key|g' \
++	-e 's|/etc/ssh/ssh_host_key|$(keydir)/ssh_host_key|g' \
++	-e 's|/etc/ssh/ssh_host_ecdsa_key|$(keydir)/ssh_host_ecdsa_key|g' \
++	-e 's|/etc/ssh/ssh_host_dsa_key|$(keydir)/ssh_host_dsa_key|g' \
++	-e 's|/etc/ssh/ssh_host_rsa_key|$(keydir)/ssh_host_rsa_key|g' \
++	-e 's|/etc/ssh/ssh_host_ed25519_key|$(keydir)/ssh_host_ed25519_key|g' \
+ 	-e 's|/var/run/sshd.pid|$(piddir)/sshd.pid|g' \
+ 	-e 's|/etc/moduli|$(sysconfdir)/moduli|g' \
+ 	-e 's|/etc/ssh/moduli|$(sysconfdir)/moduli|g' \
+@@ -365,6 +366,7 @@ install-files:
+ 	$(srcdir)/mkinstalldirs $(SMFNETMANIDIR)
+ 	$(INSTALL) -m 555 smf/method.sh $(SMFMETHODDIR)/sshd
+ 	$(INSTALL) -m 444 smf/manifest.xml $(SMFNETMANIDIR)/ssh.xml
++	mkdir -p $(DESTDIR)$(keydir)
+ 
+ install-sysconf:
+ 	if [ ! -d $(DESTDIR)$(sysconfdir) ]; then \
+diff --git a/configure.ac b/configure.ac
+index b38b1b3..8c0abd6 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -4638,6 +4638,20 @@ AC_DEFINE_UNQUOTED([_PATH_SSH_PIDDIR], ["$piddir"],
+ 	[Specify location of ssh.pid])
+ AC_SUBST([piddir])
+ 
++keydir=$sysconfdir
++AC_ARG_WITH([key-dir],
++	[  --with-key-dir=PATH      Specify location of SSH host keys],
++	[
++		if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
++		    test "x${withval}" != "xyes"; then
++			keydir=$withval
++		fi
++	]
++)
++AC_DEFINE_UNQUOTED([SSHKEYDIR], ["$keydir"],
++	[Specify location of SSH host keys])
++AC_SUBST([keydir])
++
+ dnl allow user to disable some login recording features
+ AC_ARG_ENABLE([lastlog],
+ 	[  --disable-lastlog       disable use of lastlog even if detected [no]],
+@@ -4942,12 +4956,14 @@ G=`eval echo ${piddir}` ; G=`eval echo ${G}`
+ H=`eval echo ${PRIVSEP_PATH}` ; H=`eval echo ${H}`
+ I=`eval echo ${user_path}` ; I=`eval echo ${I}`
+ J=`eval echo ${superuser_path}` ; J=`eval echo ${J}`
++K=`eval echo ${keydir}` ; K=`eval echo ${K}`
+ 
+ echo ""
+ echo "OpenSSH has been configured with the following options:"
+ echo "                     User binaries: $B"
+ echo "                   System binaries: $C"
+ echo "               Configuration files: $D"
++echo "                   Keys and moduli: $K"
+ echo "                   Askpass program: $E"
+ echo "                      Manual pages: $F"
+ echo "                          PID file: $G"
+diff --git a/pathnames.h b/pathnames.h
+index ec89fc6..0b2281b 100644
+--- a/pathnames.h
++++ b/pathnames.h
+@@ -22,6 +22,10 @@
+ #define _PATH_SSH_PIDDIR		"/var/run"
+ #endif
+ 
++#ifndef SSHKEYDIR
++#define SSHKEYDIR			SSHDIR
++#endif
++
+ /*
+  * System-wide file containing host keys of known hosts.  This file should be
+  * world-readable.
+@@ -36,12 +40,12 @@
+  */
+ #define _PATH_SERVER_CONFIG_FILE	SSHDIR "/sshd_config"
+ #define _PATH_HOST_CONFIG_FILE		SSHDIR "/ssh_config"
+-#define _PATH_HOST_KEY_FILE		SSHDIR "/ssh_host_key"
+-#define _PATH_HOST_DSA_KEY_FILE		SSHDIR "/ssh_host_dsa_key"
+-#define _PATH_HOST_ECDSA_KEY_FILE	SSHDIR "/ssh_host_ecdsa_key"
+-#define _PATH_HOST_ED25519_KEY_FILE	SSHDIR "/ssh_host_ed25519_key"
+-#define _PATH_HOST_RSA_KEY_FILE		SSHDIR "/ssh_host_rsa_key"
+-#define _PATH_DH_MODULI			SSHDIR "/moduli"
++#define _PATH_HOST_KEY_FILE		SSHKEYDIR "/ssh_host_key"
++#define _PATH_HOST_DSA_KEY_FILE		SSHKEYDIR "/ssh_host_dsa_key"
++#define _PATH_HOST_ECDSA_KEY_FILE	SSHKEYDIR "/ssh_host_ecdsa_key"
++#define _PATH_HOST_ED25519_KEY_FILE	SSHKEYDIR "/ssh_host_ed25519_key"
++#define _PATH_HOST_RSA_KEY_FILE		SSHKEYDIR "/ssh_host_rsa_key"
++#define _PATH_DH_MODULI			SSHKEYDIR "/moduli"
+ /* Backwards compatibility */
+ #define _PATH_DH_PRIMES			SSHDIR "/primes"
+ 
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:02 2016
+++ new/build/openssh/patches/0028-Re-enable-DSA-keys-for-pk-auth.patch	Wed Feb 10 16:25:02 2016
@@ -0,0 +1,61 @@
+From 58d5723e03a5a582c2d1486719f9753aa969b244 Mon Sep 17 00:00:00 2001
+From: Alex Wilson <alex.wilson@joyent.com>
+Date: Wed, 19 Aug 2015 11:35:32 -0700
+Subject: [PATCH 28/36] Re-enable DSA keys for pk auth
+
+---
+ myproposal.h  | 4 +++-
+ ssh_config.4  | 3 ++-
+ sshd_config.4 | 3 ++-
+ 3 files changed, 7 insertions(+), 3 deletions(-)
+
+diff --git a/myproposal.h b/myproposal.h
+index 46e5b98..5041361 100644
+--- a/myproposal.h
++++ b/myproposal.h
+@@ -99,9 +99,11 @@
+ 	HOSTKEY_ECDSA_CERT_METHODS \
+ 	"ssh-ed25519-cert-v01@openssh.com," \
+ 	"ssh-rsa-cert-v01@openssh.com," \
++	"ssh-dss-cert-v01@openssh.com," \
+ 	HOSTKEY_ECDSA_METHODS \
+ 	"ssh-ed25519," \
+-	"ssh-rsa" \
++	"ssh-rsa," \
++	"ssh-dss" \
+ 
+ /* the actual algorithms */
+ 
+diff --git a/ssh_config.4 b/ssh_config.4
+index 016adda..1d26140 100644
+--- a/ssh_config.4
++++ b/ssh_config.4
+@@ -1264,8 +1264,9 @@ ecdsa-sha2-nistp384-cert-v01@openssh.com,
+ ecdsa-sha2-nistp521-cert-v01@openssh.com,
+ ssh-ed25519-cert-v01@openssh.com,
+ ssh-rsa-cert-v01@openssh.com,
++ssh-dss-cert-v01@openssh.com,
+ ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
+-ssh-ed25519,ssh-rsa
++ssh-ed25519,ssh-rsa,ssh-dss
+ .Ed
+ .Pp
+ The
+diff --git a/sshd_config.4 b/sshd_config.4
+index bd70a68..0c07fd1 100644
+--- a/sshd_config.4
++++ b/sshd_config.4
+@@ -1366,8 +1366,9 @@ ecdsa-sha2-nistp384-cert-v01@openssh.com,
+ ecdsa-sha2-nistp521-cert-v01@openssh.com,
+ ssh-ed25519-cert-v01@openssh.com,
+ ssh-rsa-cert-v01@openssh.com,
++ssh-dss-cert-v01@openssh.com,
+ ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,
+-ssh-ed25519,ssh-rsa
++ssh-ed25519,ssh-rsa,ssh-dss
+ .Ed
+ .Pp
+ The
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:02 2016
+++ new/build/openssh/patches/0029-Don-t-use-krb5-config-to-check-for-GSSAPI-on-Illumos.patch	Wed Feb 10 16:25:02 2016
@@ -0,0 +1,37 @@
+From 2ddf64a6bfa74df030fa7b765c315377d9b5bc04 Mon Sep 17 00:00:00 2001
+From: Alex Wilson <alex.wilson@joyent.com>
+Date: Fri, 21 Aug 2015 18:47:46 -0700
+Subject: [PATCH 29/36] Don't use krb5-config to check for GSSAPI on Illumos
+
+---
+ configure.ac | 7 ++++++-
+ 1 file changed, 6 insertions(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index 8c0abd6..e251f9b 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -4064,6 +4064,11 @@ AC_ARG_WITH([kerberos5],
+ 		AC_PATH_PROG([KRB5CONF], [krb5-config],
+ 			     [$KRB5ROOT/bin/krb5-config],
+ 			     [$KRB5ROOT/bin:$PATH])
++		# Illumos has GSS but krb5-config doesn't talk about it
++		# Fall back to regular probing for libs
++		if uname -rs | grep 'SunOS 5.11' ; then
++			KRB5CONF=nonexistent
++		fi
+ 		if test -x $KRB5CONF ; then
+ 			K5CFLAGS="`$KRB5CONF --cflags`"
+ 			K5LIBS="`$KRB5CONF --libs`"
+@@ -4105,7 +4110,7 @@ AC_ARG_WITH([kerberos5],
+ 					 AC_CHECK_LIB([des], [des_cbc_encrypt],
+ 					   [K5LIBS="$K5LIBS -ldes"])
+ 				       ], [ AC_MSG_RESULT([no])
+-					 K5LIBS="-lkrb5 -lk5crypto -lcom_err"
++					 K5LIBS="-lkrb5"
+ 				       
+ 			])
+ 			AC_SEARCH_LIBS([dn_expand], [resolv])
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:02 2016
+++ new/build/openssh/patches/0030-Set-default-sshd-options-based-on-etc-default-login.patch	Wed Feb 10 16:25:02 2016
@@ -0,0 +1,147 @@
+From 4e36108ba3e42eb1c4d84b6e31d21a5ca77f33a1 Mon Sep 17 00:00:00 2001
+From: Alex Wilson <alex.wilson@joyent.com>
+Date: Mon, 24 Aug 2015 18:57:27 -0700
+Subject: [PATCH 30/36] Set default sshd options based on /etc/default/login
+
+---
+ pathnames.h   |  1 +
+ servconf.c    | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ sshd_config.4 | 17 +++++++++++++++--
+ 3 files changed, 77 insertions(+), 2 deletions(-)
+
+diff --git a/pathnames.h b/pathnames.h
+index 0b2281b..11c9bf6 100644
+--- a/pathnames.h
++++ b/pathnames.h
+@@ -46,6 +46,7 @@
+ #define _PATH_HOST_ED25519_KEY_FILE	SSHKEYDIR "/ssh_host_ed25519_key"
+ #define _PATH_HOST_RSA_KEY_FILE		SSHKEYDIR "/ssh_host_rsa_key"
+ #define _PATH_DH_MODULI			SSHKEYDIR "/moduli"
++#define _PATH_DEFAULT_LOGIN		ETCDIR "/default/login"
+ /* Backwards compatibility */
+ #define _PATH_DH_PRIMES			SSHDIR "/primes"
+ 
+diff --git a/servconf.c b/servconf.c
+index a0edff2..f8122aa 100644
+--- a/servconf.c
++++ b/servconf.c
+@@ -30,6 +30,7 @@
+ #include <unistd.h>
+ #include <limits.h>
+ #include <stdarg.h>
++#include <deflt.h>
+ #include <errno.h>
+ #ifdef HAVE_UTIL_H
+ #include <util.h>
+@@ -192,6 +193,64 @@ option_clear_or_none(const char *o)
+ 	return o == NULL || strcasecmp(o, "none") == 0;
+ }
+ 
++/*
++ * Reads /etc/default/login and defaults several ServerOptions:
++ *
++ * PermitRootLogin
++ * PermitEmptyPasswords
++ * LoginGraceTime
++ *
++ * CONSOLE=*      -> PermitRootLogin=without-password
++ * #CONSOLE=*     -> PermitRootLogin=yes
++ *
++ * PASSREQ=YES    -> PermitEmptyPasswords=no
++ * PASSREQ=NO     -> PermitEmptyPasswords=yes
++ * #PASSREQ=*     -> PermitEmptyPasswords=no
++ *
++ * TIMEOUT=<secs> -> LoginGraceTime=<secs>
++ * #TIMEOUT=<secs> -> LoginGraceTime=300
++ */
++static void
++deflt_fill_default_server_options(ServerOptions *options)
++{
++	int	flags;
++	char	*ptr;
++
++	if (defopen(_PATH_DEFAULT_LOGIN))
++		return;
++
++	/* Ignore case */
++	flags = defcntl(DC_GETFLAGS, 0);
++	TURNOFF(flags, DC_CASE);
++	(void) defcntl(DC_SETFLAGS, flags);
++
++	if (options->permit_root_login == PERMIT_NOT_SET &&
++	    (ptr = defread("CONSOLE=")) != NULL)
++		options->permit_root_login = PERMIT_NO_PASSWD;
++
++	if (options->permit_empty_passwd == -1 &&
++	    (ptr = defread("PASSREQ=")) != NULL) {
++		if (strcasecmp("YES", ptr) == 0)
++			options->permit_empty_passwd = 0;
++		else if (strcasecmp("NO", ptr) == 0)
++			options->permit_empty_passwd = 1;
++	}
++
++	if (options->max_authtries == -1 &&
++	    (ptr = defread("RETRIES=")) != NULL) {
++		options->max_authtries = atoi(ptr);
++	}
++
++	if (options->login_grace_time == -1) {
++		if ((ptr = defread("TIMEOUT=")) != NULL)
++			options->login_grace_time = (unsigned)atoi(ptr);
++		else
++			options->login_grace_time = 300;
++	}
++
++	(void) defopen((char *)NULL);
++}
++
+ void
+ fill_default_server_options(ServerOptions *options)
+ {
+@@ -206,6 +265,8 @@ fill_default_server_options(ServerOptions *options)
+ 		options->use_pam = 0;
+ #endif
+ 
++	deflt_fill_default_server_options(options);
++
+ 	/* Standard Options */
+ 	if (options->protocol == SSH_PROTO_UNKNOWN)
+ 		options->protocol = SSH_PROTO_2;
+diff --git a/sshd_config.4 b/sshd_config.4
+index 0c07fd1..cce3a5a 100644
+--- a/sshd_config.4
++++ b/sshd_config.4
+@@ -1138,7 +1138,13 @@ Specifies the maximum number of authentication attempts permitted per
+ connection.
+ Once the number of failures reaches half this value,
+ additional failures are logged.
+-The default is 6.
++The default is 6, or the value given by
++.Dq RETRIES=
++in the file
++.Dq /etc/default/login ,
++if available (see
++.Xr login 1
++).
+ .It Cm MaxSessions
+ Specifies the maximum number of open sessions permitted per network connection.
+ The default is 10.
+@@ -1189,7 +1195,14 @@ The default is
+ When password authentication is allowed, it specifies whether the
+ server allows login to accounts with empty password strings.
+ The default is
+-.Dq no .
++.Dq no
++unless
++.Dq PASSREQ=YES
++is present in
++.Dq /etc/default/login
++(see
++.Xr login 1
++).
+ .It Cm PermitOpen
+ Specifies the destinations to which TCP port forwarding is permitted.
+ The forwarding specification must be one of the following forms:
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:02 2016
+++ new/build/openssh/patches/0031-Compatibility-for-SunSSH_1.5-should-include-old-DH-K.patch	Wed Feb 10 16:25:02 2016
@@ -0,0 +1,75 @@
+From c71eccaac0cba458050a78e850522761c45e424f Mon Sep 17 00:00:00 2001
+From: Alex Wilson <alex.wilson@joyent.com>
+Date: Fri, 4 Sep 2015 10:38:28 -0700
+Subject: [PATCH 31/36] Compatibility for SunSSH_1.5* should include old DH KEx
+ algos
+
+We use the kex compat mechanism here to recognise old SunSSH
+versions and present a kex proposal that always includes the
+dh-group14 and -group1 algorithms.
+
+Without this, an old SunSSH client cannot connect to our
+new daemon.
+---
+ compat.c | 31 ++++++++++++++++++++++++++++++-
+ 1 file changed, 30 insertions(+), 1 deletion(-)
+
+diff --git a/compat.c b/compat.c
+index 5583804..e2bebee 100644
+--- a/compat.c
++++ b/compat.c
+@@ -92,7 +92,9 @@ compat_datafellows(const char *version)
+ 		  "OpenSSH_3.0*,"
+ 		  "OpenSSH_3.1*",	SSH_BUG_EXTEOF|SSH_OLD_FORWARD_ADDR},
+ 		{ "OpenSSH_3.*",	SSH_OLD_FORWARD_ADDR },
+-		{ "Sun_SSH_1.0*",	SSH_BUG_NOREKEY|SSH_BUG_EXTEOF},
++		{ "Sun_SSH_1.0*",	SSH_BUG_NOREKEY|SSH_BUG_EXTEOF|
++					SSH_OLD_DHGEX},
++		{ "Sun_SSH_1.5*",	SSH_OLD_DHGEX},
+ 		{ "OpenSSH_4*",		0 },
+ 		{ "OpenSSH_5*",		SSH_NEW_OPENSSH|SSH_BUG_DYNAMIC_RPORT},
+ 		{ "OpenSSH_6.6.1*",	SSH_NEW_OPENSSH},
+@@ -279,6 +281,31 @@ filter_proposal(char *proposal, const char *filter)
+ 	return fix_prop;
+ }
+ 
++/*
++ * Adds an algorithm to the end of a proposal list, only if the algorithm is
++ * not already present.
++ */
++static char *
++append_proposal(char *proposal, const char *append)
++{
++	Buffer b;
++	char *fix_prop;
++
++	if (strstr(proposal, append) != NULL)
++		return proposal;
++
++	buffer_init(&b);
++	buffer_append(&b, proposal, strlen(proposal));
++	if (buffer_len(&b) > 0)
++		buffer_append(&b, ",", 1);
++	buffer_append(&b, append, strlen(append));
++	buffer_append(&b, "\0", 1);
++	fix_prop = xstrdup((char *)buffer_ptr(&b));
++	buffer_free(&b);
++
++	return fix_prop;
++}
++
+ char *
+ compat_cipher_proposal(char *cipher_prop)
+ {
+@@ -316,6 +343,8 @@ compat_kex_proposal(char *p)
+ 	if ((datafellows & SSH_OLD_DHGEX) != 0) {
+ 		p = filter_proposal(p, "diffie-hellman-group-exchange-sha256");
+ 		p = filter_proposal(p, "diffie-hellman-group-exchange-sha1");
++		p = append_proposal(p, "diffie-hellman-group14-sha1");
++		p = append_proposal(p, "diffie-hellman-group1-sha1");
+ 	}
+ 	debug2("%s: compat KEX proposal: %s", __func__, p);
+ 	if (*p == '\0')
+-- 
+2.5.4 (Apple Git-61)
+
--- old/build/openssh/patches/0032-Accept-LANG-and-LC_-environment-variables-from-clien.patch	Wed Feb 10 16:25:02 2016
+++ new/build/openssh/patches/0032-Accept-LANG-and-LC_-environment-variables-from-clien.patch	Wed Feb 10 16:25:02 2016
@@ -1,8 +1,8 @@
-From e47c600f563b6acdcfc5c5fb5751d85335f2225a Mon Sep 17 00:00:00 2001
+From 71b520b3fdbd211fc92f455903a3c218250f44b8 Mon Sep 17 00:00:00 2001
 From: Alex Wilson <alex.wilson@joyent.com>
 Date: Fri, 4 Sep 2015 11:04:30 -0700
-Subject: [PATCH] Accept LANG and LC_* environment variables from clients by
- default
+Subject: [PATCH 32/36] Accept LANG and LC_* environment variables from clients
+ by default
 
 This preserves most of the old SunSSH locale negotiation
 behaviour (at least the parts that are most commonly used).
@@ -78,10 +78,10 @@
  			dst->n[dst->num_n] = xstrdup(src->n[dst->num_n]); \
  	} \
 diff --git a/session.c b/session.c
-index 5a64715..57f179d 100644
+index ab0ac1c..88cd9f0 100644
 --- a/session.c
 +++ b/session.c
-@@ -1010,6 +1010,18 @@ child_set_env(char ***envp, u_int *envsizep, const char *name,
+@@ -1019,6 +1019,18 @@ child_set_env(char ***envp, u_int *envsizep, const char *name,
  }
  
  /*
@@ -100,7 +100,7 @@
   * Reads environment variables from the given file and adds/overrides them
   * into the environment.  If the file does not exist, this does nothing.
   * Otherwise, it must consist of empty lines, comments (line starts with '#')
-@@ -1171,6 +1183,16 @@ do_setup_env(Session *s, const char *shell)
+@@ -1180,6 +1192,16 @@ do_setup_env(Session *s, const char *shell)
  	ssh_gssapi_do_child(&env, &envsize);
  #endif
  
@@ -117,7 +117,7 @@
  	if (!options.use_login) {
  		/* Set basic environment. */
  		for (i = 0; i < s->num_env; i++)
-@@ -1215,8 +1237,8 @@ do_setup_env(Session *s, const char *shell)
+@@ -1224,8 +1246,8 @@ do_setup_env(Session *s, const char *shell)
  		/* Normal systems set SHELL by default. */
  		child_set_env(&env, &envsize, "SHELL", shell);
  	}
@@ -126,8 +126,8 @@
 +
 +	child_inherit_env(&env, &envsize, "TZ");
  
- 	/* Set custom environment options from RSA authentication. */
- 	if (!options.use_login) {
+ #ifdef PER_SESSION_XAUTHFILE
+         if (s->auth_file != NULL)
 diff --git a/sshd_config b/sshd_config
 index 0048f98..bbdc6ae 100644
 --- a/sshd_config
@@ -168,5 +168,5 @@
  Specifies which address family should be used by
  .Xr sshd 1M .
 -- 
-2.3.2 (Apple Git-55)
+2.5.4 (Apple Git-61)
 
--- /dev/null	Wed Feb 10 16:25:02 2016
+++ new/build/openssh/patches/0033-Temporarily-set-ssh-keygen-and-ssh-add-to-old-FP-for.patch	Wed Feb 10 16:25:02 2016
@@ -0,0 +1,146 @@
+From 59c773c11e5c0bf249e270fc4658513834a754e1 Mon Sep 17 00:00:00 2001
+From: Alex Wilson <alex.wilson@joyent.com>
+Date: Wed, 9 Sep 2015 10:36:05 -0700
+Subject: [PATCH 33/36] Temporarily set ssh-keygen and ssh-add to old FP format
+
+SDC and its users have a lot of scripts that expect ssh-add
+and ssh-keygen to return fingerprints in the old format.
+As a temporary measure, make us default to producing this
+same output until we have migrated everything over.
+---
+ ssh-add.c    | 13 +++++++++++--
+ ssh-keygen.c | 21 ++++++++++++++++++---
+ 2 files changed, 29 insertions(+), 5 deletions(-)
+
+diff --git a/ssh-add.c b/ssh-add.c
+index d6271d7..2eb723f 100644
+--- a/ssh-add.c
++++ b/ssh-add.c
+@@ -52,6 +52,7 @@
+ #include <string.h>
+ #include <unistd.h>
+ #include <limits.h>
++#include <assert.h>
+ 
+ #include "xmalloc.h"
+ #include "ssh.h"
+@@ -85,7 +86,8 @@ static char *default_files[] = {
+ 	NULL
+ };
+ 
+-static int fingerprint_hash = SSH_FP_HASH_DEFAULT;
++static int fingerprint_hash = SSH_DIGEST_MD5;
++static int fingerprint_compat = 1;
+ 
+ /* Default lifetime (0 == forever) */
+ static int lifetime = 0;
+@@ -364,6 +366,7 @@ static int
+ list_identities(int agent_fd, int do_fp)
+ {
+ 	char *fp;
++	char *fpp;
+ 	int r, had_identities = 0;
+ 	struct ssh_identitylist *idlist;
+ 	size_t i;
+@@ -386,9 +389,14 @@ list_identities(int agent_fd, int do_fp)
+ 			if (do_fp) {
+ 				fp = sshkey_fingerprint(idlist->keys[i],
+ 				    fingerprint_hash, SSH_FP_DEFAULT);
++				fpp = fp;
++				if (fingerprint_compat == 1) {
++					assert(strncmp(fp, "MD5:", 4) == 0);
++					fpp += 4;
++				}
+ 				printf("%d %s %s (%s)\n",
+ 				    sshkey_size(idlist->keys[i]),
+-				    fp == NULL ? "(null)" : fp,
++				    fp == NULL ? "(null)" : fpp,
+ 				    idlist->comments[i],
+ 				    sshkey_type(idlist->keys[i]));
+ 				free(fp);
+@@ -514,6 +522,7 @@ main(int argc, char **argv)
+ 		switch (ch) {
+ 		case 'E':
+ 			fingerprint_hash = ssh_digest_alg_by_name(optarg);
++			fingerprint_compat = 0;
+ 			if (fingerprint_hash == -1)
+ 				fatal("Invalid hash algorithm \"%s\"", optarg);
+ 			break;
+diff --git a/ssh-keygen.c b/ssh-keygen.c
+index 4e0a855..75b3734 100644
+--- a/ssh-keygen.c
++++ b/ssh-keygen.c
+@@ -37,6 +37,7 @@
+ #include <string.h>
+ #include <unistd.h>
+ #include <limits.h>
++#include <assert.h>
+ 
+ #include "xmalloc.h"
+ #include "sshkey.h"
+@@ -101,7 +102,8 @@ int print_fingerprint = 0;
+ int print_bubblebabble = 0;
+ 
+ /* Hash algorithm to use for fingerprints. */
+-int fingerprint_hash = SSH_FP_HASH_DEFAULT;
++int fingerprint_hash = SSH_DIGEST_MD5;
++int fingerprint_compat = 1;
+ 
+ /* The identity file name, given on the command line or entered by the user. */
+ char identity_file[1024];
+@@ -773,6 +775,7 @@ do_download(struct passwd *pw)
+ 	enum sshkey_fp_rep rep;
+ 	int fptype;
+ 	char *fp, *ra;
++	char *fpp;
+ 
+ 	fptype = print_bubblebabble ? SSH_DIGEST_SHA1 : fingerprint_hash;
+ 	rep =    print_bubblebabble ? SSH_FP_BUBBLEBABBLE : SSH_FP_DEFAULT;
+@@ -788,8 +791,13 @@ do_download(struct passwd *pw)
+ 			    SSH_FP_RANDOMART);
+ 			if (fp == NULL || ra == NULL)
+ 				fatal("%s: sshkey_fingerprint fail", __func__);
++			fpp = fp;
++			if (fingerprint_compat == 1) {
++				assert(strncmp(fp, "MD5:", 4) == 0);
++				fpp += 4;
++			}
+ 			printf("%u %s %s (PKCS11 key)\n", sshkey_size(keys[i]),
+-			    fp, sshkey_type(keys[i]));
++			    fpp, sshkey_type(keys[i]));
+ 			if (log_level >= SYSLOG_LEVEL_VERBOSE)
+ 				printf("%s\n", ra);
+ 			free(ra);
+@@ -814,6 +822,7 @@ do_fingerprint(struct passwd *pw)
+ 	FILE *f;
+ 	struct sshkey *public;
+ 	char *comment = NULL, *cp, *ep, line[16*1024], *fp, *ra;
++	char *fpp;
+ 	int r, i, skip = 0, num = 0, invalid = 1;
+ 	enum sshkey_fp_rep rep;
+ 	int fptype;
+@@ -834,7 +843,12 @@ do_fingerprint(struct passwd *pw)
+ 		    SSH_FP_RANDOMART);
+ 		if (fp == NULL || ra == NULL)
+ 			fatal("%s: sshkey_fingerprint fail", __func__);
+-		printf("%u %s %s (%s)\n", sshkey_size(public), fp, comment,
++		fpp = fp;
++		if (fingerprint_compat == 1) {
++			assert(strncmp(fp, "MD5:", 4) == 0);
++			fpp += 4;
++		}
++		printf("%u %s %s (%s)\n", sshkey_size(public), fpp, comment,
+ 		    sshkey_type(public));
+ 		if (log_level >= SYSLOG_LEVEL_VERBOSE)
+ 			printf("%s\n", ra);
+@@ -2243,6 +2257,7 @@ main(int argc, char **argv)
+ 			break;
+ 		case 'E':
+ 			fingerprint_hash = ssh_digest_alg_by_name(optarg);
++			fingerprint_compat = 0;
+ 			if (fingerprint_hash == -1)
+ 				fatal("Invalid hash algorithm \"%s\"", optarg);
+ 			break;
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:02 2016
+++ new/build/openssh/patches/0034-Restore-tcpwrappers-libwrap-support.patch	Wed Feb 10 16:25:02 2016
@@ -0,0 +1,159 @@
+From 38fc11d61103a3fa75e72b111abaab812dac8061 Mon Sep 17 00:00:00 2001
+From: Alex Wilson <alex.wilson@joyent.com>
+Date: Wed, 16 Sep 2015 10:54:13 -0700
+Subject: [PATCH 34/36] Restore tcpwrappers/libwrap support
+
+This reverts commit f9696566fb41320820f3b257ab564fa321bb3751
+and commit f2719b7c2b8a3b14d778d8a6d8dc729b5174b054.
+---
+ configure.ac | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ sshd.1m      |  7 +++++++
+ sshd.c       | 25 +++++++++++++++++++++++++
+ 3 files changed, 89 insertions(+)
+
+diff --git a/configure.ac b/configure.ac
+index e251f9b..0097431 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -1456,6 +1456,62 @@ AC_ARG_WITH([skey],
+ 	]
+ )
+ 
++# Check whether user wants TCP wrappers support
++TCPW_MSG="no"
++AC_ARG_WITH([tcp-wrappers],
++	[  --with-tcp-wrappers[[=PATH]] Enable tcpwrappers support (optionally in PATH)],
++	[
++		if test "x$withval" != "xno" ; then
++			saved_LIBS="$LIBS"
++			saved_LDFLAGS="$LDFLAGS"
++			saved_CPPFLAGS="$CPPFLAGS"
++			if test -n "${withval}" && \
++			    test "x${withval}" != "xyes"; then
++				if test -d "${withval}/lib"; then
++					if test -n "${need_dash_r}"; then
++						LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
++					else
++						LDFLAGS="-L${withval}/lib ${LDFLAGS}"
++					fi
++				else
++					if test -n "${need_dash_r}"; then
++						LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
++					else
++						LDFLAGS="-L${withval} ${LDFLAGS}"
++					fi
++				fi
++				if test -d "${withval}/include"; then
++					CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
++				else
++					CPPFLAGS="-I${withval} ${CPPFLAGS}"
++				fi
++			fi
++			LIBS="-lwrap $LIBS"
++			AC_MSG_CHECKING([for libwrap])
++			AC_LINK_IFELSE([AC_LANG_PROGRAM([[
++#include <sys/types.h>
++#include <sys/socket.h>
++#include <netinet/in.h>
++#include <tcpd.h>
++int deny_severity = 0, allow_severity = 0;
++				]], [[
++	hosts_access(0);
++				]])], [
++					AC_MSG_RESULT([yes])
++					AC_DEFINE([LIBWRAP], [1],
++						[Define if you want
++						TCP Wrappers support])
++					SSHDLIBS="$SSHDLIBS -lwrap"
++					TCPW_MSG="yes"
++				], [
++					AC_MSG_ERROR([*** libwrap missing])
++				
++			])
++			LIBS="$saved_LIBS"
++		fi
++	]
++)
++
+ # Check whether user wants to use ldns
+ LDNS_MSG="no"
+ AC_ARG_WITH(ldns,
+@@ -4993,6 +5049,7 @@ echo "                 KerberosV support: $KRB5_MSG"
+ echo "                   SELinux support: $SELINUX_MSG"
+ echo "                 Smartcard support: $SCARD_MSG"
+ echo "                     S/KEY support: $SKEY_MSG"
++echo "              TCP Wrappers support: $TCPW_MSG"
+ echo "              MD5 password support: $MD5_MSG"
+ echo "                   libedit support: $LIBEDIT_MSG"
+ echo "  Solaris process contract support: $SPC_MSG"
+diff --git a/sshd.1m b/sshd.1m
+index 3753f90..345c08f 100644
+--- a/sshd.1m
++++ b/sshd.1m
+@@ -850,6 +850,12 @@ the user's home directory becomes accessible.
+ This file should be writable only by the user, and need not be
+ readable by anyone else.
+ .Pp
++.It Pa /etc/hosts.allow
++.It Pa /etc/hosts.deny
++Access controls that should be enforced by tcp-wrappers are defined here.
++Further details are described in
++.Xr hosts_access 5 .
++.Pp
+ .It Pa /etc/hosts.equiv
+ This file is for host-based authentication (see
+ .Xr ssh 1 ) .
+@@ -980,6 +986,7 @@ Each SSHv2 userauth type has its own PAM service name:
+ .Xr ssh-keygen 1 ,
+ .Xr ssh-keyscan 1 ,
+ .Xr chroot 2 ,
++.Xr hosts_access 5 ,
+ .Xr login.conf 5 ,
+ .Xr moduli 4 ,
+ .Xr sshd_config 4 ,
+diff --git a/sshd.c b/sshd.c
+index f19b398..c32c078 100644
+--- a/sshd.c
++++ b/sshd.c
+@@ -126,6 +126,13 @@
+ #include "version.h"
+ #include "ssherr.h"
+ 
++#ifdef LIBWRAP
++#include <tcpd.h>
++#include <syslog.h>
++int allow_severity;
++int deny_severity;
++#endif /* LIBWRAP */
++
+ #ifndef O_NOCTTY
+ #define O_NOCTTY	0
+ #endif
+@@ -2166,6 +2173,24 @@ main(int ac, char **av)
+ #ifdef SSH_AUDIT_EVENTS
+ 	audit_connection_from(remote_ip, remote_port);
+ #endif
++#ifdef LIBWRAP
++	allow_severity = options.log_facility|LOG_INFO;
++	deny_severity = options.log_facility|LOG_WARNING;
++	/* Check whether logins are denied from this host. */
++	if (packet_connection_is_on_socket()) {
++		struct request_info req;
++
++		request_init(&req, RQ_DAEMON, __progname, RQ_FILE, sock_in, 0);
++		fromhost(&req);
++
++		if (!hosts_access(&req)) {
++			debug("Connection refused by tcp wrapper");
++			refuse(&req);
++			/* NOTREACHED */
++			fatal("libwrap refuse returns");
++		}
++	}
++#endif /* LIBWRAP */
+ 
+ 	/* Log the connection. */
+ 	laddr = get_local_ipaddr(sock_in);
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:02 2016
+++ new/build/openssh/patches/0035-Let-us-put-a-fallback-copy-of-DH-moduli-in-a-system-.patch	Wed Feb 10 16:25:02 2016
@@ -0,0 +1,108 @@
+From 02ca99dfcbeade2367a527b5024137946914d4fc Mon Sep 17 00:00:00 2001
+From: Alex Wilson <alex.wilson@joyent.com>
+Date: Thu, 15 Oct 2015 16:02:37 -0700
+Subject: [PATCH 35/36] Let us put a fallback copy of DH moduli in a system
+ path
+
+Live distributions like SmartOS can't keep and update default
+config in directories like /etc/ssh very easily, so we should
+put the default "moduli" file in a system path and fall back to
+that if we can't find one in the SSHKEYDIR.
+---
+ Makefile.in  | 17 +++++------------
+ configure.ac | 15 +++++++++++++++
+ dh.c         |  3 +++
+ 3 files changed, 23 insertions(+), 12 deletions(-)
+
+diff --git a/Makefile.in b/Makefile.in
+index 5e05771..afe15c8 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -19,6 +19,7 @@ piddir=@piddir@
+ srcdir=@srcdir@
+ top_srcdir=@top_srcdir@
+ keydir=@keydir@
++modulidir=@modulidir@
+ 
+ DESTDIR=
+ VPATH=@srcdir@
+@@ -139,8 +140,8 @@ PATHSUBS	= \
+ 	-e 's|/etc/ssh/ssh_host_rsa_key|$(keydir)/ssh_host_rsa_key|g' \
+ 	-e 's|/etc/ssh/ssh_host_ed25519_key|$(keydir)/ssh_host_ed25519_key|g' \
+ 	-e 's|/var/run/sshd.pid|$(piddir)/sshd.pid|g' \
+-	-e 's|/etc/moduli|$(sysconfdir)/moduli|g' \
+-	-e 's|/etc/ssh/moduli|$(sysconfdir)/moduli|g' \
++	-e 's|/etc/moduli|$(modulidir)/moduli|g' \
++	-e 's|/etc/ssh/moduli|$(modulidir)/moduli|g' \
+ 	-e 's|/etc/ssh/sshrc|$(sysconfdir)/sshrc|g' \
+ 	-e 's|/usr/X11R6/bin/xauth|$(XAUTH_PATH)|g' \
+ 	-e 's|/var/empty|$(PRIVSEP_PATH)|g' \
+@@ -367,6 +368,8 @@ install-files:
+ 	$(INSTALL) -m 555 smf/method.sh $(SMFMETHODDIR)/sshd
+ 	$(INSTALL) -m 444 smf/manifest.xml $(SMFNETMANIDIR)/ssh.xml
+ 	mkdir -p $(DESTDIR)$(keydir)
++	$(srcdir)/mkinstalldirs $(DESTDIR)$(modulidir)
++	$(INSTALL) -m 644 moduli.out $(DESTDIR)$(modulidir)/moduli
+ 
+ install-sysconf:
+ 	if [ ! -d $(DESTDIR)$(sysconfdir) ]; then \
+@@ -382,16 +385,6 @@ install-sysconf:
+ 	else \
+ 		echo "$(DESTDIR)$(sysconfdir)/sshd_config already exists, install will not overwrite"; \
+ 	fi
+-	@if [ ! -f $(DESTDIR)$(sysconfdir)/moduli ]; then \
+-		if [ -f $(DESTDIR)$(sysconfdir)/primes ]; then \
+-			echo "moving $(DESTDIR)$(sysconfdir)/primes to $(DESTDIR)$(sysconfdir)/moduli"; \
+-			mv "$(DESTDIR)$(sysconfdir)/primes" "$(DESTDIR)$(sysconfdir)/moduli"; \
+-		else \
+-			$(INSTALL) -m 644 moduli.out $(DESTDIR)$(sysconfdir)/moduli; \
+-		fi ; \
+-	else \
+-		echo "$(DESTDIR)$(sysconfdir)/moduli already exists, install will not overwrite"; \
+-	fi
+ 
+ host-key: ssh-keygen$(EXEEXT)
+ 	@if [ -z "$(DESTDIR)" ] ; then \
+diff --git a/configure.ac b/configure.ac
+index 0097431..c5da202 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -4713,6 +4713,21 @@ AC_DEFINE_UNQUOTED([SSHKEYDIR], ["$keydir"],
+ 	[Specify location of SSH host keys])
+ AC_SUBST([keydir])
+ 
++modulidir=$sysconfdir
++AC_ARG_WITH([sys-moduli],
++	[  --with-sys-moduli=PATH      Specify location for system default moduli],
++	[
++		if test -n "$withval"  &&  test "x$withval" != "xno"  &&  \
++		    test "x${withval}" != "xyes"; then
++			sysmoduli=$withval
++			modulidir=`dirname $sysmoduli`
++			AC_DEFINE_UNQUOTED([_PATH_SYS_MODULI], ["$sysmoduli"],
++				[Specify location for system default moduli])
++		fi
++	]
++)
++AC_SUBST([modulidir])
++
+ dnl allow user to disable some login recording features
+ AC_ARG_ENABLE([lastlog],
+ 	[  --disable-lastlog       disable use of lastlog even if detected [no]],
+diff --git a/dh.c b/dh.c
+index 4c639ac..a1a0639 100644
+--- a/dh.c
++++ b/dh.c
+@@ -152,6 +152,9 @@ choose_dh(int min, int wantbits, int max)
+ 	struct dhgroup dhg;
+ 
+ 	if ((f = fopen(_PATH_DH_MODULI, "r")) == NULL &&
++#if defined(_PATH_SYS_MODULI)
++	    (f = fopen(_PATH_SYS_MODULI, "r")) == NULL &&
++#endif
+ 	    (f = fopen(_PATH_DH_PRIMES, "r")) == NULL) {
+ 		logit("WARNING: %s does not exist, using fixed modulus",
+ 		    _PATH_DH_MODULI);
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:02 2016
+++ new/build/openssh/patches/0036-Default-to-enabling-sandbox-when-built-with-sandbox-.patch	Wed Feb 10 16:25:02 2016
@@ -0,0 +1,44 @@
+From 98fa54cc412790040fa5232fffae6c82e5c78022 Mon Sep 17 00:00:00 2001
+From: Alex Wilson <alex.wilson@joyent.com>
+Date: Tue, 22 Dec 2015 17:42:12 -0800
+Subject: [PATCH 36/36] Default to enabling "sandbox" when built
+ --with-sandbox=solaris
+
+The Solaris priv sandbox should be enabled by default, to preserve
+old behaviour, and also because it does not have any significant
+negative impacts on performance or otherwise.
+---
+ servconf.c | 8 ++++++++
+ 1 file changed, 8 insertions(+)
+
+diff --git a/servconf.c b/servconf.c
+index 245f2fd..5709978 100644
+--- a/servconf.c
++++ b/servconf.c
+@@ -472,7 +472,11 @@ fill_default_server_options(ServerOptions *options)
+ 
+ 	/* Turn privilege separation on by default */
+ 	if (use_privsep == -1)
++#ifdef USE_SOLARIS_PRIVS
++		use_privsep = PRIVSEP_ON;
++#else
+ 		use_privsep = PRIVSEP_NOSANDBOX;
++#endif
+ 
+ #define CLEAR_ON_NONE(v) \
+ 	do { \
+@@ -1108,7 +1112,11 @@ static const struct multistate multistate_gatewayports[] = {
+ 	{ NULL, -1 }
+ };
+ static const struct multistate multistate_privsep[] = {
++#ifdef USE_SOLARIS_PRIVS
++	{ "yes",			PRIVSEP_ON },
++#else
+ 	{ "yes",			PRIVSEP_NOSANDBOX },
++#endif
+ 	{ "sandbox",			PRIVSEP_ON },
+ 	{ "nosandbox",			PRIVSEP_NOSANDBOX },
+ 	{ "no",				PRIVSEP_OFF },
+-- 
+2.5.4 (Apple Git-61)
+
--- /dev/null	Wed Feb 10 16:25:02 2016
+++ new/build/openssh/patches/1001-dtrace32.patch	Wed Feb 10 16:25:02 2016
@@ -0,0 +1,43 @@
+From f20520c20ef1f0091222188c481928b92c5ac9d4 Mon Sep 17 00:00:00 2001
+From: Alex Wilson <alex.wilson@joyent.com>
+Date: Thu, 14 Jan 2016 10:12:07 -0800
+Subject: [PATCH 1/2] SmartOS local: make dtrace lib 32-bit
+
+---
+ Makefile.in | 6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+diff --git a/Makefile.in b/Makefile.in
+index afe15c8..6462088 100644
+--- a/Makefile.in
++++ b/Makefile.in
+@@ -28,7 +28,7 @@ ASKPASS_PROGRAM=$(libexecdir)/ssh-askpass
+ SFTP_SERVER=$(libexecdir)/sftp-server
+ SSH_KEYSIGN=$(libexecdir)/ssh-keysign
+ SSH_PKCS11_HELPER=$(libexecdir)/ssh-pkcs11-helper
+-ROOTDLIBDIR64=$(DESTDIR)/usr/lib/dtrace/64
++ROOTDLIBDIR=$(DESTDIR)/usr/lib/dtrace
+ SMFMETHODDIR=$(DESTDIR)/lib/svc/method
+ SMFNETMANIDIR=$(DESTDIR)/lib/svc/manifest/network
+ PRIVSEP_PATH=@PRIVSEP_PATH@
+@@ -240,7 +240,7 @@ sftp_provider.h: $(srcdir)/sftp_provider.d
+ 	    -o $(srcdir)/sftp_provider.h
+ 
+ sftp_provider.o: sftp_provider.d sftp_provider.h sftp-server.o
+-	/usr/sbin/dtrace -G -64 -xnolibs -s $(srcdir)/sftp_provider.d \
++	/usr/sbin/dtrace -G -xnolibs -s $(srcdir)/sftp_provider.d \
+ 	    sftp-server.o -o sftp_provider.o
+ 
+ # special case for sftp-server.o, it includes sftp_provider.h
+@@ -362,7 +362,7 @@ install-files:
+ 	ln -s ./ssh$(EXEEXT) $(DESTDIR)$(bindir)/slogin
+ 	-rm -f $(DESTDIR)$(mandir)/$(mansubdir)1/slogin.1
+ 	ln -s ./ssh.1 $(DESTDIR)$(mandir)/$(mansubdir)1/slogin.1
+-	mkdir -p $(ROOTDLIBDIR64) && cp $(srcdir)/sftp64.d $(ROOTDLIBDIR64)/sftp64.d
++	mkdir -p $(ROOTDLIBDIR) && cp $(srcdir)/sftp64.d $(ROOTDLIBDIR)/sftp.d
+ 	$(srcdir)/mkinstalldirs $(SMFMETHODDIR)
+ 	$(srcdir)/mkinstalldirs $(SMFNETMANIDIR)
+ 	$(INSTALL) -m 555 smf/method.sh $(SMFMETHODDIR)/sshd
+-- 
+2.5.4 (Apple Git-61)
+
--- old/build/openssh/patches/series	Wed Feb 10 16:25:02 2016
+++ new/build/openssh/patches/series	Wed Feb 10 16:25:02 2016
@@ -1,10 +1,38 @@
-sshd_config.patch
-0002-PAM-Support.patch
-0003-lastlogin.patch
-0004-Reorganise-man-pages-into-Illumos-numbering-adjust-t.patch
-0009-PAM-conversation-fix.patch
-0010-PAM-enhancements-for-Solaris.patch
-0014-Solaris-Auditing-support.patch
-0016-Enable-login-to-a-role-if-PAM-is-ok-with-it.patch
-0017-PAM-setcred-failures.patch
-0032-Accept-LANG-and-LC_-environment-variables-from-clien.patch
+sshd_config.patch 
+0001-upstream-commit.patch 
+0002-Support-Illumos-Solaris-fine-grained-privileges.patch 
+0003-Skip-config-check.patch 
+0004-PAM-Support.patch 
+0005-lastlogin.patch 
+0006-Reorganise-man-pages-into-Illumos-numbering-adjust-t.patch 
+0007-Deprecated-SunSSH-options.patch 
+0008-GSS-store-creds-for-Solaris.patch 
+0009-DTrace-support-for-SFTP.patch 
+0010-Add-DisableBanner-option.patch 
+0011-PAM-conversation-fix.patch 
+0012-PAM-enhancements-for-Solaris.patch 
+0013-SunSSH-compat-default-config-values.patch 
+0014-Deprecate-SunSSH-compatible-server-options.patch 
+0015-Solaris-Auditing-support.patch 
+0016-GSS-API-key-exchange-support.patch 
+0017-Enable-login-to-a-role-if-PAM-is-ok-with-it.patch 
+0018-PAM-setcred-failures.patch 
+0019-Don-t-call-do_pam_setcred-twice.patch 
+0020-Per-session-xauthfile.patch 
+0021-PubKeyPlugin-support.patch 
+0022-Compatibility-fix-for-ListenAddress.patch 
+0023-Hack-around-umac_ctx-name-punning.patch 
+0024-Try-to-create-privsep-chroot-dir-if-it-doesn-t-exist.patch 
+0025-Add-SMF-manifest-and-method-and-install-them.patch 
+0026-Make-default-sshd_config-more-like-the-old-illumos-o.patch 
+0027-Add-with-key-dir-configure-option-to-place-SSH-host-.patch 
+0028-Re-enable-DSA-keys-for-pk-auth.patch 
+0029-Don-t-use-krb5-config-to-check-for-GSSAPI-on-Illumos.patch 
+0030-Set-default-sshd-options-based-on-etc-default-login.patch 
+0031-Compatibility-for-SunSSH_1.5-should-include-old-DH-K.patch 
+0032-Accept-LANG-and-LC_-environment-variables-from-clien.patch 
+0033-Temporarily-set-ssh-keygen-and-ssh-add-to-old-FP-for.patch 
+0034-Restore-tcpwrappers-libwrap-support.patch 
+0035-Let-us-put-a-fallback-copy-of-DH-moduli-in-a-system-.patch 
+0036-Default-to-enabling-sandbox-when-built-with-sandbox-.patch 
+1001-dtrace32.patch
--- old/build/openssh/ssh.xml	Wed Feb 10 16:25:02 2016
+++ /dev/null	Wed Feb 10 16:25:02 2016
@@ -1,68 +0,0 @@
-<?xml version='1.0' ?>
-<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
-
-<service_bundle type='manifest' name='openssh' >
-	<service name='network/ssh' type='service' version='1'>
-		<create_default_instance enabled='false' />
-		<single_instance />
-
-		<dependency name='loopback'  grouping='require_all'
-		restart_on='none' type='service'>
-			<service_fmri value='svc:/network/loopback:default' />
-		</dependency>
-
-		<dependency name='physical'  grouping='require_all'
-		restart_on='none' type='service'>
-			<service_fmri value='svc:/network/physical:default' />
-		</dependency>
-
-		<dependency name='cryptosvc'  grouping='require_all'
-		restart_on='none' type='service'>
-			<service_fmri value='svc:/system/cryptosvc:default' />
-		</dependency>
-		
-		<dependency name='localfs'  grouping='require_all'
-		restart_on='none' type='service'>
-			<service_fmri value='svc:/system/filesystem/local:default' />
-		</dependency>
-
-		<dependency
-		name='config-file'
-		grouping='require_all'
-		restart_on='restart'
-		type='path'>
-		<service_fmri
-		value='file://localhost/etc/ssh/sshd_config' />
-		</dependency>
-		
-		<exec_method name='start' type='method'
-		exec='/lib/svc/method/sshd start'
-		timeout_seconds='60' />
-		
-		<exec_method name='stop' type='method'
-		exec=':kill'
-		timeout_seconds='60' />
-		
-		<exec_method name='refresh' type='method'
-		exec=':kill -HUP'
-		timeout_seconds='60' />
-
-		<property_group name='general' type='framework'>
-			<propval name='action_authorization' type='astring'
-			value='omnios.smf.manage.openssh' />
-		</property_group>
-
-		<stability value='Evolving' />
-
-		<template>
-			<common_name>
-				<loctext xml:lang='C'>OpenSSH Server</loctext>
-			</common_name>
-
-			<documentation>
-				<manpage title='sshd' section='1M' />
-				<doc_link name='openssh.com' uri='http://openssh.com' />
-			</documentation>
-		</template>
-	</service>
-</service_bundle>
