vishalmishra434 / rpms / openssh

Forked from rpms/openssh a month ago
Clone
Jan F. Chadima 69dd72
diff -up openssh-5.9p0/auth.h.2auth openssh-5.9p0/auth.h
Jan F. Chadima 69dd72
--- openssh-5.9p0/auth.h.2auth	2011-05-29 13:39:38.000000000 +0200
Jan F. Chadima 69dd72
+++ openssh-5.9p0/auth.h	2011-09-05 13:16:00.550626991 +0200
Jan F. Chadima 69dd72
@@ -149,6 +149,8 @@ int	auth_root_allowed(char *);
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
 char	*auth2_read_banner(void);
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
+void	userauth_restart(const char *);
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
 void	privsep_challenge_enable(void);
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
 int	auth2_challenge(Authctxt *, char *);
Jan F. Chadima 69dd72
diff -up openssh-5.9p0/auth2.c.2auth openssh-5.9p0/auth2.c
Jan F. Chadima 69dd72
--- openssh-5.9p0/auth2.c.2auth	2011-05-05 06:04:11.000000000 +0200
Jan F. Chadima 69dd72
+++ openssh-5.9p0/auth2.c	2011-09-05 13:16:00.640626827 +0200
Jan F. Chadima 69dd72
@@ -290,6 +290,23 @@ input_userauth_request(int type, u_int32
Jan F. Chadima 69dd72
 }
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
 void
Jan F. Chadima 69dd72
+userauth_restart(const char *method)
Jan F. Chadima 69dd72
+{
Jan F. Chadima 69dd72
+	options.two_factor_authentication = 0;
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
+	options.pubkey_authentication = options.second_pubkey_authentication && strcmp(method, method_pubkey.name);
Jan F. Chadima 69dd72
+#ifdef GSSAPI
Jan F. Chadima 69dd72
+	options.gss_authentication = options.second_gss_authentication && strcmp(method, method_gssapi.name);
Jan F. Chadima 69dd72
+#endif
Jan F. Chadima 69dd72
+#ifdef JPAKE
Jan F. Chadima 69dd72
+	options.zero_knowledge_password_authentication = options.second_zero_knowledge_password_authentication && strcmp(method, method_jpake.name);
Jan F. Chadima 69dd72
+#endif
Jan F. Chadima 69dd72
+	options.password_authentication = options.second_password_authentication && strcmp(method, method_passwd.name);
Jan F. Chadima 69dd72
+	options.kbd_interactive_authentication = options.second_kbd_interactive_authentication && strcmp(method, method_kbdint.name);
Jan F. Chadima 69dd72
+	options.hostbased_authentication = options.second_hostbased_authentication && strcmp(method, method_hostbased.name);
Jan F. Chadima 69dd72
+}
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
+void
Jan F. Chadima 69dd72
 userauth_finish(Authctxt *authctxt, int authenticated, char *method)
