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.
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.
2
u/ImDevinC 1d ago
https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
Did you follow the guide?
3
u/houseoftrees_ 1d ago
lol learn the basics before downloading whatever the fuck Gitfiend is, god my heart weeps for society
1
u/SlowPlan8945 1d ago
You have two small issues in your setup causing the
Permission denied (publickey)error:1. Your
~/.ssh/configsyntax is wrong In Step 6,Hosttakes the domain name, notuser@domain, and you didn't tell SSH which key file to use (since it's namedgithubinstead of the defaultid_ed25519).Replace your
~/.ssh/configcontents with:Code snippet
2. Check where you ran Step 2 & 4 In Step 2, typing
"github"without a full path creates./githubin whatever directory your terminal was currently in, rather than~/.ssh/github. Make sure bothgithubandgithub.pubactually live inside~/.ssh/:Bash
(Note: That initial authenticity prompt asking if you want to continue connecting is normal on your first connection to GitHub—you didn't do anything wrong there.)
Test it: Run
ssh -T git@github.com. If it saysHi <username>! You've successfully authenticated..., you're good to go. (You can also removessh-addfrom~/.profileonceIdentityFileis in your config, as SSH will load it automatically.)You have two small issues in your setup causing the Permission denied (publickey) error:1. Your ~/.ssh/config syntax is wrongIn Step 6, Host takes the domain name, not user@domain, and you didn't tell SSH which key file to use (since it's named github instead of the default id_ed25519).Replace your ~/.ssh/config contents with:Code snippet
Host github.com
HostName github.com
User git
IdentityFile ~/.ssh/github
IdentitiesOnly yes
2. Check where you ran Step 2 & 4
In Step 2, typing "github" without a full path creates ./github in whatever directory your terminal was currently in, rather than ~/.ssh/github. Make sure both github and github.pub actually live inside ~/.ssh/:Bash
mv ~/github* ~/.ssh/ 2>/dev/null
chmod 700 ~/.ssh
chmod 600 ~/.ssh/github
chmod 644 ~/.ssh/github.pub
(Note: That initial authenticity prompt asking if you want to continue connecting is normal on your first connection to GitHub—you didn't do anything wrong there.)Test it:
Run ssh -T git@github.com. If it says Hi <username>! You've successfully authenticated..., you're good to go. (You can also remove ssh-add from ~/.profile once IdentityFile is in your config, as SSH will load it automatically.)