r/github • • 2d ago

Question Setting up SSH

I'm on Linux MX and I'm having trouble connecting my computer to my repos, to clone and what-not.

I think I'm following the guide on it. I want to use GitFiend to manage my projects, but using got in the command line it first throws an key authentication error and asks if I want to continue anyway. I say yes and it creates a "known_hosts" file, but then throws a permission denied error.

I can't tell what I'm doing wrong. These were my steps:

1 - Created a ~/.ssh directory

2 - ssh-keygen -t ed25519 -C "teclo+teal@disroot.org"
Inserted "github" as the key file names and left without password (also tried my password for Github on other attempts)

3 - eval "$(ssh-agent -s)"

4 - ssh-add github

5 - ssh-add -L and echo "$SSH_AUTH_SOCK" as just checks, but they didn't seem to say anything I could recognize as a problem.

6 - created ~/.ssh/config and added

Host git@github.com
   ForwardAgent yes

7 - Opened ~/.profile and added ssh-add ~/.ssh/github

8 - The text in ~/.ssh/github.pub is added to GitHub.

0 Upvotes

8 comments sorted by

View all comments

3

u/andeeeeeeeeer 1d ago edited 1d ago

I think it's your ~/.ssh/config. Host matches the hostname you connect to, so "Host git@github.com" never matches anything.

Change it to:

```
Host github.com
IdentityFile ~/.ssh/github
IdentitiesOnly yes
```

and drop the ForwardAgent line, you don't need it. Since you named the key "github" instead of id_ed25519, ssh won't pick it up on its own, that's why the config matters. Also check the key actually landed in ~/.ssh and not in whatever folder you ran ssh-keygen from. Then test with ssh -T git@github.com before going back to GitFiend.

1

u/Sal_Iko 1d ago

Thank you! That seems to be the problem. Just to be clear, after doing the correction, I tried cloning with the git command and got this ("Wicked Haywire" is one of my projects):

Cloning into 'Wicked_Haywire'...
The authenticity of host 'github.com (20.250.119.67)' can't be established.
ED25519 key fingerprint is SHA256:+DiY3wvvV6TuJJhbpZisF/zLDA0zPMSvHdkr4UvCOqU.
This key is not known by any other names.
Are you sure you want to continue connecting (yes/no/[fingerprint])?

I replied "yes" and this came up:

Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
remote: Enumerating objects: 1236, done.
remote: Counting objects: 100% (346/346), done.
remote: Compressing objects: 100% (179/179), done.
remote: Total 1236 (delta 198), reused 263 (delta 135), pack-reused 890 (from 1)
Receiving objects: 100% (1236/1236), 3.04 MiB | 402.00 KiB/s, done.
Resolving deltas: 100% (709/709), done.

But GitFiend can now access my repos fine, so far.