Darren Tucker | 59d928d | 2013-05-17 15:32:29 +1000 | [diff] [blame] | 1 | # $OpenBSD: ssh-com-client.sh,v 1.7 2013/05/17 04:29:14 dtucker Exp $ |
Damien Miller | 38cd435 | 2002-05-01 13:17:33 +1000 | [diff] [blame] | 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 |
Damien Miller | 8b9cde7 | 2003-01-22 17:53:16 +1100 | [diff] [blame] | 18 | 3.1.0 |
| 19 | 3.2.0 |
Darren Tucker | ee5f83d | 2003-06-18 22:36:48 +1000 | [diff] [blame] | 20 | 3.2.2 |
| 21 | 3.2.3 |
Darren Tucker | 437a5f0 | 2004-02-29 20:33:51 +1100 | [diff] [blame] | 22 | 3.2.5 |
| 23 | 3.2.9 |
| 24 | 3.2.9.1 |
Damien Miller | 8b9cde7 | 2003-01-22 17:53:16 +1100 | [diff] [blame] | 25 | 3.3.0" |
Damien Miller | 38cd435 | 2002-05-01 13:17:33 +1000 | [diff] [blame] | 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 | |
Damien Miller | 38cd435 | 2002-05-01 13:17:33 +1000 | [diff] [blame] | 70 | # go for it |
| 71 | for v in ${VERSIONS}; do |
| 72 | ssh2=${TEST_COMBASE}/${v}/ssh2 |
| 73 | if [ ! -x ${ssh2} ]; then |
| 74 | continue |
| 75 | fi |
| 76 | verbose "ssh2 ${v}" |
| 77 | key=ssh-dss |
| 78 | skipcat=0 |
| 79 | case $v in |
| 80 | 2.1.*|2.3.0) |
| 81 | skipcat=1 |
| 82 | ;; |
| 83 | 3.0.*) |
| 84 | key=ssh-rsa |
| 85 | ;; |
| 86 | esac |
| 87 | cp ${HK}.$key.pub ${HK}.pub |
| 88 | |
| 89 | # check exit status |
| 90 | ${ssh2} -q -F ${OBJ}/ssh2_config somehost exit 42 |
| 91 | r=$? |
| 92 | if [ $r -ne 42 ]; then |
| 93 | fail "ssh2 ${v} exit code test failed (got $r, expected 42)" |
| 94 | fi |
| 95 | |
| 96 | # data transfer |
| 97 | rm -f ${COPY} |
| 98 | ${ssh2} -F ${OBJ}/ssh2_config somehost cat ${DATA} > ${COPY} |
| 99 | if [ $? -ne 0 ]; then |
| 100 | fail "ssh2 ${v} cat test (receive) failed" |
| 101 | fi |
| 102 | cmp ${DATA} ${COPY} || fail "ssh2 ${v} cat test (receive) data mismatch" |
| 103 | |
| 104 | # data transfer, again |
| 105 | if [ $skipcat -eq 0 ]; then |
| 106 | rm -f ${COPY} |
| 107 | cat ${DATA} | \ |
| 108 | ${ssh2} -F ${OBJ}/ssh2_config host "cat > ${COPY}" |
| 109 | if [ $? -ne 0 ]; then |
| 110 | fail "ssh2 ${v} cat test (send) failed" |
| 111 | fi |
| 112 | cmp ${DATA} ${COPY} || \ |
| 113 | fail "ssh2 ${v} cat test (send) data mismatch" |
| 114 | fi |
| 115 | |
| 116 | # no stderr after eof |
| 117 | rm -f ${COPY} |
| 118 | ${ssh2} -F ${OBJ}/ssh2_config somehost \ |
| 119 | exec sh -c \'"exec > /dev/null; sleep 1; echo bla 1>&2; exit 0"\' \ |
| 120 | 2> /dev/null |
| 121 | if [ $? -ne 0 ]; then |
| 122 | fail "ssh2 ${v} stderr test failed" |
| 123 | fi |
| 124 | done |
| 125 | |
| 126 | rm -rf ${OBJ}/${USER} |
| 127 | for i in ssh2_config random_seed dsa.pub dsa host.dsa \ |
| 128 | id.list id.com id.com.pub id.openssh; do |
| 129 | rm -f ${OBJ}/$i |
| 130 | done |