diff --git a/lib/travis/build/bash/travis_disable_ssh_roaming.bash b/lib/travis/build/bash/travis_disable_ssh_roaming.bash index af1c5c8ffd..30bf91579d 100644 --- a/lib/travis/build/bash/travis_disable_ssh_roaming.bash +++ b/lib/travis/build/bash/travis_disable_ssh_roaming.bash @@ -2,6 +2,8 @@ travis_disable_ssh_roaming() { mkdir -p "${TRAVIS_HOME}/.ssh" chmod 0700 "${TRAVIS_HOME}/.ssh" touch "${TRAVIS_HOME}/.ssh/config" + ssh-keygen -R github.com + curl -L https://api.github.com/meta | jq -r ".ssh_keys | .[]" | sed -e "s/^/github.com /" >> ~/.ssh/known_hosts echo -e "Host *\\n UseRoaming no\\n" | cat - "${TRAVIS_HOME}/.ssh/config" >"${TRAVIS_HOME}/.ssh/config.tmp" && mv "${TRAVIS_HOME}/.ssh/config.tmp" "${TRAVIS_HOME}/.ssh/config" diff --git a/lib/travis/vcs/git/ssh_key.rb b/lib/travis/vcs/git/ssh_key.rb index 1941f962bc..227bd77b74 100644 --- a/lib/travis/vcs/git/ssh_key.rb +++ b/lib/travis/vcs/git/ssh_key.rb @@ -12,10 +12,12 @@ def apply sh.chmod 600, '~/.ssh/id_rsa', echo: false sh.raw 'eval `ssh-agent` &> /dev/null' sh.raw 'ssh-add ~/.ssh/id_rsa &> /dev/null' + sh.raw 'ssh-keygen -R github.com' + sh.raw 'curl -L https://api.github.com/meta | jq -r ".ssh_keys | .[]" | sed -e "s/^/github.com /" >> ~/.ssh/known_hosts' # BatchMode - If set to 'yes', passphrase/password querying will be disabled. # TODO ... how to solve StrictHostKeyChecking correctly? deploy a known_hosts file? - sh.file '~/.ssh/config', "Host #{data.source_host}\n\tBatchMode yes\n\tStrictHostKeyChecking no\n", append: true + sh.file '~/.ssh/config', "Host #{data.source_host}\n\tBatchMode yes\n", append: true end private