Jan F. Chadima 69dd72
 {
Jan F. Chadima 69dd72
 	char *methods;
Jan F. Chadima 69dd72
@@ -337,6 +354,15 @@ userauth_finish(Authctxt *authctxt, int
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
 	/* XXX todo: check if multiple auth methods are needed */
Jan F. Chadima 69dd72
 	if (authenticated == 1) {
Jan F. Chadima 69dd72
+		if (options.two_factor_authentication) {
Jan F. Chadima 69dd72
+			userauth_restart(method);
Jan F. Chadima 69dd72
+			if (use_privsep) 
Jan F. Chadima 69dd72
+				PRIVSEP(userauth_restart(method));
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
+			debug("1st factor authentication done go to 2nd factor");
Jan F. Chadima 69dd72
+			goto ask_methods;
Jan F. Chadima 69dd72
+		}
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
 		/* turn off userauth */
Jan F. Chadima 69dd72
 		dispatch_set(SSH2_MSG_USERAUTH_REQUEST, &dispatch_protocol_ignore);
Jan F. Chadima 69dd72
 		packet_start(SSH2_MSG_USERAUTH_SUCCESS);
Jan F. Chadima 69dd72
@@ -356,6 +382,7 @@ userauth_finish(Authctxt *authctxt, int
Jan F. Chadima 69dd72
 #endif
Jan F. Chadima 69dd72
 			packet_disconnect(AUTH_FAIL_MSG, authctxt->user);
Jan F. Chadima 69dd72
 		}
Jan F. Chadima 69dd72
+ask_methods:
Jan F. Chadima 69dd72
 		methods = authmethods_get();
Jan F. Chadima 69dd72
 		packet_start(SSH2_MSG_USERAUTH_FAILURE);
Jan F. Chadima 69dd72
 		packet_put_cstring(methods);
Jan F. Chadima 69dd72
diff -up openssh-5.9p0/monitor.c.2auth openssh-5.9p0/monitor.c
Jan F. Chadima 69dd72
--- openssh-5.9p0/monitor.c.2auth	2011-08-05 22:15:18.000000000 +0200
Jan F. Chadima 69dd72
+++ openssh-5.9p0/monitor.c	2011-09-05 13:37:35.468502112 +0200
Jan F. Chadima 69dd72
@@ -165,6 +165,7 @@ int mm_answer_jpake_step1(int, Buffer *)
Jan F. Chadima 69dd72
 int mm_answer_jpake_step2(int, Buffer *);
Jan F. Chadima 69dd72
 int mm_answer_jpake_key_confirm(int, Buffer *);
Jan F. Chadima 69dd72
 int mm_answer_jpake_check_confirm(int, Buffer *);
Jan F. Chadima 69dd72
+int mm_answer_userauth_restart(int, Buffer *);
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
 #ifdef USE_PAM
Jan F. Chadima 69dd72
 int mm_answer_pam_start(int, Buffer *);
Jan F. Chadima 69dd72
@@ -259,6 +260,7 @@ struct mon_table mon_dispatch_proto20[]
Jan F. Chadima 69dd72
     {MONITOR_REQ_JPAKE_KEY_CONFIRM, MON_ONCE, mm_answer_jpake_key_confirm},
Jan F. Chadima 69dd72
     {MONITOR_REQ_JPAKE_CHECK_CONFIRM, MON_AUTH, mm_answer_jpake_check_confirm},
Jan F. Chadima 69dd72
 #endif
Jan F. Chadima 69dd72
+    {MONITOR_REQ_USERAUTH_RESTART, MON_PERMIT, mm_answer_userauth_restart},
Jan F. Chadima 69dd72
     {0, 0, NULL}
Jan F. Chadima 69dd72
 };
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
@@ -378,9 +380,9 @@ monitor_child_preauth(Authctxt *_authctx
Jan F. Chadima 69dd72
 	}
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
 	/* The first few requests do not require asynchronous access */
Jan F. Chadima 69dd72
-	while (!authenticated) {
Jan F. Chadima 69dd72
+	while (!authenticated || options.two_factor_authentication) {
Jan F. Chadima 69dd72
 		auth_method = "unknown";
Jan F. Chadima 69dd72
 		authenticated = (monitor_read(pmonitor, mon_dispatch, &ent) == 1);
Jan F. Chadima 69dd72
 		if (authenticated) {
Jan F. Chadima 69dd72
 			if (!(ent->flags & MON_AUTHDECIDE))
Jan F. Chadima 69dd72
 				fatal("%s: unexpected authentication from %d",
Jan F. Chadima 69dd72
@@ -390,7 +393,7 @@ monitor_child_preauth(Authctxt *_authctx
Jan F. Chadima 69dd72
 				authenticated = 0;
Jan F. Chadima 69dd72
 #ifdef USE_PAM
Jan F. Chadima 69dd72
 			/* PAM needs to perform account checks after auth */
Jan F. Chadima 69dd72
-			if (options.use_pam && authenticated) {
Jan F. Chadima 69dd72
+			if (options.use_pam && authenticated && !options.two_factor_authentication) {
Jan F. Chadima 69dd72
 				Buffer m;
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
 				buffer_init(&m);
Jan F. Chadima 69dd72
@@ -2000,6 +2006,19 @@ monitor_reinit(struct monitor *mon)
Jan F. Chadima 69dd72
 	monitor_openfds(mon, 0);
Jan F. Chadima 69dd72
 }
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
+int
Jan F. Chadima 69dd72
+mm_answer_userauth_restart(int sock, Buffer *m)
Jan F. Chadima 69dd72
+{
Jan F. Chadima 69dd72
+	char *method;
Jan F. Chadima 69dd72
+	u_int method_len;
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
+	method = buffer_get_string(m, &method_len);
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
+	userauth_restart(method);
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
+	mm_request_send(sock, MONITOR_ANS_USERAUTH_RESTART, m);
Jan F. Chadima 69dd72
+}
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
 #ifdef GSSAPI
Jan F. Chadima 69dd72
 int
Jan F. Chadima 69dd72
 mm_answer_gss_setup_ctx(int sock, Buffer *m)
Jan F. Chadima 69dd72
diff -up openssh-5.9p0/monitor.h.2auth openssh-5.9p0/monitor.h
Jan F. Chadima 69dd72
--- openssh-5.9p0/monitor.h.2auth	2011-06-20 06:42:23.000000000 +0200
Jan F. Chadima 69dd72
+++ openssh-5.9p0/monitor.h	2011-09-05 13:16:00.855502353 +0200
Jan F. Chadima 69dd72
@@ -66,6 +66,7 @@ enum monitor_reqtype {
Jan F. Chadima 69dd72
 	MONITOR_REQ_JPAKE_STEP2, MONITOR_ANS_JPAKE_STEP2,
Jan F. Chadima 69dd72
 	MONITOR_REQ_JPAKE_KEY_CONFIRM, MONITOR_ANS_JPAKE_KEY_CONFIRM,
Jan F. Chadima 69dd72
 	MONITOR_REQ_JPAKE_CHECK_CONFIRM, MONITOR_ANS_JPAKE_CHECK_CONFIRM,
Jan F. Chadima 69dd72
+	MONITOR_REQ_USERAUTH_RESTART, MONITOR_ANS_USERAUTH_RESTART,
Jan F. Chadima 69dd72
 };
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
 struct mm_master;
Jan F. Chadima 69dd72
diff -up openssh-5.9p0/monitor_wrap.c.2auth openssh-5.9p0/monitor_wrap.c
Jan F. Chadima 69dd72
--- openssh-5.9p0/monitor_wrap.c.2auth	2011-06-20 06:42:23.000000000 +0200
Jan F. Chadima 69dd72
+++ openssh-5.9p0/monitor_wrap.c	2011-09-05 13:16:00.968503257 +0200
Jan F. Chadima 69dd72
@@ -1173,6 +1173,26 @@ mm_auth_rsa_verify_response(Key *key, BI
Jan F. Chadima 69dd72
 	return (success);
Jan F. Chadima 69dd72
 }
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
+void
Jan F. Chadima 69dd72
+mm_userauth_restart(const char *monitor)
Jan F. Chadima 69dd72
+{
Jan F. Chadima 69dd72
+	Buffer m;
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
+	debug3("%s entering", __func__);
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
+	buffer_init(&m);
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
+	buffer_put_cstring(&m, monitor);
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
+	mm_request_send(pmonitor->m_recvfd,
Jan F. Chadima 69dd72
+	    MONITOR_REQ_USERAUTH_RESTART, &m);
Jan F. Chadima 69dd72
+	debug3("%s: waiting for MONITOR_ANS_USERAUTH_RESTART", __func__);
Jan F. Chadima 69dd72
+	mm_request_receive_expect(pmonitor->m_recvfd,
Jan F. Chadima 69dd72
+	    MONITOR_ANS_USERAUTH_RESTART, &m);
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
+	buffer_free(&m);
Jan F. Chadima 69dd72
+}
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
 #ifdef SSH_AUDIT_EVENTS
Jan F. Chadima 69dd72
 void
Jan F. Chadima 69dd72
 mm_audit_event(ssh_audit_event_t event)
Jan F. Chadima 69dd72
diff -up openssh-5.9p0/monitor_wrap.h.2auth openssh-5.9p0/monitor_wrap.h
Jan F. Chadima 69dd72
--- openssh-5.9p0/monitor_wrap.h.2auth	2011-06-20 06:42:23.000000000 +0200
Jan F. Chadima 69dd72
+++ openssh-5.9p0/monitor_wrap.h	2011-09-05 13:16:01.074502211 +0200
Jan F. Chadima 69dd72
@@ -53,6 +53,7 @@ int mm_key_verify(Key *, u_char *, u_int
Jan F. Chadima 69dd72
 int mm_auth_rsa_key_allowed(struct passwd *, BIGNUM *, Key **);
Jan F. Chadima 69dd72
 int mm_auth_rsa_verify_response(Key *, BIGNUM *, u_char *);
Jan F. Chadima 69dd72
 BIGNUM *mm_auth_rsa_generate_challenge(Key *);
Jan F. Chadima 69dd72
+void mm_userauth_restart(const char *);
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
 #ifdef GSSAPI
Jan F. Chadima 69dd72
 OM_uint32 mm_ssh_gssapi_server_ctx(Gssctxt **, gss_OID);
Jan F. Chadima 69dd72
diff -up openssh-5.9p0/servconf.c.2auth openssh-5.9p0/servconf.c
Jan F. Chadima 69dd72
--- openssh-5.9p0/servconf.c.2auth	2011-06-23 00:30:03.000000000 +0200
Jan F. Chadima 69dd72
+++ openssh-5.9p0/servconf.c	2011-09-05 13:16:01.223441110 +0200
Jan F. Chadima 69dd72
@@ -92,6 +92,13 @@ initialize_server_options(ServerOptions
Jan F. Chadima 69dd72
 	options->hostbased_uses_name_from_packet_only = -1;
Jan F. Chadima 69dd72
 	options->rsa_authentication = -1;
Jan F. Chadima 69dd72
 	options->pubkey_authentication = -1;
Jan F. Chadima 69dd72
+	options->two_factor_authentication = -1;
Jan F. Chadima 69dd72
+	options->second_pubkey_authentication = -1;
Jan F. Chadima 69dd72
+	options->second_gss_authentication = -1;
Jan F. Chadima 69dd72
+	options->second_password_authentication = -1;
Jan F. Chadima 69dd72
+	options->second_kbd_interactive_authentication = -1;
Jan F. Chadima 69dd72
+	options->second_zero_knowledge_password_authentication = -1;
Jan F. Chadima 69dd72
+	options->second_hostbased_authentication = -1;
Jan F. Chadima 69dd72
 	options->kerberos_authentication = -1;
Jan F. Chadima 69dd72
 	options->kerberos_or_local_passwd = -1;
Jan F. Chadima 69dd72
 	options->kerberos_ticket_cleanup = -1;
Jan F. Chadima 69dd72
@@ -237,6 +244,20 @@ fill_default_server_options(ServerOption
Jan F. Chadima 69dd72
 		options->permit_empty_passwd = 0;
Jan F. Chadima 69dd72
 	if (options->permit_user_env == -1)
Jan F. Chadima 69dd72
 		options->permit_user_env = 0;
Jan F. Chadima 69dd72
+	if (options->two_factor_authentication == -1)
Jan F. Chadima 69dd72
+		options->two_factor_authentication = 0;
Jan F. Chadima 69dd72
+	if (options->second_pubkey_authentication == -1)
Jan F. Chadima 69dd72
+		options->second_pubkey_authentication = 1;
Jan F. Chadima 69dd72
+	if (options->second_gss_authentication == -1)
Jan F. Chadima 69dd72
+		options->second_gss_authentication = 0;
Jan F. Chadima 69dd72
+	if (options->second_password_authentication == -1)
Jan F. Chadima 69dd72
+		options->second_password_authentication = 1;
Jan F. Chadima 69dd72
+	if (options->second_kbd_interactive_authentication == -1)
Jan F. Chadima 69dd72
+		options->second_kbd_interactive_authentication = 0;
Jan F. Chadima 69dd72
+	if (options->second_zero_knowledge_password_authentication == -1)
Jan F. Chadima 69dd72
+		options->second_zero_knowledge_password_authentication = 0;
Jan F. Chadima 69dd72
+	if (options->second_hostbased_authentication == -1)
Jan F. Chadima 69dd72
+		options->second_hostbased_authentication = 0;
Jan F. Chadima 69dd72
 	if (options->use_login == -1)
Jan F. Chadima 69dd72
 		options->use_login = 0;
Jan F. Chadima 69dd72
 	if (options->compression == -1)
Jan F. Chadima 69dd72
@@ -316,8 +337,11 @@ typedef enum {
Jan F. Chadima 69dd72
 	sGatewayPorts, sPubkeyAuthentication, sXAuthLocation, sSubsystem,
Jan F. Chadima 69dd72
 	sMaxStartups, sMaxAuthTries, sMaxSessions,
Jan F. Chadima 69dd72
 	sBanner, sUseDNS, sHostbasedAuthentication,
Jan F. Chadima 69dd72
-	sHostbasedUsesNameFromPacketOnly, sClientAliveInterval,
Jan F. Chadima 69dd72
-	sClientAliveCountMax, sAuthorizedKeysFile,
Jan F. Chadima 69dd72
+	sHostbasedUsesNameFromPacketOnly, sTwoFactorAuthentication,
Jan F. Chadima 69dd72
+	sSecondPubkeyAuthentication, sSecondGssAuthentication,
Jan F. Chadima 69dd72
+	sSecondPasswordAuthentication, sSecondKbdInteractiveAuthentication,
Jan F. Chadima 69dd72
+	sSecondZeroKnowledgePasswordAuthentication, sSecondHostbasedAuthentication,
Jan F. Chadima 69dd72
+	sClientAliveInterval, sClientAliveCountMax, sAuthorizedKeysFile,
Jan F. Chadima 69dd72
 	sGssAuthentication, sGssCleanupCreds, sAcceptEnv, sPermitTunnel,
Jan F. Chadima 69dd72
 	sMatch, sPermitOpen, sForceCommand, sChrootDirectory,
Jan F. Chadima 69dd72
 	sUsePrivilegeSeparation, sAllowAgentForwarding,
Jan F. Chadima 69dd72
@@ -395,6 +419,21 @@ static struct {
Jan F. Chadima 69dd72
 #else
Jan F. Chadima 69dd72
 	{ "zeroknowledgepasswordauthentication", sUnsupported, SSHCFG_ALL },
Jan F. Chadima 69dd72
 #endif
Jan F. Chadima 69dd72
+	{ "twofactorauthentication", sTwoFactorAuthentication, SSHCFG_ALL },
Jan F. Chadima 69dd72
+	{ "secondpubkeyauthentication", sSecondPubkeyAuthentication, SSHCFG_ALL },
Jan F. Chadima 69dd72
+#ifdef GSSAPI
Jan F. Chadima 69dd72
+	{ "secondgssapiauthentication", sSecondGssAuthentication, SSHCFG_ALL },
Jan F. Chadima 69dd72
+#else
Jan F. Chadima 69dd72
+	{ "secondgssapiauthentication", sUnsupported, SSHCFG_ALL },
Jan F. Chadima 69dd72
+#endif
Jan F. Chadima 69dd72
+	{ "secondpasswordauthentication", sSecondPasswordAuthentication, SSHCFG_ALL },
Jan F. Chadima 69dd72
+	{ "secondkbdinteractiveauthentication", sSecondKbdInteractiveAuthentication, SSHCFG_ALL },
Jan F. Chadima 69dd72
+#ifdef JPAKE
Jan F. Chadima 69dd72
+	{ "secondzeroknowledgepasswordauthentication", sSecondZeroKnowledgePasswordAuthentication, SSHCFG_ALL },
Jan F. Chadima 69dd72
+#else
Jan F. Chadima 69dd72
+	{ "secondzeroknowledgepasswordauthentication", sUnsupported, SSHCFG_ALL },
Jan F. Chadima 69dd72
+#endif
Jan F. Chadima 69dd72
+	{ "secondhostbasedauthentication", sSecondHostbasedAuthentication, SSHCFG_ALL },
Jan F. Chadima 69dd72
 	{ "checkmail", sDeprecated, SSHCFG_GLOBAL },
Jan F. Chadima 69dd72
 	{ "listenaddress", sListenAddress, SSHCFG_GLOBAL },
Jan F. Chadima 69dd72
 	{ "addressfamily", sAddressFamily, SSHCFG_GLOBAL },
Jan F. Chadima 69dd72
@@ -982,6 +1021,34 @@ process_server_config_line(ServerOptions
Jan F. Chadima 69dd72
 		intptr = &options->challenge_response_authentication;
Jan F. Chadima 69dd72
 		goto parse_flag;
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
+	case sTwoFactorAuthentication:
Jan F. Chadima 69dd72
+		intptr = &options->two_factor_authentication;
Jan F. Chadima 69dd72
+		goto parse_flag;
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
+	case sSecondPubkeyAuthentication:
Jan F. Chadima 69dd72
+		intptr = &options->second_pubkey_authentication;
Jan F. Chadima 69dd72
+		goto parse_flag;
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
+	case sSecondGssAuthentication:
Jan F. Chadima 69dd72
+		intptr = &options->second_gss_authentication;
Jan F. Chadima 69dd72
+		goto parse_flag;
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
+	case sSecondPasswordAuthentication:
Jan F. Chadima 69dd72
+		intptr = &options->second_password_authentication;
Jan F. Chadima 69dd72
+		goto parse_flag;
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
+	case sSecondKbdInteractiveAuthentication:
Jan F. Chadima 69dd72
+		intptr = &options->second_kbd_interactive_authentication;
Jan F. Chadima 69dd72
+		goto parse_flag;
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
+	case sSecondZeroKnowledgePasswordAuthentication:
Jan F. Chadima 69dd72
+		intptr = &options->second_zero_knowledge_password_authentication;
Jan F. Chadima 69dd72
+		goto parse_flag;
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
+	case sSecondHostbasedAuthentication:
Jan F. Chadima 69dd72
+		intptr = &options->second_hostbased_authentication;
Jan F. Chadima 69dd72
+		goto parse_flag;
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
 	case sPrintMotd:
Jan F. Chadima 69dd72
 		intptr = &options->print_motd;
Jan F. Chadima 69dd72
 		goto parse_flag;
Jan F. Chadima 69dd72
@@ -1491,14 +1558,21 @@ void
Jan F. Chadima 69dd72
 copy_set_server_options(ServerOptions *dst, ServerOptions *src, int preauth)
Jan F. Chadima 69dd72
 {
Jan F. Chadima 69dd72
 	M_CP_INTOPT(password_authentication);
Jan F. Chadima 69dd72
+	M_CP_INTOPT(second_password_authentication);
Jan F. Chadima 69dd72
 	M_CP_INTOPT(gss_authentication);
Jan F. Chadima 69dd72
+	M_CP_INTOPT(second_gss_authentication);
Jan F. Chadima 69dd72
 	M_CP_INTOPT(rsa_authentication);
Jan F. Chadima 69dd72
 	M_CP_INTOPT(pubkey_authentication);
Jan F. Chadima 69dd72
+	M_CP_INTOPT(second_pubkey_authentication);
Jan F. Chadima 69dd72
 	M_CP_INTOPT(kerberos_authentication);
Jan F. Chadima 69dd72
 	M_CP_INTOPT(hostbased_authentication);
Jan F. Chadima 69dd72
+	M_CP_INTOPT(second_hostbased_authentication);
Jan F. Chadima 69dd72
 	M_CP_INTOPT(hostbased_uses_name_from_packet_only);
Jan F. Chadima 69dd72
 	M_CP_INTOPT(kbd_interactive_authentication);
Jan F. Chadima 69dd72
+	M_CP_INTOPT(second_kbd_interactive_authentication);
Jan F. Chadima 69dd72
 	M_CP_INTOPT(zero_knowledge_password_authentication);
Jan F. Chadima 69dd72
+	M_CP_INTOPT(second_zero_knowledge_password_authentication);
Jan F. Chadima 69dd72
+	M_CP_INTOPT(two_factor_authentication);
Jan F. Chadima 69dd72
 	M_CP_INTOPT(permit_root_login);
Jan F. Chadima 69dd72
 	M_CP_INTOPT(permit_empty_passwd);
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
@@ -1720,17 +1794,24 @@ dump_config(ServerOptions *o)
Jan F. Chadima 69dd72
 #endif
Jan F. Chadima 69dd72
 #ifdef GSSAPI
Jan F. Chadima 69dd72
 	dump_cfg_fmtint(sGssAuthentication, o->gss_authentication);
Jan F. Chadima 69dd72
+	dump_cfg_fmtint(sSecondGssAuthentication, o->second_gss_authentication);
Jan F. Chadima 69dd72
 	dump_cfg_fmtint(sGssCleanupCreds, o->gss_cleanup_creds);
Jan F. Chadima 69dd72
 #endif
Jan F. Chadima 69dd72
 #ifdef JPAKE
Jan F. Chadima 69dd72
 	dump_cfg_fmtint(sZeroKnowledgePasswordAuthentication,
Jan F. Chadima 69dd72
 	    o->zero_knowledge_password_authentication);
Jan F. Chadima 69dd72
+	dump_cfg_fmtint(sSecondZeroKnowledgePasswordAuthentication,
Jan F. Chadima 69dd72
+	    o->second_zero_knowledge_password_authentication);
Jan F. Chadima 69dd72
 #endif
Jan F. Chadima 69dd72
 	dump_cfg_fmtint(sPasswordAuthentication, o->password_authentication);
Jan F. Chadima 69dd72
+	dump_cfg_fmtint(sSecondPasswordAuthentication, o->second_password_authentication);
Jan F. Chadima 69dd72
 	dump_cfg_fmtint(sKbdInteractiveAuthentication,
Jan F. Chadima 69dd72
 	    o->kbd_interactive_authentication);
Jan F. Chadima 69dd72
+	dump_cfg_fmtint(sSecondKbdInteractiveAuthentication,
Jan F. Chadima 69dd72
+	    o->second_kbd_interactive_authentication);
Jan F. Chadima 69dd72
 	dump_cfg_fmtint(sChallengeResponseAuthentication,
Jan F. Chadima 69dd72
 	    o->challenge_response_authentication);
Jan F. Chadima 69dd72
+	dump_cfg_fmtint(sTwoFactorAuthentication, o->two_factor_authentication);
Jan F. Chadima 69dd72
 	dump_cfg_fmtint(sPrintMotd, o->print_motd);
Jan F. Chadima 69dd72
 	dump_cfg_fmtint(sPrintLastLog, o->print_lastlog);
Jan F. Chadima 69dd72
 	dump_cfg_fmtint(sX11Forwarding, o->x11_forwarding);
Jan F. Chadima 69dd72
diff -up openssh-5.9p0/servconf.h.2auth openssh-5.9p0/servconf.h
Jan F. Chadima 69dd72
--- openssh-5.9p0/servconf.h.2auth	2011-06-23 00:30:03.000000000 +0200
Jan F. Chadima 69dd72
+++ openssh-5.9p0/servconf.h	2011-09-05 13:16:01.352564530 +0200
Jan F. Chadima 69dd72
@@ -112,6 +112,14 @@ typedef struct {
Jan F. Chadima 69dd72
 					/* If true, permit jpake auth */
Jan F. Chadima 69dd72
 	int     permit_empty_passwd;	/* If false, do not permit empty
Jan F. Chadima 69dd72
 					 * passwords. */
Jan F. Chadima 69dd72
+	int	two_factor_authentication;	/* If true, the first sucessful authentication
Jan F. Chadima 69dd72
+					 * will be followed by the second one from anorher set */
Jan F. Chadima 69dd72
+	int	second_pubkey_authentication;	/* second set of authentications */
Jan F. Chadima 69dd72
+	int	second_gss_authentication;
Jan F. Chadima 69dd72
+	int	second_password_authentication;
Jan F. Chadima 69dd72
+	int	second_kbd_interactive_authentication;
Jan F. Chadima 69dd72
+	int	second_zero_knowledge_password_authentication;
Jan F. Chadima 69dd72
+	int	second_hostbased_authentication;
Jan F. Chadima 69dd72
 	int     permit_user_env;	/* If true, read ~/.ssh/environment */
Jan F. Chadima 69dd72
 	int     use_login;	/* If true, login(1) is used */
Jan F. Chadima 69dd72
 	int     compression;	/* If true, compression is allowed */
Jan F. Chadima 69dd72
diff -up openssh-5.9p0/sshd_config.2auth openssh-5.9p0/sshd_config
Jan F. Chadima 69dd72
--- openssh-5.9p0/sshd_config.2auth	2011-05-29 13:39:39.000000000 +0200
Jan F. Chadima 69dd72
+++ openssh-5.9p0/sshd_config	2011-09-05 13:16:01.461565750 +0200
Jan F. Chadima 69dd72
@@ -87,6 +87,13 @@ AuthorizedKeysFile	.ssh/authorized_keys
Jan F. Chadima 69dd72
 # and ChallengeResponseAuthentication to 'no'.
Jan F. Chadima 69dd72
 #UsePAM no
Jan F. Chadima 69dd72
 
Jan F. Chadima 69dd72
+#TwoFactorAuthentication no
Jan F. Chadima 69dd72
+#SecondPubkeyAuthentication yes
Jan F. Chadima 69dd72
+#SecondHostbasedAuthentication no
Jan F. Chadima 69dd72
+#SecondPasswordAuthentication yes
Jan F. Chadima 69dd72
+#SecondChallengeResponseAuthentication yes
Jan F. Chadima 69dd72
+#SecondGSSAPIAuthentication no
Jan F. Chadima 69dd72
+
Jan F. Chadima 69dd72
 #AllowAgentForwarding yes
Jan F. Chadima 69dd72
 #AllowTcpForwarding yes
Jan F. Chadima 69dd72
 #GatewayPorts no
Jan F. Chadima 69dd72
diff -up openssh-5.9p0/sshd_config.5.2auth openssh-5.9p0/sshd_config.5
Jan F. Chadima 69dd72
--- openssh-5.9p0/sshd_config.5.2auth	2011-08-05 22:17:33.000000000 +0200
Jan F. Chadima 69dd72
+++ openssh-5.9p0/sshd_config.5	2011-09-05 13:16:01.572564496 +0200
Jan F. Chadima 69dd72
@@ -726,6 +726,12 @@ Available keywords are
Jan F. Chadima 69dd72
 .Cm PubkeyAuthentication ,
Jan F. Chadima 69dd72
 .Cm RhostsRSAAuthentication ,
Jan F. Chadima 69dd72
 .Cm RSAAuthentication ,
Jan F. Chadima 69dd72
+.Cm SecondGSSAPIAuthentication ,
Jan F. Chadima 69dd72
+.Cm SecondHostbasedAuthentication ,
Jan F. Chadima 69dd72
+.Cm SecondKbdInteractiveAuthentication ,
Jan F. Chadima 69dd72
+.Cm SecondPasswordAuthentication ,
Jan F. Chadima 69dd72
+.Cm SecondPubkeyAuthentication ,
Jan F. Chadima 69dd72
+.Cm TwoFactorAuthentication ,
Jan F. Chadima 69dd72
 .Cm X11DisplayOffset ,
Jan F. Chadima 69dd72
 .Cm X11Forwarding
Jan F. Chadima 69dd72
 and
Jan F. Chadima 69dd72
@@ -931,6 +937,41 @@ Specifies whether pure RSA authenticatio
Jan F. Chadima 69dd72
 The default is
Jan F. Chadima 69dd72
 .Dq yes .
Jan F. Chadima 69dd72
 This option applies to protocol version 1 only.
Jan F. Chadima 69dd72
+.It Cm SecondGSSAPIAuthentication
Jan F. Chadima 69dd72
+Specifies whether the
Jan F. Chadima 69dd72
+.Cm GSSAPIAuthentication
Jan F. Chadima 69dd72
+may be used on the second authentication while
Jan F. Chadima 69dd72
+.Cm TwoFactorAuthentication
Jan F. Chadima 69dd72
+is set.
Jan F. Chadima 69dd72
+The argument must be “yes” or “no”.  The default is “no”.
Jan F. Chadima 69dd72
+.It Cm SecondHostbasedAuthentication
Jan F. Chadima 69dd72
+Specifies whether the
Jan F. Chadima 69dd72
+.Cm HostbasedAuthentication
Jan F. Chadima 69dd72
+may be used on the second authentication while
Jan F. Chadima 69dd72
+.Cm TwoFactorAuthentication
Jan F. Chadima 69dd72
+is set.
Jan F. Chadima 69dd72
+The argument must be “yes” or “no”.  The default is “no”.
Jan F. Chadima 69dd72
+.It Cm SecondKbdInteractiveAuthentication
Jan F. Chadima 69dd72
+Specifies whether the
Jan F. Chadima 69dd72
+.Cm KbdInteractiveAuthentication
Jan F. Chadima 69dd72
+may be used on the second authentication while
Jan F. Chadima 69dd72
+.Cm TwoFactorAuthentication
Jan F. Chadima 69dd72
+is set.
Jan F. Chadima 69dd72
+The argument must be “yes” or “no”.  The default is “no”.
Jan F. Chadima 69dd72
+.It Cm SecondPasswordAuthentication
Jan F. Chadima 69dd72
+Specifies whether the
Jan F. Chadima 69dd72
+.Cm PasswordAuthentication
Jan F. Chadima 69dd72
+may be used on the second authentication while
Jan F. Chadima 69dd72
+.Cm TwoFactorAuthentication
Jan F. Chadima 69dd72
+is set.
Jan F. Chadima 69dd72
+The argument must be “yes” or “no”.  The default is “yes”.
Jan F. Chadima 69dd72
+.It Cm SecondPubkeyAuthentication 
Jan F. Chadima 69dd72
+Specifies whether the
Jan F. Chadima 69dd72
+.Cm PubkeyAuthentication
Jan F. Chadima 69dd72
+may be used on the second authentication while
Jan F. Chadima 69dd72
+.Cm TwoFactorAuthentication
Jan F. Chadima 69dd72
+is set.
Jan F. Chadima 69dd72
+The argument must be “yes” or “no”.  The default is “yes”.
Jan F. Chadima 69dd72
 .It Cm ServerKeyBits
Jan F. Chadima 69dd72
 Defines the number of bits in the ephemeral protocol version 1 server key.
Jan F. Chadima 69dd72
 The minimum value is 512, and the default is 1024.
Jan F. Chadima 69dd72
@@ -1011,6 +1052,22 @@ For more details on certificates, see th
Jan F. Chadima 69dd72
 .Sx CERTIFICATES
Jan F. Chadima 69dd72
 section in
Jan F. Chadima 69dd72
 .Xr ssh-keygen 1 .
Jan F. Chadima 69dd72
+.It Cm TwoFactorAuthentication
Jan F. Chadima 69dd72
+Specifies whether for a successful login is necessary to meet two independent authentications.
Jan F. Chadima 69dd72
+If select the first method is selected from the set of allowed methods from
Jan F. Chadima 69dd72
+.Cm GSSAPIAuthentication ,
Jan F. Chadima 69dd72
+.Cm HostbasedAuthentication ,
Jan F. Chadima 69dd72
+.Cm KbdInteractiveAuthentication ,
Jan F. Chadima 69dd72
+.Cm PasswordAuthentication ,
Jan F. Chadima 69dd72
+.Cm PubkeyAuthentication .
Jan F. Chadima 69dd72
+And the second method is selected from the set of allowed methods from
Jan F. Chadima 69dd72
+.Cm SecondGSSAPIAuthentication ,
Jan F. Chadima 69dd72
+.Cm SecondHostbasedAuthentication ,
Jan F. Chadima 69dd72
+.Cm SecondKbdInteractiveAuthentication ,
Jan F. Chadima 69dd72
+.Cm SecondPasswordAuthentication ,
Jan F. Chadima 69dd72
+.Cm SecondPubkeyAuthentication 
Jan F. Chadima 69dd72
+without the method used for the first authentication.
Jan F. Chadima 69dd72
+The argument must be “yes” or “no”.  The default is “no”.
Jan F. Chadima 69dd72
 .It Cm UseDNS
Jan F. Chadima 69dd72
 Specifies whether
Jan F. Chadima 69dd72
 .Xr sshd 8