summaryrefslogtreecommitdiff
path: root/regress/hostkey-agent.sh
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2015-01-17 18:54:30 +0000
committerDamien Miller <djm@mindrot.org>2015-01-20 00:23:43 +1100
commit26b3425170bf840e4b095e1c10bf25a0a3e3a105 (patch)
treeabc40ceba9aa1d95a539deba22fca5d24575e2b2 /regress/hostkey-agent.sh
parent9e06a0fb23ec55d9223b26a45bb63c7649e2f2f2 (diff)
upstream commit
unit test for hostkeys in ssh-agent
Diffstat (limited to 'regress/hostkey-agent.sh')
-rw-r--r--regress/hostkey-agent.sh55
1 files changed, 55 insertions, 0 deletions
diff --git a/regress/hostkey-agent.sh b/regress/hostkey-agent.sh
new file mode 100644
index 000000000..4562f42af
--- /dev/null
+++ b/regress/hostkey-agent.sh
@@ -0,0 +1,55 @@
1# $OpenBSD: hostkey-agent.sh,v 1.1 2015/01/17 18:54:30 djm Exp $
2# Placed in the Public Domain.
3
4tid="hostkey agent"
5
6# Need full names here since they are used in HostKeyAlgorithms
7HOSTKEY_TYPES="ecdsa-sha2-nistp256 ssh-ed25519 ssh-rsa ssh-dss"
8
9rm -f $OBJ/agent.* $OBJ/ssh_proxy.orig
10
11trace "start agent"
12eval `${SSHAGENT} -s` > /dev/null
13r=$?
14[ $r -ne 0 ] && fatal "could not start ssh-agent: exit code $r"
15
16grep -vi 'hostkey' $OBJ/sshd_proxy > $OBJ/sshd_proxy.orig
17echo "HostKeyAgent $SSH_AUTH_SOCK" >> $OBJ/sshd_proxy.orig
18echo "LogLevel debug3" >> $OBJ/sshd_proxy.orig
19rm $OBJ/known_hosts
20
21trace "load hostkeys"
22for k in $HOSTKEY_TYPES ; do
23 ${SSHKEYGEN} -qt $k -f $OBJ/agent.$k -N '' || fatal "ssh-keygen $k"
24 (
25 echo -n 'localhost-with-alias,127.0.0.1,::1 '
26 cat $OBJ/agent.$k.pub
27 ) >> $OBJ/known_hosts
28 ${SSHADD} $OBJ/agent.$k >/dev/null 2>&1 || \
29 fatal "couldn't load key $OBJ/agent.$k"
30 echo "Hostkey $OBJ/agent.${k}" >> sshd_proxy.orig
31 # Remove private key so the server can't use it.
32 rm $OBJ/agent.$k || fatal "couldn't rm $OBJ/agent.$k"
33done
34
35unset SSH_AUTH_SOCK
36
37for ps in no yes; do
38 cp $OBJ/sshd_proxy.orig $OBJ/sshd_proxy
39 echo "UsePrivilegeSeparation $ps" >> $OBJ/sshd_proxy
40 for k in $HOSTKEY_TYPES ; do
41 verbose "key type $k privsep=$ps"
42 opts="-oHostKeyAlgorithms=$k -F $OBJ/ssh_proxy"
43 SSH_CONNECTION=`${SSH} $opts host 'echo $SSH_CONNECTION'`
44 if [ $? -ne 0 ]; then
45 fail "protocol $p privsep=$ps failed"
46 fi
47 if [ "$SSH_CONNECTION" != "UNKNOWN 65535 UNKNOWN 65535" ]; then
48 fail "bad SSH_CONNECTION key type $k privsep=$ps"
49 fi
50 done
51done
52
53trace "kill agent"
54${SSHAGENT} -k > /dev/null
55