blob: 6a23fe300bf78b071b636f0c1ec8b13f44ea6f30 [file] [log] [blame]
djm@openbsd.orgdd369322017-04-30 23:34:55 +00001# $OpenBSD: cert-userkey.sh,v 1.18 2017/04/30 23:34:55 djm Exp $
Damien Miller58ac6de2010-02-27 07:57:12 +11002# Placed in the Public Domain.
3
4tid="certified user keys"
5
6rm -f $OBJ/authorized_keys_$USER $OBJ/user_ca_key* $OBJ/cert_user_key*
7cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
markus@openbsd.org5bf09332015-07-10 06:23:25 +00008cp $OBJ/ssh_proxy $OBJ/ssh_proxy_bak
Damien Miller58ac6de2010-02-27 07:57:12 +11009
Damien Millerf54542a2013-12-07 16:32:44 +110010PLAIN_TYPES=`$SSH -Q key-plain | sed 's/^ssh-dss/ssh-dsa/;s/^ssh-//'`
11
djm@openbsd.org67f14592016-05-02 09:52:00 +000012if echo "$PLAIN_TYPES" | grep '^rsa$' >/dev/null 2>&1 ; then
13 PLAIN_TYPES="$PLAIN_TYPES rsa-sha2-256 rsa-sha2-512"
14fi
15
markus@openbsd.org5bf09332015-07-10 06:23:25 +000016kname() {
djm@openbsd.org67f14592016-05-02 09:52:00 +000017 case $ktype in
18 rsa-sha2-*) ;;
dtucker@openbsd.orgcca3b432016-05-03 12:15:49 +000019 # subshell because some seds will add a newline
20 *) n=$(echo $1 | sed 's/^dsa/ssh-dss/;s/^rsa/ssh-rsa/;s/^ed/ssh-ed/') ;;
djm@openbsd.org67f14592016-05-02 09:52:00 +000021 esac
dtucker@openbsd.orgcca3b432016-05-03 12:15:49 +000022 echo "$n*,ssh-rsa*,ssh-ed25519*"
markus@openbsd.org5bf09332015-07-10 06:23:25 +000023}
24
Damien Miller700dcfa2010-03-04 21:58:01 +110025# Create a CA key
Damien Miller58ac6de2010-02-27 07:57:12 +110026${SSHKEYGEN} -q -N '' -t rsa -f $OBJ/user_ca_key ||\
27 fail "ssh-keygen of user_ca_key failed"
Damien Miller58ac6de2010-02-27 07:57:12 +110028
29# Generate and sign user keys
djm@openbsd.org67f14592016-05-02 09:52:00 +000030for ktype in $PLAIN_TYPES $EXTRA_TYPES ; do
Damien Miller58ac6de2010-02-27 07:57:12 +110031 verbose "$tid: sign user ${ktype} cert"
32 ${SSHKEYGEN} -q -N '' -t ${ktype} \
33 -f $OBJ/cert_user_key_${ktype} || \
djm@openbsd.org67f14592016-05-02 09:52:00 +000034 fatal "ssh-keygen of cert_user_key_${ktype} failed"
35 # Generate RSA/SHA2 certs for rsa-sha2* keys.
36 case $ktype in
37 rsa-sha2-*) tflag="-t $ktype" ;;
38 *) tflag="" ;;
39 esac
40 ${SSHKEYGEN} -q -s $OBJ/user_ca_key -z $$ \
41 -I "regress user key for $USER" \
42 -n ${USER},mekmitasdigoat $tflag $OBJ/cert_user_key_${ktype} || \
43 fatal "couldn't sign cert_user_key_${ktype}"
Damien Miller58ac6de2010-02-27 07:57:12 +110044done
45
Damien Miller3bcce802010-05-21 14:48:16 +100046# Test explicitly-specified principals
djm@openbsd.org67f14592016-05-02 09:52:00 +000047for ktype in $EXTRA_TYPES $PLAIN_TYPES ; do
markus@openbsd.org5bf09332015-07-10 06:23:25 +000048 t=$(kname $ktype)
Damien Miller3bcce802010-05-21 14:48:16 +100049 for privsep in yes no ; do
50 _prefix="${ktype} privsep $privsep"
51
52 # Setup for AuthorizedPrincipalsFile
53 rm -f $OBJ/authorized_keys_$USER
54 (
55 cat $OBJ/sshd_proxy_bak
56 echo "UsePrivilegeSeparation $privsep"
57 echo "AuthorizedPrincipalsFile " \
58 "$OBJ/authorized_principals_%u"
59 echo "TrustedUserCAKeys $OBJ/user_ca_key.pub"
markus@openbsd.org5bf09332015-07-10 06:23:25 +000060 echo "PubkeyAcceptedKeyTypes ${t}"
Damien Miller3bcce802010-05-21 14:48:16 +100061 ) > $OBJ/sshd_proxy
markus@openbsd.org5bf09332015-07-10 06:23:25 +000062 (
63 cat $OBJ/ssh_proxy_bak
64 echo "PubkeyAcceptedKeyTypes ${t}"
65 ) > $OBJ/ssh_proxy
Damien Miller3bcce802010-05-21 14:48:16 +100066
67 # Missing authorized_principals
68 verbose "$tid: ${_prefix} missing authorized_principals"
69 rm -f $OBJ/authorized_principals_$USER
djm@openbsd.orgdd369322017-04-30 23:34:55 +000070 ${SSH} -i $OBJ/cert_user_key_${ktype} \
Damien Miller3bcce802010-05-21 14:48:16 +100071 -F $OBJ/ssh_proxy somehost true >/dev/null 2>&1
72 if [ $? -eq 0 ]; then
73 fail "ssh cert connect succeeded unexpectedly"
74 fi
75
76 # Empty authorized_principals
77 verbose "$tid: ${_prefix} empty authorized_principals"
78 echo > $OBJ/authorized_principals_$USER
djm@openbsd.orgdd369322017-04-30 23:34:55 +000079 ${SSH} -i $OBJ/cert_user_key_${ktype} \
Damien Miller3bcce802010-05-21 14:48:16 +100080 -F $OBJ/ssh_proxy somehost true >/dev/null 2>&1
81 if [ $? -eq 0 ]; then
82 fail "ssh cert connect succeeded unexpectedly"
83 fi
djm@openbsd.org67f14592016-05-02 09:52:00 +000084
Damien Miller3bcce802010-05-21 14:48:16 +100085 # Wrong authorized_principals
86 verbose "$tid: ${_prefix} wrong authorized_principals"
87 echo gregorsamsa > $OBJ/authorized_principals_$USER
djm@openbsd.orgdd369322017-04-30 23:34:55 +000088 ${SSH} -i $OBJ/cert_user_key_${ktype} \
Damien Miller3bcce802010-05-21 14:48:16 +100089 -F $OBJ/ssh_proxy somehost true >/dev/null 2>&1
90 if [ $? -eq 0 ]; then
91 fail "ssh cert connect succeeded unexpectedly"
92 fi
93
94 # Correct authorized_principals
95 verbose "$tid: ${_prefix} correct authorized_principals"
96 echo mekmitasdigoat > $OBJ/authorized_principals_$USER
djm@openbsd.orgdd369322017-04-30 23:34:55 +000097 ${SSH} -i $OBJ/cert_user_key_${ktype} \
Damien Miller3bcce802010-05-21 14:48:16 +100098 -F $OBJ/ssh_proxy somehost true >/dev/null 2>&1
99 if [ $? -ne 0 ]; then
100 fail "ssh cert connect failed"
101 fi
102
Damien Millerab139cd2010-07-02 13:42:18 +1000103 # authorized_principals with bad key option
104 verbose "$tid: ${_prefix} authorized_principals bad key opt"
105 echo 'blah mekmitasdigoat' > $OBJ/authorized_principals_$USER
djm@openbsd.orgdd369322017-04-30 23:34:55 +0000106 ${SSH} -i $OBJ/cert_user_key_${ktype} \
Damien Millerab139cd2010-07-02 13:42:18 +1000107 -F $OBJ/ssh_proxy somehost true >/dev/null 2>&1
108 if [ $? -eq 0 ]; then
109 fail "ssh cert connect succeeded unexpectedly"
110 fi
111
112 # authorized_principals with command=false
113 verbose "$tid: ${_prefix} authorized_principals command=false"
114 echo 'command="false" mekmitasdigoat' > \
115 $OBJ/authorized_principals_$USER
djm@openbsd.orgdd369322017-04-30 23:34:55 +0000116 ${SSH} -i $OBJ/cert_user_key_${ktype} \
Damien Millerab139cd2010-07-02 13:42:18 +1000117 -F $OBJ/ssh_proxy somehost true >/dev/null 2>&1
118 if [ $? -eq 0 ]; then
119 fail "ssh cert connect succeeded unexpectedly"
120 fi
121
122
123 # authorized_principals with command=true
124 verbose "$tid: ${_prefix} authorized_principals command=true"
125 echo 'command="true" mekmitasdigoat' > \
126 $OBJ/authorized_principals_$USER
djm@openbsd.orgdd369322017-04-30 23:34:55 +0000127 ${SSH} -i $OBJ/cert_user_key_${ktype} \
Damien Millerab139cd2010-07-02 13:42:18 +1000128 -F $OBJ/ssh_proxy somehost false >/dev/null 2>&1
129 if [ $? -ne 0 ]; then
130 fail "ssh cert connect failed"
131 fi
132
Damien Miller3bcce802010-05-21 14:48:16 +1000133 # Setup for principals= key option
134 rm -f $OBJ/authorized_principals_$USER
135 (
136 cat $OBJ/sshd_proxy_bak
137 echo "UsePrivilegeSeparation $privsep"
markus@openbsd.org5bf09332015-07-10 06:23:25 +0000138 echo "PubkeyAcceptedKeyTypes ${t}"
Damien Miller3bcce802010-05-21 14:48:16 +1000139 ) > $OBJ/sshd_proxy
markus@openbsd.org5bf09332015-07-10 06:23:25 +0000140 (
141 cat $OBJ/ssh_proxy_bak
142 echo "PubkeyAcceptedKeyTypes ${t}"
143 ) > $OBJ/ssh_proxy
Damien Miller3bcce802010-05-21 14:48:16 +1000144
145 # Wrong principals list
146 verbose "$tid: ${_prefix} wrong principals key option"
147 (
Darren Tucker56347ef2013-05-17 13:28:36 +1000148 printf 'cert-authority,principals="gregorsamsa" '
Damien Miller3bcce802010-05-21 14:48:16 +1000149 cat $OBJ/user_ca_key.pub
150 ) > $OBJ/authorized_keys_$USER
djm@openbsd.orgdd369322017-04-30 23:34:55 +0000151 ${SSH} -i $OBJ/cert_user_key_${ktype} \
Damien Miller3bcce802010-05-21 14:48:16 +1000152 -F $OBJ/ssh_proxy somehost true >/dev/null 2>&1
153 if [ $? -eq 0 ]; then
154 fail "ssh cert connect succeeded unexpectedly"
155 fi
156
157 # Correct principals list
158 verbose "$tid: ${_prefix} correct principals key option"
159 (
Darren Tucker56347ef2013-05-17 13:28:36 +1000160 printf 'cert-authority,principals="mekmitasdigoat" '
Damien Miller3bcce802010-05-21 14:48:16 +1000161 cat $OBJ/user_ca_key.pub
162 ) > $OBJ/authorized_keys_$USER
djm@openbsd.orgdd369322017-04-30 23:34:55 +0000163 ${SSH} -i $OBJ/cert_user_key_${ktype} \
Damien Miller3bcce802010-05-21 14:48:16 +1000164 -F $OBJ/ssh_proxy somehost true >/dev/null 2>&1
165 if [ $? -ne 0 ]; then
166 fail "ssh cert connect failed"
167 fi
168 done
169done
170
Damien Miller700dcfa2010-03-04 21:58:01 +1100171basic_tests() {
172 auth=$1
173 if test "x$auth" = "xauthorized_keys" ; then
174 # Add CA to authorized_keys
175 (
Darren Tucker56347ef2013-05-17 13:28:36 +1000176 printf 'cert-authority '
Damien Miller700dcfa2010-03-04 21:58:01 +1100177 cat $OBJ/user_ca_key.pub
178 ) > $OBJ/authorized_keys_$USER
179 else
180 echo > $OBJ/authorized_keys_$USER
181 extra_sshd="TrustedUserCAKeys $OBJ/user_ca_key.pub"
182 fi
djm@openbsd.org67f14592016-05-02 09:52:00 +0000183
184 for ktype in $PLAIN_TYPES ; do
markus@openbsd.org5bf09332015-07-10 06:23:25 +0000185 t=$(kname $ktype)
Damien Miller700dcfa2010-03-04 21:58:01 +1100186 for privsep in yes no ; do
187 _prefix="${ktype} privsep $privsep $auth"
188 # Simple connect
189 verbose "$tid: ${_prefix} connect"
190 (
191 cat $OBJ/sshd_proxy_bak
192 echo "UsePrivilegeSeparation $privsep"
markus@openbsd.org5bf09332015-07-10 06:23:25 +0000193 echo "PubkeyAcceptedKeyTypes ${t}"
Damien Miller700dcfa2010-03-04 21:58:01 +1100194 echo "$extra_sshd"
195 ) > $OBJ/sshd_proxy
markus@openbsd.org5bf09332015-07-10 06:23:25 +0000196 (
197 cat $OBJ/ssh_proxy_bak
198 echo "PubkeyAcceptedKeyTypes ${t}"
199 ) > $OBJ/ssh_proxy
djm@openbsd.org67f14592016-05-02 09:52:00 +0000200
djm@openbsd.orgdd369322017-04-30 23:34:55 +0000201 ${SSH} -i $OBJ/cert_user_key_${ktype} \
Damien Miller700dcfa2010-03-04 21:58:01 +1100202 -F $OBJ/ssh_proxy somehost true
203 if [ $? -ne 0 ]; then
204 fail "ssh cert connect failed"
205 fi
206
207 # Revoked keys
208 verbose "$tid: ${_prefix} revoked key"
209 (
210 cat $OBJ/sshd_proxy_bak
211 echo "UsePrivilegeSeparation $privsep"
Damien Millerebafebd2013-01-18 11:51:56 +1100212 echo "RevokedKeys $OBJ/cert_user_key_revoked"
markus@openbsd.org5bf09332015-07-10 06:23:25 +0000213 echo "PubkeyAcceptedKeyTypes ${t}"
Damien Miller700dcfa2010-03-04 21:58:01 +1100214 echo "$extra_sshd"
215 ) > $OBJ/sshd_proxy
Damien Millerebafebd2013-01-18 11:51:56 +1100216 cp $OBJ/cert_user_key_${ktype}.pub \
217 $OBJ/cert_user_key_revoked
djm@openbsd.orgdd369322017-04-30 23:34:55 +0000218 ${SSH} -i $OBJ/cert_user_key_${ktype} \
Damien Miller700dcfa2010-03-04 21:58:01 +1100219 -F $OBJ/ssh_proxy somehost true >/dev/null 2>&1
220 if [ $? -eq 0 ]; then
221 fail "ssh cert connect succeeded unexpecedly"
222 fi
Damien Millerebafebd2013-01-18 11:51:56 +1100223 verbose "$tid: ${_prefix} revoked via KRL"
224 rm $OBJ/cert_user_key_revoked
225 ${SSHKEYGEN} -kqf $OBJ/cert_user_key_revoked \
226 $OBJ/cert_user_key_${ktype}.pub
djm@openbsd.orgdd369322017-04-30 23:34:55 +0000227 ${SSH} -i $OBJ/cert_user_key_${ktype} \
Damien Millerebafebd2013-01-18 11:51:56 +1100228 -F $OBJ/ssh_proxy somehost true >/dev/null 2>&1
229 if [ $? -eq 0 ]; then
230 fail "ssh cert connect succeeded unexpecedly"
231 fi
232 verbose "$tid: ${_prefix} empty KRL"
233 ${SSHKEYGEN} -kqf $OBJ/cert_user_key_revoked
djm@openbsd.orgdd369322017-04-30 23:34:55 +0000234 ${SSH} -i $OBJ/cert_user_key_${ktype} \
Damien Millerebafebd2013-01-18 11:51:56 +1100235 -F $OBJ/ssh_proxy somehost true >/dev/null 2>&1
236 if [ $? -ne 0 ]; then
237 fail "ssh cert connect failed"
238 fi
Damien Miller700dcfa2010-03-04 21:58:01 +1100239 done
djm@openbsd.org67f14592016-05-02 09:52:00 +0000240
Damien Miller700dcfa2010-03-04 21:58:01 +1100241 # Revoked CA
242 verbose "$tid: ${ktype} $auth revoked CA key"
Damien Miller58ac6de2010-02-27 07:57:12 +1100243 (
244 cat $OBJ/sshd_proxy_bak
Damien Miller700dcfa2010-03-04 21:58:01 +1100245 echo "RevokedKeys $OBJ/user_ca_key.pub"
markus@openbsd.org5bf09332015-07-10 06:23:25 +0000246 echo "PubkeyAcceptedKeyTypes ${t}"
Damien Miller700dcfa2010-03-04 21:58:01 +1100247 echo "$extra_sshd"
Damien Miller58ac6de2010-02-27 07:57:12 +1100248 ) > $OBJ/sshd_proxy
djm@openbsd.orgdd369322017-04-30 23:34:55 +0000249 ${SSH} -i $OBJ/cert_user_key_${ktype} -F $OBJ/ssh_proxy \
Damien Miller700dcfa2010-03-04 21:58:01 +1100250 somehost true >/dev/null 2>&1
251 if [ $? -eq 0 ]; then
252 fail "ssh cert connect succeeded unexpecedly"
Damien Miller58ac6de2010-02-27 07:57:12 +1100253 fi
254 done
djm@openbsd.org67f14592016-05-02 09:52:00 +0000255
Damien Miller700dcfa2010-03-04 21:58:01 +1100256 verbose "$tid: $auth CA does not authenticate"
257 (
258 cat $OBJ/sshd_proxy_bak
markus@openbsd.org5bf09332015-07-10 06:23:25 +0000259 echo "PubkeyAcceptedKeyTypes ${t}"
Damien Miller700dcfa2010-03-04 21:58:01 +1100260 echo "$extra_sshd"
261 ) > $OBJ/sshd_proxy
262 verbose "$tid: ensure CA key does not authenticate user"
djm@openbsd.orgdd369322017-04-30 23:34:55 +0000263 ${SSH} -i $OBJ/user_ca_key \
Damien Miller700dcfa2010-03-04 21:58:01 +1100264 -F $OBJ/ssh_proxy somehost true >/dev/null 2>&1
265 if [ $? -eq 0 ]; then
266 fail "ssh cert connect with CA key succeeded unexpectedly"
267 fi
268}
Damien Miller58ac6de2010-02-27 07:57:12 +1100269
Damien Miller700dcfa2010-03-04 21:58:01 +1100270basic_tests authorized_keys
271basic_tests TrustedUserCAKeys
Damien Miller58ac6de2010-02-27 07:57:12 +1100272
273test_one() {
274 ident=$1
275 result=$2
276 sign_opts=$3
Damien Miller700dcfa2010-03-04 21:58:01 +1100277 auth_choice=$4
Damien Miller3bcce802010-05-21 14:48:16 +1000278 auth_opt=$5
Damien Miller58ac6de2010-02-27 07:57:12 +1100279
Damien Miller700dcfa2010-03-04 21:58:01 +1100280 if test "x$auth_choice" = "x" ; then
281 auth_choice="authorized_keys TrustedUserCAKeys"
Damien Miller58ac6de2010-02-27 07:57:12 +1100282 fi
Damien Miller700dcfa2010-03-04 21:58:01 +1100283
284 for auth in $auth_choice ; do
djm@openbsd.org6a977a42015-07-03 04:39:23 +0000285 for ktype in rsa ed25519 ; do
Damien Miller53f4bb62010-04-18 08:15:14 +1000286 cat $OBJ/sshd_proxy_bak > $OBJ/sshd_proxy
287 if test "x$auth" = "xauthorized_keys" ; then
288 # Add CA to authorized_keys
289 (
Darren Tucker56347ef2013-05-17 13:28:36 +1000290 printf "cert-authority${auth_opt} "
Damien Miller53f4bb62010-04-18 08:15:14 +1000291 cat $OBJ/user_ca_key.pub
292 ) > $OBJ/authorized_keys_$USER
293 else
294 echo > $OBJ/authorized_keys_$USER
295 echo "TrustedUserCAKeys $OBJ/user_ca_key.pub" \
296 >> $OBJ/sshd_proxy
markus@openbsd.org5bf09332015-07-10 06:23:25 +0000297 echo "PubkeyAcceptedKeyTypes ${t}*" \
298 >> $OBJ/sshd_proxy
Damien Miller3bcce802010-05-21 14:48:16 +1000299 if test "x$auth_opt" != "x" ; then
300 echo $auth_opt >> $OBJ/sshd_proxy
301 fi
Damien Miller700dcfa2010-03-04 21:58:01 +1100302 fi
djm@openbsd.org67f14592016-05-02 09:52:00 +0000303
Damien Miller53f4bb62010-04-18 08:15:14 +1000304 verbose "$tid: $ident auth $auth expect $result $ktype"
305 ${SSHKEYGEN} -q -s $OBJ/user_ca_key \
306 -I "regress user key for $USER" \
djm@openbsd.org6a977a42015-07-03 04:39:23 +0000307 $sign_opts $OBJ/cert_user_key_${ktype} ||
Damien Miller53f4bb62010-04-18 08:15:14 +1000308 fail "couldn't sign cert_user_key_${ktype}"
309
djm@openbsd.orgdd369322017-04-30 23:34:55 +0000310 ${SSH} -i $OBJ/cert_user_key_${ktype} \
Damien Miller53f4bb62010-04-18 08:15:14 +1000311 -F $OBJ/ssh_proxy somehost true >/dev/null 2>&1
312 rc=$?
313 if [ "x$result" = "xsuccess" ] ; then
314 if [ $rc -ne 0 ]; then
315 fail "$ident failed unexpectedly"
316 fi
317 else
318 if [ $rc -eq 0 ]; then
319 fail "$ident succeeded unexpectedly"
320 fi
Damien Miller700dcfa2010-03-04 21:58:01 +1100321 fi
Damien Miller53f4bb62010-04-18 08:15:14 +1000322 done
Damien Miller700dcfa2010-03-04 21:58:01 +1100323 done
Damien Miller58ac6de2010-02-27 07:57:12 +1100324}
325
Damien Miller700dcfa2010-03-04 21:58:01 +1100326test_one "correct principal" success "-n ${USER}"
327test_one "host-certificate" failure "-n ${USER} -h"
Damien Miller58ac6de2010-02-27 07:57:12 +1100328test_one "wrong principals" failure "-n foo"
Damien Miller700dcfa2010-03-04 21:58:01 +1100329test_one "cert not yet valid" failure "-n ${USER} -V20200101:20300101"
330test_one "cert expired" failure "-n ${USER} -V19800101:19900101"
331test_one "cert valid interval" success "-n ${USER} -V-1w:+2w"
332test_one "wrong source-address" failure "-n ${USER} -Osource-address=10.0.0.0/8"
333test_one "force-command" failure "-n ${USER} -Oforce-command=false"
334
335# Behaviour is different here: TrustedUserCAKeys doesn't allow empty principals
336test_one "empty principals" success "" authorized_keys
337test_one "empty principals" failure "" TrustedUserCAKeys
Damien Miller58ac6de2010-02-27 07:57:12 +1100338
Damien Miller3bcce802010-05-21 14:48:16 +1000339# Check explicitly-specified principals: an empty principals list in the cert
340# should always be refused.
341
342# AuthorizedPrincipalsFile
343rm -f $OBJ/authorized_keys_$USER
344echo mekmitasdigoat > $OBJ/authorized_principals_$USER
345test_one "AuthorizedPrincipalsFile principals" success "-n mekmitasdigoat" \
346 TrustedUserCAKeys "AuthorizedPrincipalsFile $OBJ/authorized_principals_%u"
347test_one "AuthorizedPrincipalsFile no principals" failure "" \
348 TrustedUserCAKeys "AuthorizedPrincipalsFile $OBJ/authorized_principals_%u"
349
350# principals= key option
351rm -f $OBJ/authorized_principals_$USER
352test_one "principals key option principals" success "-n mekmitasdigoat" \
353 authorized_keys ',principals="mekmitasdigoat"'
354test_one "principals key option no principals" failure "" \
355 authorized_keys ',principals="mekmitasdigoat"'
356
djm@openbsd.org85aa2ef2016-11-30 03:01:33 +0000357# command= options vs. force-command in key
358test_one "force-command match true" success \
359 "-n ${USER} -Oforce-command=true" \
360 authorized_keys ',command="true"'
361test_one "force-command match true" failure \
362 "-n ${USER} -Oforce-command=false" \
363 authorized_keys ',command="false"'
364test_one "force-command mismatch 1" failure \
365 "-n ${USER} -Oforce-command=false" \
366 authorized_keys ',command="true"'
367test_one "force-command mismatch 2" failure \
368 "-n ${USER} -Oforce-command=true" \
369 authorized_keys ',command="false"'
370
Damien Miller017d1e72010-03-04 21:57:21 +1100371# Wrong certificate
Damien Miller3bcce802010-05-21 14:48:16 +1000372cat $OBJ/sshd_proxy_bak > $OBJ/sshd_proxy
djm@openbsd.org67f14592016-05-02 09:52:00 +0000373for ktype in $PLAIN_TYPES ; do
markus@openbsd.org5bf09332015-07-10 06:23:25 +0000374 t=$(kname $ktype)
Damien Miller017d1e72010-03-04 21:57:21 +1100375 # Self-sign
djm@openbsd.org6a977a42015-07-03 04:39:23 +0000376 ${SSHKEYGEN} -q -s $OBJ/cert_user_key_${ktype} -I \
Damien Miller017d1e72010-03-04 21:57:21 +1100377 "regress user key for $USER" \
378 -n $USER $OBJ/cert_user_key_${ktype} ||
djm@openbsd.org67f14592016-05-02 09:52:00 +0000379 fatal "couldn't sign cert_user_key_${ktype}"
Damien Miller017d1e72010-03-04 21:57:21 +1100380 verbose "$tid: user ${ktype} connect wrong cert"
djm@openbsd.orgdd369322017-04-30 23:34:55 +0000381 ${SSH} -i $OBJ/cert_user_key_${ktype} -F $OBJ/ssh_proxy \
Damien Miller017d1e72010-03-04 21:57:21 +1100382 somehost true >/dev/null 2>&1
383 if [ $? -eq 0 ]; then
384 fail "ssh cert connect $ident succeeded unexpectedly"
385 fi
386done
387
Damien Miller58ac6de2010-02-27 07:57:12 +1100388rm -f $OBJ/authorized_keys_$USER $OBJ/user_ca_key* $OBJ/cert_user_key*
Damien Miller3bcce802010-05-21 14:48:16 +1000389rm -f $OBJ/authorized_principals_$USER
Damien Miller700dcfa2010-03-04 21:58:01 +1100390