summaryrefslogtreecommitdiff
path: root/regress/limit-keytype.sh
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2015-09-24 06:16:53 +0000
committerDamien Miller <djm@mindrot.org>2015-10-06 12:28:41 +1100
commite14ac43b75e68f1ffbd3e1a5e44143c8ae578dcd (patch)
tree7e5c0f6792a657ba21d35f7a47508ab0fd94b8b0 /regress/limit-keytype.sh
parent905b054ed24e0d5b4ef226ebf2c8bfc02ae6d4ad (diff)
upstream commit
regress test for CertificateFile; patch from Meghana Bhat via bz#2436 Upstream-Regress-ID: e7a6e980cbe0f8081ba2e83de40d06c17be8bd25
Diffstat (limited to 'regress/limit-keytype.sh')
-rw-r--r--regress/limit-keytype.sh19
1 files changed, 9 insertions, 10 deletions
diff --git a/regress/limit-keytype.sh b/regress/limit-keytype.sh
index 2de037bd1..aaf2d2d44 100644
--- a/regress/limit-keytype.sh
+++ b/regress/limit-keytype.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: limit-keytype.sh,v 1.1 2015/01/13 07:49:49 djm Exp $ 1# $OpenBSD: limit-keytype.sh,v 1.2 2015/09/24 06:16:53 djm Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4tid="restrict pubkey type" 4tid="restrict pubkey type"
@@ -26,12 +26,11 @@ ${SSHKEYGEN} -q -s $OBJ/user_ca_key -I "regress user key for $USER" \
26# Copy the private key alongside the cert to allow better control of when 26# Copy the private key alongside the cert to allow better control of when
27# it is offered. 27# it is offered.
28mv $OBJ/user_key3-cert.pub $OBJ/cert_user_key3.pub 28mv $OBJ/user_key3-cert.pub $OBJ/cert_user_key3.pub
29cp -p $OBJ/user_key3 $OBJ/cert_user_key3
30 29
31grep -v IdentityFile $OBJ/ssh_proxy.orig > $OBJ/ssh_proxy 30grep -v IdentityFile $OBJ/ssh_proxy.orig > $OBJ/ssh_proxy
32 31
33opts="-oProtocol=2 -F $OBJ/ssh_proxy -oIdentitiesOnly=yes" 32opts="-oProtocol=2 -F $OBJ/ssh_proxy -oIdentitiesOnly=yes"
34fullopts="$opts -i $OBJ/cert_user_key3 -i $OBJ/user_key1 -i $OBJ/user_key2" 33certopts="$opts -i $OBJ/user_key3 -oCertificateFile=$OBJ/cert_user_key3.pub"
35 34
36echo mekmitasdigoat > $OBJ/authorized_principals_$USER 35echo mekmitasdigoat > $OBJ/authorized_principals_$USER
37cat $OBJ/user_key1.pub > $OBJ/authorized_keys_$USER 36cat $OBJ/user_key1.pub > $OBJ/authorized_keys_$USER
@@ -53,28 +52,28 @@ prepare_config() {
53prepare_config 52prepare_config
54 53
55# Check we can log in with all key types. 54# Check we can log in with all key types.
56${SSH} $opts -i $OBJ/cert_user_key3 proxy true || fatal "cert failed" 55${SSH} $certopts proxy true || fatal "cert failed"
57${SSH} $opts -i $OBJ/user_key1 proxy true || fatal "key1 failed" 56${SSH} $opts -i $OBJ/user_key1 proxy true || fatal "key1 failed"
58${SSH} $opts -i $OBJ/user_key2 proxy true || fatal "key2 failed" 57${SSH} $opts -i $OBJ/user_key2 proxy true || fatal "key2 failed"
59 58
60# Allow plain Ed25519 and RSA. The certificate should fail. 59# Allow plain Ed25519 and RSA. The certificate should fail.
61verbose "privsep=$privsep allow rsa,ed25519" 60verbose "allow rsa,ed25519"
62prepare_config "PubkeyAcceptedKeyTypes ssh-rsa,ssh-ed25519" 61prepare_config "PubkeyAcceptedKeyTypes ssh-rsa,ssh-ed25519"
63${SSH} $opts -i $OBJ/cert_user_key3 proxy true && fatal "cert succeeded" 62${SSH} $certopt proxy true && fatal "cert succeeded"
64${SSH} $opts -i $OBJ/user_key1 proxy true || fatal "key1 failed" 63${SSH} $opts -i $OBJ/user_key1 proxy true || fatal "key1 failed"
65${SSH} $opts -i $OBJ/user_key2 proxy true || fatal "key2 failed" 64${SSH} $opts -i $OBJ/user_key2 proxy true || fatal "key2 failed"
66 65
67# Allow Ed25519 only. 66# Allow Ed25519 only.
68verbose "privsep=$privsep allow ed25519" 67verbose "allow ed25519"
69prepare_config "PubkeyAcceptedKeyTypes ssh-ed25519" 68prepare_config "PubkeyAcceptedKeyTypes ssh-ed25519"
70${SSH} $opts -i $OBJ/cert_user_key3 proxy true && fatal "cert succeeded" 69${SSH} $certopts proxy true && fatal "cert succeeded"
71${SSH} $opts -i $OBJ/user_key1 proxy true || fatal "key1 failed" 70${SSH} $opts -i $OBJ/user_key1 proxy true || fatal "key1 failed"
72${SSH} $opts -i $OBJ/user_key2 proxy true && fatal "key2 succeeded" 71${SSH} $opts -i $OBJ/user_key2 proxy true && fatal "key2 succeeded"
73 72
74# Allow all certs. Plain keys should fail. 73# Allow all certs. Plain keys should fail.
75verbose "privsep=$privsep allow cert only" 74verbose "allow cert only"
76prepare_config "PubkeyAcceptedKeyTypes ssh-*-cert-v01@openssh.com" 75prepare_config "PubkeyAcceptedKeyTypes ssh-*-cert-v01@openssh.com"
77${SSH} $opts -i $OBJ/cert_user_key3 proxy true || fatal "cert failed" 76${SSH} $certopts proxy true || fatal "cert failed"
78${SSH} $opts -i $OBJ/user_key1 proxy true && fatal "key1 succeeded" 77${SSH} $opts -i $OBJ/user_key1 proxy true && fatal "key1 succeeded"
79${SSH} $opts -i $OBJ/user_key2 proxy true && fatal "key2 succeeded" 78${SSH} $opts -i $OBJ/user_key2 proxy true && fatal "key2 succeeded"
80 79