summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--auth2-hostbased.c11
-rw-r--r--auth2-pubkey.c9
-rw-r--r--key.h3
-rw-r--r--monitor.c14
-rw-r--r--readconf.c4
-rw-r--r--servconf.c44
-rw-r--r--servconf.h6
-rw-r--r--sshd_config.528
-rw-r--r--sshkey.c32
-rw-r--r--sshkey.h4
10 files changed, 131 insertions, 24 deletions
diff --git a/auth2-hostbased.c b/auth2-hostbased.c
index 2db3d2524..9f8a01cbe 100644
--- a/auth2-hostbased.c
+++ b/auth2-hostbased.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth2-hostbased.c,v 1.21 2015/01/08 10:14:08 djm Exp $ */ 1/* $OpenBSD: auth2-hostbased.c,v 1.22 2015/01/13 07:39:19 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * 4 *
@@ -48,6 +48,7 @@
48#endif 48#endif
49#include "monitor_wrap.h" 49#include "monitor_wrap.h"
50#include "pathnames.h" 50#include "pathnames.h"
51#include "match.h"
51 52
52/* import */ 53/* import */
53extern ServerOptions options; 54extern ServerOptions options;
@@ -108,6 +109,14 @@ userauth_hostbased(Authctxt *authctxt)
108 "signature format"); 109 "signature format");
109 goto done; 110 goto done;
110 } 111 }
112 if (match_pattern_list(sshkey_ssh_name(key),
113 options.hostbased_key_types,
114 strlen(options.hostbased_key_types), 0) != 1) {
115 logit("%s: key type %s not in HostbasedAcceptedKeyTypes",
116 __func__, sshkey_type(key));
117 goto done;
118 }
119
111 service = datafellows & SSH_BUG_HBSERVICE ? "ssh-userauth" : 120 service = datafellows & SSH_BUG_HBSERVICE ? "ssh-userauth" :
112 authctxt->service; 121 authctxt->service;
113 buffer_init(&b); 122 buffer_init(&b);
diff --git a/auth2-pubkey.c b/auth2-pubkey.c
index 2b0486222..d922eea26 100644
--- a/auth2-pubkey.c
+++ b/auth2-pubkey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: auth2-pubkey.c,v 1.44 2014/12/22 07:51:30 djm Exp $ */ 1/* $OpenBSD: auth2-pubkey.c,v 1.45 2015/01/13 07:39:19 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000 Markus Friedl. All rights reserved.
4 * 4 *
@@ -127,6 +127,13 @@ userauth_pubkey(Authctxt *authctxt)
127 logit("refusing previously-used %s key", key_type(key)); 127 logit("refusing previously-used %s key", key_type(key));
128 goto done; 128 goto done;
129 } 129 }
130 if (match_pattern_list(sshkey_ssh_name(key), options.pubkey_key_types,
131 strlen(options.pubkey_key_types), 0) != 1) {
132 logit("%s: key type %s not in PubkeyAcceptedKeyTypes",
133 __func__, sshkey_ssh_name(key));
134 goto done;
135 }
136
130 if (have_sig) { 137 if (have_sig) {
131 sig = packet_get_string(&slen); 138 sig = packet_get_string(&slen);
132 packet_check_eom(); 139 packet_check_eom();
diff --git a/key.h b/key.h
index 7190b842d..bf884970c 100644
--- a/key.h
+++ b/key.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: key.h,v 1.45 2015/01/08 10:14:08 djm Exp $ */ 1/* $OpenBSD: key.h,v 1.46 2015/01/13 07:39:19 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
@@ -50,7 +50,6 @@ typedef struct sshkey Key;
50#define key_size sshkey_size 50#define key_size sshkey_size
51#define key_ecdsa_bits_to_nid sshkey_ecdsa_bits_to_nid 51#define key_ecdsa_bits_to_nid sshkey_ecdsa_bits_to_nid
52#define key_ecdsa_key_to_nid sshkey_ecdsa_key_to_nid 52#define key_ecdsa_key_to_nid sshkey_ecdsa_key_to_nid
53#define key_names_valid2 sshkey_names_valid2
54#define key_is_cert sshkey_is_cert 53#define key_is_cert sshkey_is_cert
55#define key_type_plain sshkey_type_plain 54#define key_type_plain sshkey_type_plain
56#define key_cert_is_legacy sshkey_cert_is_legacy 55#define key_cert_is_legacy sshkey_cert_is_legacy
diff --git a/monitor.c b/monitor.c
index b830e0374..5a28d1b34 100644
--- a/monitor.c
+++ b/monitor.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: monitor.c,v 1.136 2014/12/22 07:51:30 djm Exp $ */ 1/* $OpenBSD: monitor.c,v 1.137 2015/01/13 07:39:19 djm Exp $ */
2/* 2/*
3 * Copyright 2002 Niels Provos <provos@citi.umich.edu> 3 * Copyright 2002 Niels Provos <provos@citi.umich.edu>
4 * Copyright 2002 Markus Friedl <markus@openbsd.org> 4 * Copyright 2002 Markus Friedl <markus@openbsd.org>
@@ -100,6 +100,7 @@
100#include "ssh2.h" 100#include "ssh2.h"
101#include "roaming.h" 101#include "roaming.h"
102#include "authfd.h" 102#include "authfd.h"
103#include "match.h"
103 104
104#ifdef GSSAPI 105#ifdef GSSAPI
105static Gssctxt *gsscontext = NULL; 106static Gssctxt *gsscontext = NULL;
@@ -1167,10 +1168,18 @@ mm_answer_keyallowed(int sock, Buffer *m)
1167 debug3("%s: key_from_blob: %p", __func__, key); 1168 debug3("%s: key_from_blob: %p", __func__, key);
1168 1169
1169 if (key != NULL && authctxt->valid) { 1170 if (key != NULL && authctxt->valid) {
1171 /* These should not make it past the privsep child */
1172 if (key_type_plain(key->type) == KEY_RSA &&
1173 (datafellows & SSH_BUG_RSASIGMD5) != 0)
1174 fatal("%s: passed a SSH_BUG_RSASIGMD5 key", __func__);
1175
1170 switch (type) { 1176 switch (type) {
1171 case MM_USERKEY: 1177 case MM_USERKEY:
1172 allowed = options.pubkey_authentication && 1178 allowed = options.pubkey_authentication &&
1173 !auth2_userkey_already_used(authctxt, key) && 1179 !auth2_userkey_already_used(authctxt, key) &&
1180 match_pattern_list(sshkey_ssh_name(key),
1181 options.pubkey_key_types,
1182 strlen(options.pubkey_key_types), 0) == 1 &&
1174 user_key_allowed(authctxt->pw, key); 1183 user_key_allowed(authctxt->pw, key);
1175 pubkey_auth_info(authctxt, key, NULL); 1184 pubkey_auth_info(authctxt, key, NULL);
1176 auth_method = "publickey"; 1185 auth_method = "publickey";
@@ -1179,6 +1188,9 @@ mm_answer_keyallowed(int sock, Buffer *m)
1179 break; 1188 break;
1180 case MM_HOSTKEY: 1189 case MM_HOSTKEY:
1181 allowed = options.hostbased_authentication && 1190 allowed = options.hostbased_authentication &&
1191 match_pattern_list(sshkey_ssh_name(key),
1192 options.hostbased_key_types,
1193 strlen(options.hostbased_key_types), 0) == 1 &&
1182 hostbased_key_allowed(authctxt->pw, 1194 hostbased_key_allowed(authctxt->pw,
1183 cuser, chost, key); 1195 cuser, chost, key);
1184 pubkey_auth_info(authctxt, key, 1196 pubkey_auth_info(authctxt, key,
diff --git a/readconf.c b/readconf.c
index f1601af2e..d7f1cf036 100644
--- a/readconf.c
+++ b/readconf.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: readconf.c,v 1.225 2015/01/08 13:44:36 djm Exp $ */ 1/* $OpenBSD: readconf.c,v 1.226 2015/01/13 07:39:19 djm Exp $ */
2/* 2/*
3 * Author: Tatu Ylonen <ylo@cs.hut.fi> 3 * Author: Tatu Ylonen <ylo@cs.hut.fi>
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -1116,7 +1116,7 @@ parse_int:
1116 arg = strdelim(&s); 1116 arg = strdelim(&s);
1117 if (!arg || *arg == '\0') 1117 if (!arg || *arg == '\0')
1118 fatal("%.200s line %d: Missing argument.", filename, linenum); 1118 fatal("%.200s line %d: Missing argument.", filename, linenum);
1119 if (!key_names_valid2(arg)) 1119 if (!sshkey_names_valid2(arg, 1))
1120 fatal("%.200s line %d: Bad protocol 2 host key algorithms '%s'.", 1120 fatal("%.200s line %d: Bad protocol 2 host key algorithms '%s'.",
1121 filename, linenum, arg ? arg : "<NONE>"); 1121 filename, linenum, arg ? arg : "<NONE>");
1122 if (*activep && options->hostkeyalgorithms == NULL) 1122 if (*activep && options->hostkeyalgorithms == NULL)
diff --git a/servconf.c b/servconf.c
index 6eb368661..1b6bdb4af 100644
--- a/servconf.c
+++ b/servconf.c
@@ -1,5 +1,5 @@
1 1
2/* $OpenBSD: servconf.c,v 1.257 2014/12/22 07:55:51 djm Exp $ */ 2/* $OpenBSD: servconf.c,v 1.258 2015/01/13 07:39:19 djm Exp $ */
3/* 3/*
4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland 4 * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
5 * All rights reserved 5 * All rights reserved
@@ -104,8 +104,10 @@ initialize_server_options(ServerOptions *options)
104 options->rhosts_rsa_authentication = -1; 104 options->rhosts_rsa_authentication = -1;
105 options->hostbased_authentication = -1; 105 options->hostbased_authentication = -1;
106 options->hostbased_uses_name_from_packet_only = -1; 106 options->hostbased_uses_name_from_packet_only = -1;
107 options->hostbased_key_types = NULL;
107 options->rsa_authentication = -1; 108 options->rsa_authentication = -1;
108 options->pubkey_authentication = -1; 109 options->pubkey_authentication = -1;
110 options->pubkey_key_types = NULL;
109 options->kerberos_authentication = -1; 111 options->kerberos_authentication = -1;
110 options->kerberos_or_local_passwd = -1; 112 options->kerberos_or_local_passwd = -1;
111 options->kerberos_ticket_cleanup = -1; 113 options->kerberos_ticket_cleanup = -1;
@@ -248,10 +250,14 @@ fill_default_server_options(ServerOptions *options)
248 options->hostbased_authentication = 0; 250 options->hostbased_authentication = 0;
249 if (options->hostbased_uses_name_from_packet_only == -1) 251 if (options->hostbased_uses_name_from_packet_only == -1)
250 options->hostbased_uses_name_from_packet_only = 0; 252 options->hostbased_uses_name_from_packet_only = 0;
253 if (options->hostbased_key_types == NULL)
254 options->hostbased_key_types = xstrdup("*");
251 if (options->rsa_authentication == -1) 255 if (options->rsa_authentication == -1)
252 options->rsa_authentication = 1; 256 options->rsa_authentication = 1;
253 if (options->pubkey_authentication == -1) 257 if (options->pubkey_authentication == -1)
254 options->pubkey_authentication = 1; 258 options->pubkey_authentication = 1;
259 if (options->pubkey_key_types == NULL)
260 options->pubkey_key_types = xstrdup("*");
255 if (options->kerberos_authentication == -1) 261 if (options->kerberos_authentication == -1)
256 options->kerberos_authentication = 0; 262 options->kerberos_authentication = 0;
257 if (options->kerberos_or_local_passwd == -1) 263 if (options->kerberos_or_local_passwd == -1)
@@ -365,8 +371,8 @@ typedef enum {
365 /* Portable-specific options */ 371 /* Portable-specific options */
366 sUsePAM, 372 sUsePAM,
367 /* Standard Options */ 373 /* Standard Options */
368 sPort, sHostKeyFile, sServerKeyBits, sLoginGraceTime, sKeyRegenerationTime, 374 sPort, sHostKeyFile, sServerKeyBits, sLoginGraceTime,
369 sPermitRootLogin, sLogFacility, sLogLevel, 375 sKeyRegenerationTime, sPermitRootLogin, sLogFacility, sLogLevel,
370 sRhostsRSAAuthentication, sRSAAuthentication, 376 sRhostsRSAAuthentication, sRSAAuthentication,
371 sKerberosAuthentication, sKerberosOrLocalPasswd, sKerberosTicketCleanup, 377 sKerberosAuthentication, sKerberosOrLocalPasswd, sKerberosTicketCleanup,
372 sKerberosGetAFSToken, 378 sKerberosGetAFSToken,
@@ -379,11 +385,11 @@ typedef enum {
379 sPermitUserEnvironment, sUseLogin, sAllowTcpForwarding, sCompression, 385 sPermitUserEnvironment, sUseLogin, sAllowTcpForwarding, sCompression,
380 sRekeyLimit, sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups, 386 sRekeyLimit, sAllowUsers, sDenyUsers, sAllowGroups, sDenyGroups,
381 sIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile, 387 sIgnoreUserKnownHosts, sCiphers, sMacs, sProtocol, sPidFile,
382 sGatewayPorts, sPubkeyAuthentication, sXAuthLocation, sSubsystem, 388 sGatewayPorts, sPubkeyAuthentication, sPubkeyAcceptedKeyTypes,
383 sMaxStartups, sMaxAuthTries, sMaxSessions, 389 sXAuthLocation, sSubsystem, sMaxStartups, sMaxAuthTries, sMaxSessions,
384 sBanner, sUseDNS, sHostbasedAuthentication, 390 sBanner, sUseDNS, sHostbasedAuthentication,
385 sHostbasedUsesNameFromPacketOnly, sClientAliveInterval, 391 sHostbasedUsesNameFromPacketOnly, sHostbasedAcceptedKeyTypes,
386 sClientAliveCountMax, sAuthorizedKeysFile, 392 sClientAliveInterval, sClientAliveCountMax, sAuthorizedKeysFile,
387 sGssAuthentication, sGssCleanupCreds, sAcceptEnv, sPermitTunnel, 393 sGssAuthentication, sGssCleanupCreds, sAcceptEnv, sPermitTunnel,
388 sMatch, sPermitOpen, sForceCommand, sChrootDirectory, 394 sMatch, sPermitOpen, sForceCommand, sChrootDirectory,
389 sUsePrivilegeSeparation, sAllowAgentForwarding, 395 sUsePrivilegeSeparation, sAllowAgentForwarding,
@@ -430,8 +436,10 @@ static struct {
430 { "rhostsrsaauthentication", sRhostsRSAAuthentication, SSHCFG_ALL }, 436 { "rhostsrsaauthentication", sRhostsRSAAuthentication, SSHCFG_ALL },
431 { "hostbasedauthentication", sHostbasedAuthentication, SSHCFG_ALL }, 437 { "hostbasedauthentication", sHostbasedAuthentication, SSHCFG_ALL },
432 { "hostbasedusesnamefrompacketonly", sHostbasedUsesNameFromPacketOnly, SSHCFG_ALL }, 438 { "hostbasedusesnamefrompacketonly", sHostbasedUsesNameFromPacketOnly, SSHCFG_ALL },
439 { "hostbasedacceptedkeytypes", sHostbasedAcceptedKeyTypes, SSHCFG_ALL },
433 { "rsaauthentication", sRSAAuthentication, SSHCFG_ALL }, 440 { "rsaauthentication", sRSAAuthentication, SSHCFG_ALL },
434 { "pubkeyauthentication", sPubkeyAuthentication, SSHCFG_ALL }, 441 { "pubkeyauthentication", sPubkeyAuthentication, SSHCFG_ALL },
442 { "pubkeyacceptedkeytypes", sPubkeyAcceptedKeyTypes, SSHCFG_ALL },
435 { "dsaauthentication", sPubkeyAuthentication, SSHCFG_GLOBAL }, /* alias */ 443 { "dsaauthentication", sPubkeyAuthentication, SSHCFG_GLOBAL }, /* alias */
436#ifdef KRB5 444#ifdef KRB5
437 { "kerberosauthentication", sKerberosAuthentication, SSHCFG_ALL }, 445 { "kerberosauthentication", sKerberosAuthentication, SSHCFG_ALL },
@@ -1111,6 +1119,20 @@ process_server_config_line(ServerOptions *options, char *line,
1111 intptr = &options->hostbased_uses_name_from_packet_only; 1119 intptr = &options->hostbased_uses_name_from_packet_only;
1112 goto parse_flag; 1120 goto parse_flag;
1113 1121
1122 case sHostbasedAcceptedKeyTypes:
1123 charptr = &options->hostbased_key_types;
1124 parse_keytypes:
1125 arg = strdelim(&cp);
1126 if (!arg || *arg == '\0')
1127 fatal("%s line %d: Missing argument.",
1128 filename, linenum);
1129 if (!sshkey_names_valid2(arg, 1))
1130 fatal("%s line %d: Bad key types '%s'.",
1131 filename, linenum, arg ? arg : "<NONE>");
1132 if (*activep && *charptr == NULL)
1133 *charptr = xstrdup(arg);
1134 break;
1135
1114 case sRSAAuthentication: 1136 case sRSAAuthentication:
1115 intptr = &options->rsa_authentication; 1137 intptr = &options->rsa_authentication;
1116 goto parse_flag; 1138 goto parse_flag;
@@ -1119,6 +1141,10 @@ process_server_config_line(ServerOptions *options, char *line,
1119 intptr = &options->pubkey_authentication; 1141 intptr = &options->pubkey_authentication;
1120 goto parse_flag; 1142 goto parse_flag;
1121 1143
1144 case sPubkeyAcceptedKeyTypes:
1145 charptr = &options->pubkey_key_types;
1146 goto parse_keytypes;
1147
1122 case sKerberosAuthentication: 1148 case sKerberosAuthentication:
1123 intptr = &options->kerberos_authentication; 1149 intptr = &options->kerberos_authentication;
1124 goto parse_flag; 1150 goto parse_flag;
@@ -2142,6 +2168,10 @@ dump_config(ServerOptions *o)
2142 dump_cfg_string(sHostKeyAgent, o->host_key_agent); 2168 dump_cfg_string(sHostKeyAgent, o->host_key_agent);
2143 dump_cfg_string(sKexAlgorithms, 2169 dump_cfg_string(sKexAlgorithms,
2144 o->kex_algorithms ? o->kex_algorithms : KEX_SERVER_KEX); 2170 o->kex_algorithms ? o->kex_algorithms : KEX_SERVER_KEX);
2171 dump_cfg_string(sHostbasedAcceptedKeyTypes, o->hostbased_key_types ?
2172 o->hostbased_key_types : KEX_DEFAULT_PK_ALG);
2173 dump_cfg_string(sPubkeyAcceptedKeyTypes, o->pubkey_key_types ?
2174 o->pubkey_key_types : KEX_DEFAULT_PK_ALG);
2145 2175
2146 /* string arguments requiring a lookup */ 2176 /* string arguments requiring a lookup */
2147 dump_cfg_string(sLogLevel, log_level_name(o->log_level)); 2177 dump_cfg_string(sLogLevel, log_level_name(o->log_level));
diff --git a/servconf.h b/servconf.h
index 49b228bdf..9922f0c8c 100644
--- a/servconf.h
+++ b/servconf.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: servconf.h,v 1.115 2014/12/21 22:27:56 djm Exp $ */ 1/* $OpenBSD: servconf.h,v 1.116 2015/01/13 07:39:19 djm Exp $ */
2 2
3/* 3/*
4 * Author: Tatu Ylonen <ylo@cs.hut.fi> 4 * Author: Tatu Ylonen <ylo@cs.hut.fi>
@@ -99,8 +99,10 @@ typedef struct {
99 * authentication. */ 99 * authentication. */
100 int hostbased_authentication; /* If true, permit ssh2 hostbased auth */ 100 int hostbased_authentication; /* If true, permit ssh2 hostbased auth */
101 int hostbased_uses_name_from_packet_only; /* experimental */ 101 int hostbased_uses_name_from_packet_only; /* experimental */
102 char *hostbased_key_types; /* Key types allowed for hostbased */
102 int rsa_authentication; /* If true, permit RSA authentication. */ 103 int rsa_authentication; /* If true, permit RSA authentication. */
103 int pubkey_authentication; /* If true, permit ssh2 pubkey authentication. */ 104 int pubkey_authentication; /* If true, permit ssh2 pubkey authentication. */
105 char *pubkey_key_types; /* Key types allowed for public key */
104 int kerberos_authentication; /* If true, permit Kerberos 106 int kerberos_authentication; /* If true, permit Kerberos
105 * authentication. */ 107 * authentication. */
106 int kerberos_or_local_passwd; /* If true, permit kerberos 108 int kerberos_or_local_passwd; /* If true, permit kerberos
@@ -215,6 +217,8 @@ struct connection_info {
215 M_CP_STROPT(authorized_principals_file); \ 217 M_CP_STROPT(authorized_principals_file); \
216 M_CP_STROPT(authorized_keys_command); \ 218 M_CP_STROPT(authorized_keys_command); \
217 M_CP_STROPT(authorized_keys_command_user); \ 219 M_CP_STROPT(authorized_keys_command_user); \
220 M_CP_STROPT(hostbased_key_types); \
221 M_CP_STROPT(pubkey_key_types); \
218 M_CP_STRARRAYOPT(authorized_keys_files, num_authkeys_files); \ 222 M_CP_STRARRAYOPT(authorized_keys_files, num_authkeys_files); \
219 M_CP_STRARRAYOPT(allow_users, num_allow_users); \ 223 M_CP_STRARRAYOPT(allow_users, num_allow_users); \
220 M_CP_STRARRAYOPT(deny_users, num_deny_users); \ 224 M_CP_STRARRAYOPT(deny_users, num_deny_users); \
diff --git a/sshd_config.5 b/sshd_config.5
index cec2a023a..88fe90193 100644
--- a/sshd_config.5
+++ b/sshd_config.5
@@ -33,8 +33,8 @@
33.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 33.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35.\" 35.\"
36.\" $OpenBSD: sshd_config.5,v 1.188 2014/12/22 09:05:17 djm Exp $ 36.\" $OpenBSD: sshd_config.5,v 1.189 2015/01/13 07:39:19 djm Exp $
37.Dd $Mdocdate: December 22 2014 $ 37.Dd $Mdocdate: January 13 2015 $
38.Dt SSHD_CONFIG 5 38.Dt SSHD_CONFIG 5
39.Os 39.Os
40.Sh NAME 40.Sh NAME
@@ -561,6 +561,17 @@ on logout.
561The default is 561The default is
562.Dq yes . 562.Dq yes .
563Note that this option applies to protocol version 2 only. 563Note that this option applies to protocol version 2 only.
564.It Cm HostbasedAcceptedKeyTypes
565Specifies the key types that will be accepted for hostbased authentication
566as a comma-separated pattern list.
567The default
568.Dq *
569will allow all key types.
570The
571.Fl Q
572option of
573.Xr ssh 1
574may be used to list supported key types.
564.It Cm HostbasedAuthentication 575.It Cm HostbasedAuthentication
565Specifies whether rhosts or /etc/hosts.equiv authentication together 576Specifies whether rhosts or /etc/hosts.equiv authentication together
566with successful public key client host authentication is allowed 577with successful public key client host authentication is allowed
@@ -962,6 +973,7 @@ Available keywords are
962.Cm ForceCommand , 973.Cm ForceCommand ,
963.Cm GatewayPorts , 974.Cm GatewayPorts ,
964.Cm GSSAPIAuthentication , 975.Cm GSSAPIAuthentication ,
976.Cm HostbasedAcceptedKeyTypes ,
965.Cm HostbasedAuthentication , 977.Cm HostbasedAuthentication ,
966.Cm HostbasedUsesNameFromPacketOnly , 978.Cm HostbasedUsesNameFromPacketOnly ,
967.Cm KbdInteractiveAuthentication , 979.Cm KbdInteractiveAuthentication ,
@@ -975,6 +987,7 @@ Available keywords are
975.Cm PermitTTY , 987.Cm PermitTTY ,
976.Cm PermitTunnel , 988.Cm PermitTunnel ,
977.Cm PermitUserRC , 989.Cm PermitUserRC ,
990.Cm PubkeyAcceptedKeyTypes ,
978.Cm PubkeyAuthentication , 991.Cm PubkeyAuthentication ,
979.Cm RekeyLimit , 992.Cm RekeyLimit ,
980.Cm RhostsRSAAuthentication , 993.Cm RhostsRSAAuthentication ,
@@ -1182,6 +1195,17 @@ Specifying
1182.Dq 2,1 1195.Dq 2,1
1183is identical to 1196is identical to
1184.Dq 1,2 . 1197.Dq 1,2 .
1198.It Cm PubkeyAcceptedKeyTypes
1199Specifies the key types that will be accepted for public key authentication
1200as a comma-separated pattern list.
1201The default
1202.Dq *
1203will allow all key types.
1204The
1205.Fl Q
1206option of
1207.Xr ssh 1
1208may be used to list supported key types.
1185.It Cm PubkeyAuthentication 1209.It Cm PubkeyAuthentication
1186Specifies whether public key authentication is allowed. 1210Specifies whether public key authentication is allowed.
1187The default is 1211The default is
diff --git a/sshkey.c b/sshkey.c
index a680929fa..30f209a25 100644
--- a/sshkey.c
+++ b/sshkey.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshkey.c,v 1.10 2015/01/12 20:13:27 markus Exp $ */ 1/* $OpenBSD: sshkey.c,v 1.11 2015/01/13 07:39:19 djm Exp $ */
2/* 2/*
3 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 3 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
4 * Copyright (c) 2008 Alexander von Gernler. All rights reserved. 4 * Copyright (c) 2008 Alexander von Gernler. All rights reserved.
@@ -54,6 +54,7 @@
54#include "digest.h" 54#include "digest.h"
55#define SSHKEY_INTERNAL 55#define SSHKEY_INTERNAL
56#include "sshkey.h" 56#include "sshkey.h"
57#include "match.h"
57 58
58/* openssh private key file format */ 59/* openssh private key file format */
59#define MARK_BEGIN "-----BEGIN OPENSSH PRIVATE KEY-----\n" 60#define MARK_BEGIN "-----BEGIN OPENSSH PRIVATE KEY-----\n"
@@ -219,9 +220,11 @@ key_alg_list(int certs_only, int plain_only)
219} 220}
220 221
221int 222int
222sshkey_names_valid2(const char *names) 223sshkey_names_valid2(const char *names, int allow_wildcard)
223{ 224{
224 char *s, *cp, *p; 225 char *s, *cp, *p;
226 const struct keytype *kt;
227 int type;
225 228
226 if (names == NULL || strcmp(names, "") == 0) 229 if (names == NULL || strcmp(names, "") == 0)
227 return 0; 230 return 0;
@@ -229,9 +232,28 @@ sshkey_names_valid2(const char *names)
229 return 0; 232 return 0;
230 for ((p = strsep(&cp, ",")); p && *p != '\0'; 233 for ((p = strsep(&cp, ",")); p && *p != '\0';
231 (p = strsep(&cp, ","))) { 234 (p = strsep(&cp, ","))) {
232 switch (sshkey_type_from_name(p)) { 235 type = sshkey_type_from_name(p);
233 case KEY_RSA1: 236 if (type == KEY_RSA1) {
234 case KEY_UNSPEC: 237 free(s);
238 return 0;
239 }
240 if (type == KEY_UNSPEC) {
241 if (allow_wildcard) {
242 /*
243 * Try matching key types against the string.
244 * If any has a positive or negative match then
245 * the component is accepted.
246 */
247 for (kt = keytypes; kt->type != -1; kt++) {
248 if (kt->type == KEY_RSA1)
249 continue;
250 if (match_pattern_list(kt->name,
251 p, strlen(p), 0) != 0)
252 break;
253 }
254 if (kt->type != -1)
255 continue;
256 }
235 free(s); 257 free(s);
236 return 0; 258 return 0;
237 } 259 }
diff --git a/sshkey.h b/sshkey.h
index 65194d6e4..7217f8875 100644
--- a/sshkey.h
+++ b/sshkey.h
@@ -1,4 +1,4 @@
1/* $OpenBSD: sshkey.h,v 1.3 2015/01/08 10:14:08 djm Exp $ */ 1/* $OpenBSD: sshkey.h,v 1.4 2015/01/13 07:39:19 djm Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved. 4 * Copyright (c) 2000, 2001 Markus Friedl. All rights reserved.
@@ -156,7 +156,7 @@ int sshkey_ec_validate_public(const EC_GROUP *, const EC_POINT *);
156int sshkey_ec_validate_private(const EC_KEY *); 156int sshkey_ec_validate_private(const EC_KEY *);
157const char *sshkey_ssh_name(const struct sshkey *); 157const char *sshkey_ssh_name(const struct sshkey *);
158const char *sshkey_ssh_name_plain(const struct sshkey *); 158const char *sshkey_ssh_name_plain(const struct sshkey *);
159int sshkey_names_valid2(const char *); 159int sshkey_names_valid2(const char *, int);
160char *key_alg_list(int, int); 160char *key_alg_list(int, int);
161 161
162int sshkey_from_blob(const u_char *, size_t, struct sshkey **); 162int sshkey_from_blob(const u_char *, size_t, struct sshkey **);