Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: Setting up Obsidian Git on a new machine, trouble with "Please make sure you have the correct access rights and the repository exists." #346

Open
ReaderGuy42 opened this issue Oct 21, 2022 · 9 comments

Comments

@ReaderGuy42
Copy link

Describe the bug

I try this git push -u origin main and get the error below. I'm trying to sync a second machine to my repo.

I've added a new SSH key to my new machine and github (I think that worked) but can't figure out what to do now.

This isn't technically in the plugin yet, since I haven't been able to get that far. Can you still help me with this?

Relevant errors (if available)

This key is not known by any other names
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com' (ED25519) to the list of known hosts.
 git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

Steps to reproduce

Try pushing to remote. Get error

Expected Behavior

No response

Addition context

No response

Operating system

Linux

Plugin version

2.8.0

@architchandra
Copy link

I'm facing the same issue. I copied over the vault (including the Git directory) onto the new machine and set up a new SSH on it. Since then, I have been able to manually push to the remote repo using the command line but always see this error when trying to push through the plugin.

@Vinzent03
Copy link
Owner

@architchandra Do you have to enter a passphrase on the command line for the ssh key?

@architchandra
Copy link

Hi @Vinzent03

I'm not sure what clicked but I'm no longer facing this issue.

I'm using a Mac and the SSH key that I created was not getting loaded into the SSH agent automatically upon login, even after adding details to a config file. So, I added a command to load the key into the agent into my .zshenv file using ssh-add --apple-load-keychain (so that application-generated commands also have access to the passphrase).

Since then I have been able to work seamlessly despite my SSH key having a passphrase. And to answer your original question, I had to enter the passphrase the first time I added my key into the SSH agent but not after that.

@chaosraine
Copy link

Dude I'm like 2 full days with this exact problem and you may have just solved it for me.
I knew it must have to do with Obsidian git having access to the passphrase but I could not for the life of me figure out what to do about it (despite other people clearly struggling with it)

Now I'm gonna go see if I can break it again, but it's fixed for now! Many thanks!!

@chaosraine
Copy link

Okay, I DID break it (I ran --apple-load-keychain from the terminal instead of adding it to the bash profile so it broke on login as expected)

But I think I figured out where it was broken in the first place. I followed the GitHub guide for setting up the SSH keys and part of that included adding it to the keychain in the config file. They suggested:

Host *.github.com
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_ed25519

I didn't have any clue if it would work, but I figured that if the problem was with obsidian-git not being able to pull from the keychain, maybe I needed to change the host. At first, I changed host to * which did work, but I wasn't sure why I couldn't include GitHub. So I made the host just *github.com (removing the . dot after the *) and now it seems to be working in Obsidian even without loading the keychain through the bash profile/zshenv (which also did work)

It was literally one dot. I'm not okay 😮‍💨

Since probably a lot of us noobs are using the GitHub guide for setup, I'd guess a lot of the publickey errors are coming from that one dot. Now I'm going to go sleep for two days straight and then work on fixing the iPad side of things that I surely broke in the process of getting this one working haha

@elvisisvan
Copy link

elvisisvan commented Aug 17, 2023

im trying to clone my private repo using Obsidian Git: Clone an existing remote repo option then i got this same error too
image

Host *.github.com
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_ed25519
At first, I changed host to * which did work, but I wasn't sure why I couldn't include GitHub. So I made the host just *github.com (removing the . dot after the *)

@chaosraine where exactly did you find this 4-line config?

@chaosraine
Copy link

chaosraine commented Aug 17, 2023

Reference

This is the guide I was using, if I'm remembering correctly
https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

The file was my .ssh/config file. You can create it using the instructions on that page (on macos). It is blank upon creation, so I pasted in the recommended example code from the github guide.

The only real problem I ran into was that it recommended using Host: *.github.com - I changed it to *github.com (without the first dot) and that's what worked!

@architchandra
Copy link

architchandra commented Aug 20, 2023

@chaosraine - This config is from Github's docs related to creating SSH keys.

From what I can remember, the given config mentioned *.github.com in the past, which is where most of us ran into trouble. Github itself seems to have changed it to just github.com in the docs now and that seems to work fine for me. Some remnants of the previous config still seem to remain eg. in the note right below the config.

Screenshot_2023-08-20_at_10_27_45_AM

An update to my previous comment: I no longer have to load in the Apple's keychain manually upon login since changing to github.com in the SSH config.

@jsco2t
Copy link

jsco2t commented Sep 13, 2024

Just wanted to report that the fix from @architchandra also solved this issue for me. I mistakenly had *.gitlab.com as the host in my config. Changing that to *gitlab.com resolved this issue.

In any case - thank you for posting your fix.

(edit: Can confirm that Host gitlab.com, with no *, also appears to work just fine)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants