Plan 9 from Bell Labs’s /usr/web/sources/contrib/fgb/root/sys/src/cmd/openssh/regress/agent-timeout.sh

Copyright © 2021 Plan 9 Foundation.
Distributed under the MIT License.
Download the Plan 9 distribution.


#	$OpenBSD: agent-timeout.sh,v 1.1 2002/06/06 00:38:40 markus Exp $
#	Placed in the Public Domain.

tid="agent timeout test"

SSHAGENT_TIMEOUT=10

trace "start agent"
eval `${SSHAGENT} -s` > /dev/null
r=$?
if [ $r -ne 0 ]; then
	fail "could not start ssh-agent: exit code $r"
else
	trace "add keys with timeout"
	for t in rsa rsa1; do
		${SSHADD} -t ${SSHAGENT_TIMEOUT} $OBJ/$t > /dev/null 2>&1
		if [ $? -ne 0 ]; then
			fail "ssh-add did succeed exit code 0"
		fi
	done
	n=`${SSHADD} -l 2> /dev/null | wc -l`
	trace "agent has $n keys"
	if [ $n -ne 2 ]; then
		fail "ssh-add -l did not return 2 keys: $n"
	fi
	trace "sleeping 2*${SSHAGENT_TIMEOUT} seconds"
	sleep ${SSHAGENT_TIMEOUT}
	sleep ${SSHAGENT_TIMEOUT}
	${SSHADD} -l 2> /dev/null | grep 'The agent has no identities.' >/dev/null
	if [ $? -ne 0 ]; then
		fail "ssh-add -l still returns keys after timeout"
	fi

	trace "kill agent"
	${SSHAGENT} -k > /dev/null
fi

Bell Labs OSI certified Powered by Plan 9

(Return to Plan 9 Home Page)

Copyright © 2021 Plan 9 Foundation. All Rights Reserved.
Comments to webmaster@9p.io.