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
1 | 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
1 | 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
1 | 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
1 | ssh -add path /to/my/private/key |
And this command gave me the following error
1 | 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
1 | eval $( ssh -agent) |
As soon as I ran this it showed
1 | Agent pid 1755 |
This mean that my SSH agent is now running. So I ran the previous command again which is
1 | 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
1 | composer install --ignore-platform-reqs |
I learnt that,
- 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
- there can be a section called repositories in composer.json
- I can add my SSH key to SSH agent and it won't ask for passphrase again
- I can use --ignore-platform-reqs when running composer install command to avoid platform requirements by composer
1 | ssh -keygen -t ed25519 -C "your_email@example.com" |
1 | d: /my-keys/new-key |
Comments
Post a Comment