Skip to content

[Bug]: Deployment/Git clone fails: Git server with custom port and defined Commit SHA #7139

@xolyu

Description

@xolyu

Error Message and Logs

ssh: connect to host git.example.com port 22: Operation timed out
fatal: Could not read from remote repository. 

The command tries to connet to SSH port 22 (default SSH port), but the SSH port of the Git server is 222.

Coolify executes different git commands, but do not consequently passes the SSH port number.

The git clone/git fetch/git checkout command from build process (I added some line breaks for better reading):

[CMD]: docker exec kcwo0ckc4gok40cswck4wwgo bash -c 'mkdir -p /root/.ssh' && 

docker exec kcwo0ckc4gok40cswck4wwgo bash -c 'echo '<base64EncodedSshKey>' | base64 -d | tee /root/.ssh/id_rsa > /dev/null' && 

docker exec kcwo0ckc4gok40cswck4wwgo bash -c 'chmod 600 /root/.ssh/id_rsa' && 

docker exec kcwo0ckc4gok40cswck4wwgo bash -c '
GIT_SSH_COMMAND="ssh -o ConnectTimeout=30 -p 222 -o Port=222 -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa" 
git clone --depth=1 --recurse-submodules --shallow-submodules -b 'production' '[email protected]:my/repo.git' '/artifacts/kcwo0ckc4gok40cswck4wwgo' && 
cd '/artifacts/kcwo0ckc4gok40cswck4wwgo' && 
GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" git fetch --depth=1 origin v1.2.3 && 
git -c advice.detachedHead=false checkout v1.2.3 >/dev/null 2>&1 && 
cd '/artifacts/kcwo0ckc4gok40cswck4wwgo' && 
if [ -f .gitmodules ]; then git submodule sync && GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" git submodule update --init --recursive --depth=1; fi && 
cd '/artifacts/kcwo0ckc4gok40cswck4wwgo' && 
GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" git lfs pull'

Steps to Reproduce

  1. Create Resource "Private Repository (with Deploy Key)"
  2. Configure Git Source
    • Repository: [email protected]:222/my/repo.git
    • Branch: e.g. production
    • Commit SHA: e.g. v1.2.3 (not HEAD)
  3. Deploy the Application

Error Description

  1. The git clone command is executed with correct GIT_SSH_COMMAND env variable, which contains the SSH port:
    GIT_SSH_COMMAND="ssh -o ConnectTimeout=30 -p 222 -o Port=222 -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa"

  2. The git fetch command is executed with wrong GIT_SSH_COMMAND ⇒ Port is missing, so SSH tries to connect to default port 22
    GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null"

I think on every occurence of GIT_SSH_COMMAND it should looks like the first one with port and also -i option.

Example Repository URL

No response

Coolify Version

v4.0.0-beta.441

Are you using Coolify Cloud?

No (self-hosted)

Operating System and Version (self-hosted)

Ubuntu 22.04.5 LTS

Additional Information

I updated my Coolify instance today from beta.380 to beta.441. The error is present since the update, in beta.380 this worked without problems. The git clone/checkout command differs in beta.380.

The git clone command from beta.380:

[CMD]: docker exec mgk4s4k4cc8ogcw4gkcs04wk bash -c 'mkdir -p /root/.ssh' && 

docker exec mgk4s4k4cc8ogcw4gkcs04wk bash -c 'echo '<base64EncodedSshKey>' | base64 -d | tee /root/.ssh/id_rsa > /dev/null' && 

docker exec mgk4s4k4cc8ogcw4gkcs04wk bash -c 'chmod 600 /root/.ssh/id_rsa' && 

docker exec mgk4s4k4cc8ogcw4gkcs04wk bash -c 'GIT_SSH_COMMAND="ssh -o ConnectTimeout=30 -p 222 -o Port=222 -o LogLevel=ERROR -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -i /root/.ssh/id_rsa" 
git clone -b "production" [email protected]:my/repo.git /artifacts/mgk4s4k4cc8ogcw4gkcs04wk && 
cd /artifacts/mgk4s4k4cc8ogcw4gkcs04wk && GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" git -c advice.detachedHead=false checkout v1.2.3 >/dev/null 2>&1 && 
cd /artifacts/mgk4s4k4cc8ogcw4gkcs04wk && GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" git submodule update --init --recursive && 
cd /artifacts/mgk4s4k4cc8ogcw4gkcs04wk && GIT_SSH_COMMAND="ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null" git lfs pull'

In beta.380 there wasn't a git fetch – but this is the command that fails now, because of missing port in GIT_SSH_COMMAND.

Metadata

Metadata

Assignees

No one assigned

    Labels

    🔍 TriageIssues that need assessment and prioritization.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions