Git SSH to Github with a Config File Stuck in a Loop

283 Views Asked by At

SSH commits to Github do work with my current setup. I use this recommended script to trigger the password prompt:

#!/bin/bash
 
eval $(ssh-agent -s)
ssh-add ~/.ssh/github_ssh_private_key

However, ever since I switched to Emacs' Magit, password prompting simply didn't happen, I still don't know why. Apparently, the recommendation to fix this is to use a ~/.ssh/config file — I use Artix Linux. Currently, my config file looks like this — even though I've tried many, many other variations —:

Host github.com
  HostName github.com
  IdentityFile /home/philippe/.ssh/github_ssh_private_key

This simplifies the workflow overall, as a prompt now appears both in the terminal and on Emacs, i.e. I don't have to run the eval ... ssh-agent script anymore. However, typing my correct password simply doesn't achieve anything, the prompt reappears on the line below endlessly.

Strangely, the password/passphrase prompt changes slightly across the mentioned use cases:

Enter passphrase for /home/philippe/.ssh/github_ssh_private_key:       # with the eval script
Enter passphrase for key '/home/philippe/.ssh/github_ssh_private_key': # With the `config` file

I've seen a bazillion posts on the internet about this topic, but haven't found anything official or standardized about it so far. These are my references so far:

1

There are 1 best solutions below

6
On

That needs to work in a terminal first, before Emacs.

I would add to the config file a User git line.

Once that is working, then you can check your Emacs/Maggit configuration and see if that helps.