xref: /freebsd/crypto/openssh/regress/ssh-com.sh (revision b1f9167f94059fd55c630891d359bcff987bd7eb)
1#	$OpenBSD: ssh-com.sh,v 1.8 2013/05/17 00:37:40 dtucker Exp $
2#	Placed in the Public Domain.
3
4tid="connect to ssh.com server"
5
6#TEST_COMBASE=/path/to/ssh/com/binaries
7if [ "X${TEST_COMBASE}" = "X" ]; then
8	fatal '$TEST_COMBASE is not set'
9fi
10
11VERSIONS="
12	2.0.12
13	2.0.13
14	2.1.0
15	2.2.0
16	2.3.0
17	2.4.0
18	3.0.0
19	3.1.0
20	3.2.0
21	3.2.2
22	3.2.3
23	3.2.5
24	3.2.9
25	3.2.9.1
26	3.3.0"
27# 2.0.10 does not support UserConfigDirectory
28# 2.3.1 requires a config in $HOME/.ssh2
29
30SRC=`dirname ${SCRIPT}`
31
32# ssh.com
33cat << EOF > $OBJ/sshd2_config
34#*:
35	# Port and ListenAddress are not used.
36	QuietMode			yes
37	Port				4343
38	ListenAddress			127.0.0.1
39	UserConfigDirectory		${OBJ}/%U
40	Ciphers				AnyCipher
41	PubKeyAuthentication		yes
42	#AllowedAuthentications		publickey
43	AuthorizationFile		authorization
44	HostKeyFile			${SRC}/dsa_ssh2.prv
45	PublicHostKeyFile		${SRC}/dsa_ssh2.pub
46	RandomSeedFile			${OBJ}/random_seed
47	MaxConnections			0 
48	PermitRootLogin			yes
49	VerboseMode			no
50	CheckMail			no
51	Ssh1Compatibility		no
52EOF
53
54# create client config
55sed "s/HostKeyAlias.*/HostKeyAlias ssh2-localhost-with-alias/" \
56	< $OBJ/ssh_config > $OBJ/ssh_config_com
57
58# we need a DSA key for
59rm -f                             ${OBJ}/dsa ${OBJ}/dsa.pub
60${SSHKEYGEN} -q -N '' -t dsa -f	  ${OBJ}/dsa
61
62# setup userdir, try rsa first
63mkdir -p ${OBJ}/${USER}
64cp /dev/null ${OBJ}/${USER}/authorization
65for t in rsa dsa; do
66	${SSHKEYGEN} -e -f ${OBJ}/$t.pub	>  ${OBJ}/${USER}/$t.com
67	echo Key $t.com			>> ${OBJ}/${USER}/authorization
68	echo IdentityFile ${OBJ}/$t	>> ${OBJ}/ssh_config_com
69done
70
71# convert and append DSA hostkey
72(
73	printf 'ssh2-localhost-with-alias,127.0.0.1,::1 '
74	${SSHKEYGEN} -if ${SRC}/dsa_ssh2.pub
75) >> $OBJ/known_hosts
76
77# go for it
78for v in ${VERSIONS}; do
79	sshd2=${TEST_COMBASE}/${v}/sshd2
80	if [ ! -x ${sshd2} ]; then
81		continue
82	fi
83	trace "sshd2 ${v}"
84	PROXY="proxycommand ${sshd2} -qif ${OBJ}/sshd2_config 2> /dev/null"
85	${SSH} -qF ${OBJ}/ssh_config_com -o "${PROXY}" dummy exit 0
86        if [ $? -ne 0 ]; then
87                fail "ssh connect to sshd2 ${v} failed"
88        fi
89
90	ciphers="3des-cbc blowfish-cbc arcfour"
91	macs="hmac-md5"
92	case $v in
93	2.4.*)
94		ciphers="$ciphers cast128-cbc"
95		macs="$macs hmac-sha1 hmac-sha1-96 hmac-md5-96"
96		;;
97	3.*)
98		ciphers="$ciphers aes128-cbc cast128-cbc"
99		macs="$macs hmac-sha1 hmac-sha1-96 hmac-md5-96"
100		;;
101	esac
102	#ciphers="3des-cbc"
103	for m in $macs; do
104	for c in $ciphers; do
105		trace "sshd2 ${v} cipher $c mac $m"
106		verbose "test ${tid}: sshd2 ${v} cipher $c mac $m"
107		${SSH} -c $c -m $m -qF ${OBJ}/ssh_config_com -o "${PROXY}" dummy exit 0
108		if [ $? -ne 0 ]; then
109			fail "ssh connect to sshd2 ${v} with $c/$m failed"
110		fi
111	done
112	done
113done
114
115rm -rf ${OBJ}/${USER}
116for i in sshd_config_proxy ssh_config_proxy random_seed \
117	sshd2_config dsa.pub dsa ssh_config_com; do
118	rm -f ${OBJ}/$i
119done
120