summaryrefslogtreecommitdiff
path: root/regress/agent.sh
diff options
context:
space:
mode:
Diffstat (limited to 'regress/agent.sh')
-rw-r--r--regress/agent.sh53
1 files changed, 47 insertions, 6 deletions
diff --git a/regress/agent.sh b/regress/agent.sh
index 48fa12b0e..39403653c 100644
--- a/regress/agent.sh
+++ b/regress/agent.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: agent.sh,v 1.15 2019/07/23 07:39:43 dtucker Exp $ 1# $OpenBSD: agent.sh,v 1.17 2019/12/21 02:33:07 djm Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4tid="simple agent test" 4tid="simple agent test"
@@ -8,13 +8,19 @@ if [ $? -ne 2 ]; then
8 fail "ssh-add -l did not fail with exit code 2" 8 fail "ssh-add -l did not fail with exit code 2"
9fi 9fi
10 10
11trace "start agent" 11trace "start agent, args ${EXTRA_AGENT_ARGS} -s"
12eval `${SSHAGENT} -s` > /dev/null 12eval `${SSHAGENT} ${EXTRA_AGENT_ARGS} -s` > /dev/null
13r=$? 13r=$?
14if [ $r -ne 0 ]; then 14if [ $r -ne 0 ]; then
15 fatal "could not start ssh-agent: exit code $r" 15 fatal "could not start ssh-agent: exit code $r"
16fi 16fi
17 17
18eval `${SSHAGENT} ${EXTRA_AGENT_ARGS} -s | sed 's/SSH_/FW_SSH_/g'` > /dev/null
19r=$?
20if [ $r -ne 0 ]; then
21 fatal "could not start second ssh-agent: exit code $r"
22fi
23
18${SSHADD} -l > /dev/null 2>&1 24${SSHADD} -l > /dev/null 2>&1
19if [ $? -ne 1 ]; then 25if [ $? -ne 1 ]; then
20 fail "ssh-add -l did not fail with exit code 1" 26 fail "ssh-add -l did not fail with exit code 1"
@@ -38,10 +44,15 @@ for t in ${SSH_KEYTYPES}; do
38 44
39 # add to authorized keys 45 # add to authorized keys
40 cat $OBJ/$t-agent.pub >> $OBJ/authorized_keys_$USER 46 cat $OBJ/$t-agent.pub >> $OBJ/authorized_keys_$USER
41 # add privat key to agent 47 # add private key to agent
42 ${SSHADD} $OBJ/$t-agent > /dev/null 2>&1 48 ${SSHADD} $OBJ/$t-agent #> /dev/null 2>&1
49 if [ $? -ne 0 ]; then
50 fail "ssh-add failed exit code $?"
51 fi
52 # add private key to second agent
53 SSH_AUTH_SOCK=$FW_SSH_AUTH_SOCK ${SSHADD} $OBJ/$t-agent #> /dev/null 2>&1
43 if [ $? -ne 0 ]; then 54 if [ $? -ne 0 ]; then
44 fail "ssh-add did succeed exit code 0" 55 fail "ssh-add failed exit code $?"
45 fi 56 fi
46 # Remove private key to ensure that we aren't accidentally using it. 57 # Remove private key to ensure that we aren't accidentally using it.
47 rm -f $OBJ/$t-agent 58 rm -f $OBJ/$t-agent
@@ -90,6 +101,11 @@ r=$?
90if [ $r -ne 0 ]; then 101if [ $r -ne 0 ]; then
91 fail "ssh-add -l via agent fwd failed (exit code $r)" 102 fail "ssh-add -l via agent fwd failed (exit code $r)"
92fi 103fi
104${SSH} "-oForwardAgent=$SSH_AUTH_SOCK" -F $OBJ/ssh_proxy somehost ${SSHADD} -l > /dev/null 2>&1
105r=$?
106if [ $r -ne 0 ]; then
107 fail "ssh-add -l via agent path fwd failed (exit code $r)"
108fi
93${SSH} -A -F $OBJ/ssh_proxy somehost \ 109${SSH} -A -F $OBJ/ssh_proxy somehost \
94 "${SSH} -F $OBJ/ssh_proxy somehost exit 52" 110 "${SSH} -F $OBJ/ssh_proxy somehost exit 52"
95r=$? 111r=$?
@@ -97,6 +113,30 @@ if [ $r -ne 52 ]; then
97 fail "agent fwd failed (exit code $r)" 113 fail "agent fwd failed (exit code $r)"
98fi 114fi
99 115
116trace "agent forwarding different agent"
117${SSH} "-oForwardAgent=$FW_SSH_AUTH_SOCK" -F $OBJ/ssh_proxy somehost ${SSHADD} -l > /dev/null 2>&1
118r=$?
119if [ $r -ne 0 ]; then
120 fail "ssh-add -l via agent path fwd of different agent failed (exit code $r)"
121fi
122${SSH} '-oForwardAgent=$FW_SSH_AUTH_SOCK' -F $OBJ/ssh_proxy somehost ${SSHADD} -l > /dev/null 2>&1
123r=$?
124if [ $r -ne 0 ]; then
125 fail "ssh-add -l via agent path env fwd of different agent failed (exit code $r)"
126fi
127
128# Remove keys from forwarded agent, ssh-add on remote machine should now fail.
129SSH_AUTH_SOCK=$FW_SSH_AUTH_SOCK ${SSHADD} -D > /dev/null 2>&1
130r=$?
131if [ $r -ne 0 ]; then
132 fail "ssh-add -D failed: exit code $r"
133fi
134${SSH} '-oForwardAgent=$FW_SSH_AUTH_SOCK' -F $OBJ/ssh_proxy somehost ${SSHADD} -l > /dev/null 2>&1
135r=$?
136if [ $r -ne 1 ]; then
137 fail "ssh-add -l with different agent did not fail with exit code 1 (exit code $r)"
138fi
139
100(printf 'cert-authority,principals="estragon" '; cat $OBJ/user_ca_key.pub) \ 140(printf 'cert-authority,principals="estragon" '; cat $OBJ/user_ca_key.pub) \
101 > $OBJ/authorized_keys_$USER 141 > $OBJ/authorized_keys_$USER
102for t in ${SSH_KEYTYPES}; do 142for t in ${SSH_KEYTYPES}; do
@@ -121,3 +161,4 @@ fi
121 161
122trace "kill agent" 162trace "kill agent"
123${SSHAGENT} -k > /dev/null 163${SSHAGENT} -k > /dev/null
164SSH_AGENT_PID=$FW_SSH_AGENT_PID ${SSHAGENT} -k > /dev/null