Darren Tucker | 56347ef | 2013-05-17 13:28:36 +1000 | [diff] [blame] | 1 | # $OpenBSD: ssh-com.sh,v 1.8 2013/05/17 00:37:40 dtucker Exp $ |
Damien Miller | 38cd435 | 2002-05-01 13:17:33 +1000 | [diff] [blame] | 2 | # Placed in the Public Domain. |
| 3 | |
| 4 | tid="connect to ssh.com server" |
| 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.0.12 |
| 13 | 2.0.13 |
| 14 | 2.1.0 |
| 15 | 2.2.0 |
| 16 | 2.3.0 |
Damien Miller | 38cd435 | 2002-05-01 13:17:33 +1000 | [diff] [blame] | 17 | 2.4.0 |
| 18 | 3.0.0 |
Damien Miller | 8b9cde7 | 2003-01-22 17:53:16 +1100 | [diff] [blame] | 19 | 3.1.0 |
| 20 | 3.2.0 |
Darren Tucker | ee5f83d | 2003-06-18 22:36:48 +1000 | [diff] [blame] | 21 | 3.2.2 |
| 22 | 3.2.3 |
Darren Tucker | 437a5f0 | 2004-02-29 20:33:51 +1100 | [diff] [blame] | 23 | 3.2.5 |
| 24 | 3.2.9 |
| 25 | 3.2.9.1 |
Damien Miller | 8b9cde7 | 2003-01-22 17:53:16 +1100 | [diff] [blame] | 26 | 3.3.0" |
Damien Miller | 38cd435 | 2002-05-01 13:17:33 +1000 | [diff] [blame] | 27 | # 2.0.10 does not support UserConfigDirectory |
Damien Miller | 8b9cde7 | 2003-01-22 17:53:16 +1100 | [diff] [blame] | 28 | # 2.3.1 requires a config in $HOME/.ssh2 |
Damien Miller | 38cd435 | 2002-05-01 13:17:33 +1000 | [diff] [blame] | 29 | |
| 30 | SRC=`dirname ${SCRIPT}` |
| 31 | |
| 32 | # ssh.com |
| 33 | cat << EOF > $OBJ/sshd2_config |
Damien Miller | 8b9cde7 | 2003-01-22 17:53:16 +1100 | [diff] [blame] | 34 | #*: |
Darren Tucker | 633f3e0 | 2004-01-30 13:00:29 +1100 | [diff] [blame] | 35 | # Port and ListenAddress are not used. |
Damien Miller | 38cd435 | 2002-05-01 13:17:33 +1000 | [diff] [blame] | 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 |
| 52 | EOF |
| 53 | |
| 54 | # create client config |
| 55 | sed "s/HostKeyAlias.*/HostKeyAlias ssh2-localhost-with-alias/" \ |
| 56 | < $OBJ/ssh_config > $OBJ/ssh_config_com |
| 57 | |
| 58 | # we need a DSA key for |
| 59 | rm -f ${OBJ}/dsa ${OBJ}/dsa.pub |
| 60 | ${SSHKEYGEN} -q -N '' -t dsa -f ${OBJ}/dsa |
| 61 | |
| 62 | # setup userdir, try rsa first |
| 63 | mkdir -p ${OBJ}/${USER} |
| 64 | cp /dev/null ${OBJ}/${USER}/authorization |
| 65 | for 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 |
| 69 | done |
| 70 | |
| 71 | # convert and append DSA hostkey |
| 72 | ( |
Darren Tucker | 56347ef | 2013-05-17 13:28:36 +1000 | [diff] [blame] | 73 | printf 'ssh2-localhost-with-alias,127.0.0.1,::1 ' |
Damien Miller | 38cd435 | 2002-05-01 13:17:33 +1000 | [diff] [blame] | 74 | ${SSHKEYGEN} -if ${SRC}/dsa_ssh2.pub |
| 75 | ) >> $OBJ/known_hosts |
| 76 | |
| 77 | # go for it |
| 78 | for 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 |
| 113 | done |
| 114 | |
| 115 | rm -rf ${OBJ}/${USER} |
| 116 | for 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 |
| 119 | done |