Composer on pipeline failed

I have spent whole day to troubleshoot this issue. Someone please assist me.

I am using private repositories and the pipelines jobs have been working fine before.

I have followed the tutorials online closely

  • Created ssh key pair
  • Create a group variable that contains the private key
  • Create and enabled deploy key on repositories within the group so they will have have access

with the following .gitlab-ci.yml

before_script:
  ##
  ## Install ssh-agent if not already installed, it is required by Docker.
  ## (change apt-get to yum if you use an RPM-based image)
  ##
  - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client -y )'

  ##
  ## Run ssh-agent (inside the build environment)
  ##
  - eval $(ssh-agent -s)

  ##
  ## Add the SSH key stored in SSH_PRIVATE_KEY variable to the agent store
  ## We're using tr to fix line endings which makes ed25519 keys work
  ## without extra base64 encoding.
  ## https://gitlab.com/gitlab-examples/ssh-private-key/issues/1#note_48526556
  ##
  - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null

  ##
  ## Create the SSH directory and give it the right permissions
  ##
  - mkdir -p ~/.ssh
  - chmod 700 ~/.ssh
  
  - ssh-keyscan -t rsa gitlab.com >> ~/.ssh/known_hosts
  - chmod 644 ~/.ssh/known_hosts

when reached to composer, it failed with the following:

  - Installing my/repo (v1.0.7): Downloading (connecting...)Downloading (0%)               Failed to download my/repo from dist: Could not authenticate against gitlab.com
    Now trying to download from source
  - Installing my/repo (v1.0.7): Cloning 2eed0203db from cache

It was working before and I realised 2 days ago it stopped working. Not sure if I have set any settings accidentally that causes this.