1 # $OpenBSD: agent.sh,v 1.7 2007/11/25 15:35:09 jmc Exp $
2 # Placed in the Public Domain.
4 tid
="simple agent test"
6 SSH_AUTH_SOCK
=/nonexistent
${SSHADD} -l > /dev
/null
2>&1
8 fail
"ssh-add -l did not fail with exit code 2"
12 eval `${SSHAGENT} -s` > /dev
/null
15 fail
"could not start ssh-agent: exit code $r"
17 ${SSHADD} -l > /dev
/null
2>&1
19 fail
"ssh-add -l did not fail with exit code 1"
21 trace
"overwrite authorized keys"
22 echon
> $OBJ/authorized_keys_
$USER
24 # generate user key for agent
26 ${SSHKEYGEN} -q -N '' -t $t -f $OBJ/$t-agent ||\
27 fail
"ssh-keygen for $t-agent failed"
28 # add to authorized keys
29 cat $OBJ/$t-agent.pub
>> $OBJ/authorized_keys_
$USER
30 # add privat key to agent
31 ${SSHADD} $OBJ/$t-agent > /dev
/null
2>&1
33 fail
"ssh-add did succeed exit code 0"
36 ${SSHADD} -l > /dev
/null
2>&1
38 fail
"ssh-add -l failed: exit code $?"
40 # the same for full pubkey output
41 ${SSHADD} -L > /dev
/null
2>&1
43 fail
"ssh-add -L failed: exit code $?"
46 trace
"simple connect via agent"
48 ${SSH} -$p -F $OBJ/ssh_proxy somehost
exit 5$p
49 if [ $?
-ne 5$p ]; then
50 fail
"ssh connect with protocol $p failed (exit code $?)"
54 trace
"agent forwarding"
56 ${SSH} -A -$p -F $OBJ/ssh_proxy somehost
${SSHADD} -l > /dev
/null
2>&1
58 fail
"ssh-add -l via agent fwd proto $p failed (exit code $?)"
60 ${SSH} -A -$p -F $OBJ/ssh_proxy somehost \
61 "${SSH} -$p -F $OBJ/ssh_proxy somehost exit 5$p"
62 if [ $?
-ne 5$p ]; then
63 fail
"agent fwd proto $p failed (exit code $?)"
67 trace
"delete all agent keys"
68 ${SSHADD} -D > /dev
/null
2>&1
70 fail
"ssh-add -D failed: exit code $?"
74 ${SSHAGENT} -k > /dev
/null