07d1ba
diff --color -rup a/monitor.c b/monitor.c
07d1ba
--- a/monitor.c	2022-07-11 15:11:28.146863144 +0200
07d1ba
+++ b/monitor.c	2022-07-11 15:15:35.726655877 +0200
07d1ba
@@ -376,8 +376,15 @@ monitor_child_preauth(struct ssh *ssh, s
07d1ba
 		if (ent->flags & (MON_AUTHDECIDE|MON_ALOG)) {
07d1ba
 			auth_log(ssh, authenticated, partial,
07d1ba
 			    auth_method, auth_submethod);
07d1ba
-			if (!partial && !authenticated)
07d1ba
+			if (!partial && !authenticated) {
07d1ba
+#ifdef GSSAPI
07d1ba
+				/* If gssapi-with-mic failed, MONITOR_REQ_GSSCHECKMIC is disabled.
07d1ba
+				 * We have to reenable it to try again for gssapi-keyex */
07d1ba
+				if (strcmp(auth_method, "gssapi-with-mic") == 0 && options.gss_keyex)
07d1ba
+					monitor_permit(mon_dispatch, MONITOR_REQ_GSSCHECKMIC, 1);
07d1ba
+#endif
07d1ba
 				authctxt->failures++;
07d1ba
+			}
07d1ba
 			if (authenticated || partial) {
07d1ba
 				auth2_update_session_info(authctxt,
07d1ba
 				    auth_method, auth_submethod);