I am trying to setup GitLab CI/CD for our project.
It has to git clone from another private repository, so we’ve setup the deploy token as described here
[Deploy keys | GitLab](https://Deploy keys)
++ ssh -vvv git@gitlab.com
OpenSSH_7.9p1 Debian-10+deb10u2, OpenSSL 1.1.1d 10 Sep 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
Pseudo-terminal will not be allocated because stdin is not a terminal.
debug2: resolving "gitlab.com" port 22
debug2: ssh_connect_direct
debug1: Connecting to gitlab.com [172.65.251.78] port 22.
debug1: Connection established.
debug1: identity file /root/.ssh/id_rsa type -1
debug1: identity file /root/.ssh/id_rsa-cert type -1
debug1: identity file /root/.ssh/id_dsa type -1
debug1: identity file /root/.ssh/id_dsa-cert type -1
debug1: identity file /root/.ssh/id_ecdsa type -1
debug1: identity file /root/.ssh/id_ecdsa-cert type -1
debug1: identity file /root/.ssh/id_ed25519 type -1
debug1: identity file /root/.ssh/id_ed25519-cert type -1
debug1: identity file /root/.ssh/id_xmss type -1
debug1: identity file /root/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_7.9p1 Debian-10+deb10u2
ssh_exchange_identification: read: Connection timed out
We’ve verified that the deploy key works from our local machines.
Does anybody know what is causing this?
It appears your initial issue is not the only one, but here is a snippet from a CI that I have that I hope you can use or learn from.
I strongly advise against disabling Host Key checking as this leaves you vulnerable to a Man-in-the-middle type attack. Instead, add the host key to your known hosts.
before_script:
- yum install -y git openssh-clients
## Start ssh-agent (ssh key manager) and add SSH key stored in
## SSH_PRIVATE_KEY variable to agent store
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIV_KEY")
## Set up SSH directory
- mkdir ~/.ssh
- chmod 700 ~/.ssh
- echo "$TRUSTED_HOSTS" > ~/.ssh/known_hosts
- chmod 600 ~/.ssh/known_hosts