diff options
Diffstat (limited to 'regress/hostkey-agent.sh')
-rw-r--r-- | regress/hostkey-agent.sh | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/regress/hostkey-agent.sh b/regress/hostkey-agent.sh new file mode 100644 index 000000000..a011ec831 --- /dev/null +++ b/regress/hostkey-agent.sh | |||
@@ -0,0 +1,52 @@ | |||
1 | # $OpenBSD: hostkey-agent.sh,v 1.5 2015/02/21 20:51:02 djm Exp $ | ||
2 | # Placed in the Public Domain. | ||
3 | |||
4 | tid="hostkey agent" | ||
5 | |||
6 | rm -f $OBJ/agent-key.* $OBJ/ssh_proxy.orig $OBJ/known_hosts.orig | ||
7 | |||
8 | trace "start agent" | ||
9 | eval `${SSHAGENT} -s` > /dev/null | ||
10 | r=$? | ||
11 | [ $r -ne 0 ] && fatal "could not start ssh-agent: exit code $r" | ||
12 | |||
13 | grep -vi 'hostkey' $OBJ/sshd_proxy > $OBJ/sshd_proxy.orig | ||
14 | echo "HostKeyAgent $SSH_AUTH_SOCK" >> $OBJ/sshd_proxy.orig | ||
15 | |||
16 | trace "load hostkeys" | ||
17 | for k in `${SSH} -Q key-plain` ; do | ||
18 | ${SSHKEYGEN} -qt $k -f $OBJ/agent-key.$k -N '' || fatal "ssh-keygen $k" | ||
19 | ( | ||
20 | printf 'localhost-with-alias,127.0.0.1,::1 ' | ||
21 | cat $OBJ/agent-key.$k.pub | ||
22 | ) >> $OBJ/known_hosts.orig | ||
23 | ${SSHADD} $OBJ/agent-key.$k >/dev/null 2>&1 || \ | ||
24 | fatal "couldn't load key $OBJ/agent-key.$k" | ||
25 | echo "Hostkey $OBJ/agent-key.${k}" >> $OBJ/sshd_proxy.orig | ||
26 | # Remove private key so the server can't use it. | ||
27 | rm $OBJ/agent-key.$k || fatal "couldn't rm $OBJ/agent-key.$k" | ||
28 | done | ||
29 | cp $OBJ/known_hosts.orig $OBJ/known_hosts | ||
30 | |||
31 | unset SSH_AUTH_SOCK | ||
32 | |||
33 | for ps in no yes; do | ||
34 | cp $OBJ/sshd_proxy.orig $OBJ/sshd_proxy | ||
35 | echo "UsePrivilegeSeparation $ps" >> $OBJ/sshd_proxy | ||
36 | for k in `${SSH} -Q key-plain` ; do | ||
37 | verbose "key type $k privsep=$ps" | ||
38 | opts="-oHostKeyAlgorithms=$k -F $OBJ/ssh_proxy" | ||
39 | cp $OBJ/known_hosts.orig $OBJ/known_hosts | ||
40 | SSH_CONNECTION=`${SSH} $opts host 'echo $SSH_CONNECTION'` | ||
41 | if [ $? -ne 0 ]; then | ||
42 | fail "protocol $p privsep=$ps failed" | ||
43 | fi | ||
44 | if [ "$SSH_CONNECTION" != "UNKNOWN 65535 UNKNOWN 65535" ]; then | ||
45 | fail "bad SSH_CONNECTION key type $k privsep=$ps" | ||
46 | fi | ||
47 | done | ||
48 | done | ||
49 | |||
50 | trace "kill agent" | ||
51 | ${SSHAGENT} -k > /dev/null | ||
52 | |||