22
33set -ex
44
5- echo " Starting ssh daemon..."
6- TMPDIR=${TMPDIR:-/ tmp}
7- HOME=` mktemp -d ${TMPDIR} /home.XXXXXXXX`
8- SSHD_DIR=` mktemp -d ${TMPDIR} /sshd.XXXXXXXX`
5+ if [ -z " $SKIP_SSH_TESTS " ]; then
96
10- cat > " ${SSHD_DIR} /sshd_config" << -EOF
7+ echo " Starting ssh daemon..."
8+ TMPDIR=${TMPDIR:-/ tmp}
9+ HOME=` mktemp -d ${TMPDIR} /home.XXXXXXXX`
10+ SSHD_DIR=` mktemp -d ${TMPDIR} /sshd.XXXXXXXX`
11+
12+ cat > " ${SSHD_DIR} /sshd_config" << -EOF
1113Port 2222
1214ListenAddress 0.0.0.0
1315Protocol 2
@@ -26,29 +28,30 @@ StrictModes no
2628# Required here as sshd will simply close connection otherwise
2729UsePAM no
2830EOF
29- ssh-keygen -t rsa -f " ${SSHD_DIR} /id_rsa" -N " " -q
30- /usr/sbin/sshd -f " ${SSHD_DIR} /sshd_config" -E " ${SSHD_DIR} /log"
31+ ssh-keygen -t rsa -f " ${SSHD_DIR} /id_rsa" -N " " -q
32+ /usr/sbin/sshd -f " ${SSHD_DIR} /sshd_config" -E " ${SSHD_DIR} /log"
3133
32- # Set up keys
33- mkdir " ${HOME} /.ssh"
34- ssh-keygen -t rsa -f " ${HOME} /.ssh/id_rsa" -N " " -q
35- cat " ${HOME} /.ssh/id_rsa.pub" >> " ${HOME} /.ssh/authorized_keys"
36- while read algorithm key comment; do
37- echo " [localhost]:2222 $algorithm $key " >> " ${HOME} /.ssh/known_hosts"
38- done < " ${SSHD_DIR} /id_rsa.pub"
34+ # Set up keys
35+ mkdir " ${HOME} /.ssh"
36+ ssh-keygen -t rsa -f " ${HOME} /.ssh/id_rsa" -N " " -q
37+ cat " ${HOME} /.ssh/id_rsa.pub" >> " ${HOME} /.ssh/authorized_keys"
38+ while read algorithm key comment; do
39+ echo " [localhost]:2222 $algorithm $key " >> " ${HOME} /.ssh/known_hosts"
40+ done < " ${SSHD_DIR} /id_rsa.pub"
3941
40- # Append the github.com keys for the tests that don't override checks. Some
41- # older libssh2 versions don't like it unless we have ssh-rsa in here. This also
42- # tests that the automatic selection off of known_hosts is working.
43- ssh-keyscan -t ssh-rsa github.com >> " ${HOME} /.ssh/known_hosts"
42+ # Append the github.com keys for the tests that don't override checks. Some
43+ # older libssh2 versions don't like it unless we have ssh-rsa in here. This also
44+ # tests that the automatic selection off of known_hosts is working.
45+ ssh-keyscan -t ssh-rsa github.com >> " ${HOME} /.ssh/known_hosts"
4446
45- # Get the fingerprint for localhost and remove the colons so we can
46- # parse it as a hex number. Older versions have a different output
47- # format.
48- if [[ $( ssh -V 2>&1 ) == OpenSSH_6* ]]; then
49- SSH_FINGERPRINT=$( ssh-keygen -F ' [localhost]:2222' -f " ${HOME} /.ssh/known_hosts" -l | tail -n 1 | cut -d ' ' -f 2 | tr -d ' :' )
50- else
51- SSH_FINGERPRINT=$( ssh-keygen -E md5 -F ' [localhost]:2222' -f " ${HOME} /.ssh/known_hosts" -l | tail -n 1 | cut -d ' ' -f 3 | cut -d : -f2- | tr -d :)
47+ # Get the fingerprint for localhost and remove the colons so we can
48+ # parse it as a hex number. Older versions have a different output
49+ # format.
50+ if [[ $( ssh -V 2>&1 ) == OpenSSH_6* ]]; then
51+ SSH_FINGERPRINT=$( ssh-keygen -F ' [localhost]:2222' -f " ${HOME} /.ssh/known_hosts" -l | tail -n 1 | cut -d ' ' -f 2 | tr -d ' :' )
52+ else
53+ SSH_FINGERPRINT=$( ssh-keygen -E md5 -F ' [localhost]:2222' -f " ${HOME} /.ssh/known_hosts" -l | tail -n 1 | cut -d ' ' -f 3 | cut -d : -f2- | tr -d :)
54+ fi
5255fi
5356
5457# Create a test repo which we can use for the online tests
@@ -65,16 +68,18 @@ git daemon --listen=localhost --port=9419 --export-all --base-path=$HOME/_temp_r
6568# On Actions we start with 777 which means sshd won't let us in
6669chmod 750 $HOME
6770
71+ export GITTEST_REMOTE_REPO_PATH=" $HOME /_temp/test.git"
6872export GITTEST_REMOTE_GIT_RO_URL=" git://localhost:9419/testrepo.git"
6973export GITTEST_REMOTE_GIT_URL=" git://localhost/test.git"
70- export GITTEST_REMOTE_SSH_URL= " ssh://localhost:2222/ $HOME /_temp/test.git "
71- export GITTEST_REMOTE_SSH_USER= $USER
72- export GITTEST_REMOTE_SSH_KEY= " $HOME /.ssh/id_rsa "
73- export GITTEST_REMOTE_SSH_PUBKEY =" $HOME /.ssh/id_rsa.pub "
74- export GITTEST_REMOTE_SSH_PASSPHRASE= " "
75- export GITTEST_REMOTE_REPO_PATH= " $HOME /_temp/test.git "
74+ if [ -z " $SKIP_SSH_TESTS " ] ; then
75+ export GITTEST_REMOTE_SSH_URL= " ssh://localhost:2222/ $HOME /_temp/test.git "
76+ export GITTEST_REMOTE_SSH_USER= $USER
77+ export GITTEST_REMOTE_SSH_KEY =" $HOME /.ssh/id_rsa"
78+ export GITTEST_REMOTE_SSH_PUBKEY= " $HOME /.ssh/id_rsa.pub "
79+ export GITTEST_REMOTE_SSH_PASSPHRASE= " "
7680
77- eval $( ssh-agent)
78- ssh-add $GITTEST_REMOTE_SSH_KEY
81+ eval $( ssh-agent)
82+ ssh-add $GITTEST_REMOTE_SSH_KEY
83+ fi
7984
8085bundle exec rake -- --with-ssh || exit $?
0 commit comments