SSH Agent, SSH Keys/Identities, Composer, Repositories in composer.json on Windows 11

So my client shared a repository on a private GitLab platform with me. I have access to the platform and the repo and added SSH key to my account that I generated using PuTTY Gen. I then used TortoiseGit to clone it using my SSH key. It worked as expected and the repository was cloned into the WWW directory of my WAMP server. 

Then I used Git Bash to execute the following command to install composer packages

composer install

It showed some errors like this extension is required, that extension is missing. To avoid these errors for now, I ran the following command

composer install --ignore-platform-reqs

It executed and then at some point it started asking me for password. I noticed that its a different repository. I looked into the composer.json and found that it requires another repo. I asked client to grant me permission for the repo and he instantly gave that. I tried again and again, but composer install keep failing due to some password instead of asking for passphrase of my private key.

So to fix this, I first had to check if I can SSH to the GitLab platform. So I ran the following command

ssh -i path/to/my/private/key -T git@gitlab.inchev.com

It asked for my passphrase and then it said welcome.

Now I had to add my SSH identity to Git Agent, so I ran

ssh-add path/to/my/private/key

And this command gave me the following error

Could not open a connection to your authentication agent.

After asking ChatGPT about this error, it said that my SSH agent is not running and I have to run this command first to run SSH agent

eval $(ssh-agent)

As soon as I ran this it showed 

Agent pid 1755

This mean that my SSH agent is now running. So I ran the previous command again which is

ssh-add path/to/my/private/key

It then asked for the passphrase and then it confirmed that my identity was added. Then I ran the composer install command and it worked as expected

composer install --ignore-platform-reqs


I learnt that,

  1. there is something called SSH agent which I have to start. However I still don't know if I have to run this manually each time or not or what is the use of this thing
  2. there can be a section called repositories in composer.json 
  3. I can add my SSH key to SSH agent and it won't ask for passphrase again
  4. I can use --ignore-platform-reqs when running composer install command to avoid platform requirements by composer

Forgot to mention, I also created SSH key using the Git Bash as it was saying the key that I generated using PuTTY Gen. Let see how I did that

ssh-keygen -t ed25519 -C "your_email@example.com"

Here I placed my that email address that I used to login to my account on that given Git Platform

It asked for where to save the keys, I entered the following

d:/my-keys/new-key

Then it asked for my passphrase, I entered that

Then the process completed

Comments

Popular posts from this blog

Installing/Moving WSL packages on another drive or folder than the default one

Create user and SEO friendly URL slugs for your website in PHP