1 # $OpenBSD: ssh-com-client.sh,v 1.6 2004/02/24 17:06:52 markus Exp $ 2 # Placed in the Public Domain. 3 4 tid="connect with ssh.com client" 5 6 #TEST_COMBASE=/path/to/ssh/com/binaries 7 if [ "X${TEST_COMBASE}" = "X" ]; then 8 fatal '$TEST_COMBASE is not set' 9 fi 10 11 VERSIONS=" 12 2.1.0 13 2.2.0 14 2.3.0 15 2.3.1 16 2.4.0 17 3.0.0 18 3.1.0 19 3.2.0 20 3.2.2 21 3.2.3 22 3.2.5 23 3.2.9 24 3.2.9.1 25 3.3.0" 26 27 # 2.0.10 2.0.12 2.0.13 don't like the test setup 28 29 # setup authorized keys 30 SRC=`dirname ${SCRIPT}` 31 cp ${SRC}/dsa_ssh2.prv ${OBJ}/id.com 32 chmod 600 ${OBJ}/id.com 33 ${SSHKEYGEN} -i -f ${OBJ}/id.com > $OBJ/id.openssh 34 chmod 600 ${OBJ}/id.openssh 35 ${SSHKEYGEN} -y -f ${OBJ}/id.openssh > $OBJ/authorized_keys_$USER 36 ${SSHKEYGEN} -e -f ${OBJ}/id.openssh > $OBJ/id.com.pub 37 echo IdKey ${OBJ}/id.com > ${OBJ}/id.list 38 39 # we need a DSA host key 40 t=dsa 41 rm -f ${OBJ}/$t ${OBJ}/$t.pub 42 ${SSHKEYGEN} -q -N '' -t $t -f ${OBJ}/$t 43 $SUDO cp $OBJ/$t $OBJ/host.$t 44 echo HostKey $OBJ/host.$t >> $OBJ/sshd_config 45 46 # add hostkeys to known hosts 47 mkdir -p ${OBJ}/${USER}/hostkeys 48 HK=${OBJ}/${USER}/hostkeys/key_${PORT}_127.0.0.1 49 ${SSHKEYGEN} -e -f ${OBJ}/rsa.pub > ${HK}.ssh-rsa.pub 50 ${SSHKEYGEN} -e -f ${OBJ}/dsa.pub > ${HK}.ssh-dss.pub 51 52 cat > ${OBJ}/ssh2_config << EOF 53 *: 54 QuietMode yes 55 StrictHostKeyChecking yes 56 Port ${PORT} 57 User ${USER} 58 Host 127.0.0.1 59 IdentityFile ${OBJ}/id.list 60 RandomSeedFile ${OBJ}/random_seed 61 UserConfigDirectory ${OBJ}/%U 62 AuthenticationSuccessMsg no 63 BatchMode yes 64 ForwardX11 no 65 EOF 66 67 # we need a real server (no ProxyConnect option) 68 start_sshd 69 70 DATA=/bin/ls${EXEEXT} 71 COPY=${OBJ}/copy 72 rm -f ${COPY} 73 74 # go for it 75 for v in ${VERSIONS}; do 76 ssh2=${TEST_COMBASE}/${v}/ssh2 77 if [ ! -x ${ssh2} ]; then 78 continue 79 fi 80 verbose "ssh2 ${v}" 81 key=ssh-dss 82 skipcat=0 83 case $v in 84 2.1.*|2.3.0) 85 skipcat=1 86 ;; 87 3.0.*) 88 key=ssh-rsa 89 ;; 90 esac 91 cp ${HK}.$key.pub ${HK}.pub 92 93 # check exit status 94 ${ssh2} -q -F ${OBJ}/ssh2_config somehost exit 42 95 r=$? 96 if [ $r -ne 42 ]; then 97 fail "ssh2 ${v} exit code test failed (got $r, expected 42)" 98 fi 99 100 # data transfer 101 rm -f ${COPY} 102 ${ssh2} -F ${OBJ}/ssh2_config somehost cat ${DATA} > ${COPY} 103 if [ $? -ne 0 ]; then 104 fail "ssh2 ${v} cat test (receive) failed" 105 fi 106 cmp ${DATA} ${COPY} || fail "ssh2 ${v} cat test (receive) data mismatch" 107 108 # data transfer, again 109 if [ $skipcat -eq 0 ]; then 110 rm -f ${COPY} 111 cat ${DATA} | \ 112 ${ssh2} -F ${OBJ}/ssh2_config host "cat > ${COPY}" 113 if [ $? -ne 0 ]; then 114 fail "ssh2 ${v} cat test (send) failed" 115 fi 116 cmp ${DATA} ${COPY} || \ 117 fail "ssh2 ${v} cat test (send) data mismatch" 118 fi 119 120 # no stderr after eof 121 rm -f ${COPY} 122 ${ssh2} -F ${OBJ}/ssh2_config somehost \ 123 exec sh -c \'"exec > /dev/null; sleep 1; echo bla 1>&2; exit 0"\' \ 124 2> /dev/null 125 if [ $? -ne 0 ]; then 126 fail "ssh2 ${v} stderr test failed" 127 fi 128 done 129 130 rm -rf ${OBJ}/${USER} 131 for i in ssh2_config random_seed dsa.pub dsa host.dsa \ 132 id.list id.com id.com.pub id.openssh; do 133 rm -f ${OBJ}/$i 134 done 135