obsidian-git icon indicating copy to clipboard operation
obsidian-git copied to clipboard

Not able to push

Open Jack-Chronicle opened this issue 4 years ago • 14 comments

Hey, love the plug-in. But I'm not able to get it to push commits It shows the login, but it keeps giving me an error about not being able to reach the host or find the repo... Which definitely exists, and it's the right login as well I'm able to make a work around of manually pushing it through GitKraken if I need to, but would love to not have to go through the extra steps if at all possible

Jack-Chronicle avatar Jan 13 '21 12:01 Jack-Chronicle

+1 Running on Windows 10, ssh key set up for github.com. Can push manually with git cli.

trydalch avatar Jan 18 '21 07:01 trydalch

+1 Running on linux, ssh key also set up and also correctly pushing via CLI.

tklosek0 avatar Feb 01 '21 11:02 tklosek0

+1 but able to resolve after disable and reinstall the plugin again on Windows 10.

desktopofsamuel avatar Feb 15 '21 01:02 desktopofsamuel

If anyone is encountering this issue, make sure you have the Disable Push setting toggled off (see the screenshot) and restart Obsidian

image

6220119 avatar Feb 17 '21 10:02 6220119

When I'm not using Obsidian (writing, editing, etc.) it works fine, but when I use it is when the error appears. I think that it is somewhat similar to the error that appears in the file explorer when you try to move or rename a file while it's still open.

notalexnot avatar Feb 24 '21 01:02 notalexnot

Issue

⚠️ On MacOS (at least Mojave 10.14.6), the following error occurs when obsidian-git attempts to push commits to the remote repository.

git-error.js:33 Uncaught (in promise) Error: Pushing to [email protected]:ebouchut/obsidian-eric.git
ssh_askpass: exec(/usr/X11R6/bin/ssh-askpass): No such file or directory
no such identity: /Users/eric/.ssh/ids/github.com/id_rsa: No such file or directory
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

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

Cause

Here is my understanding of the problem. As Obsidian is not launched from the shell but as a UI program, whose parent is launchd it does not benefit from the environment variables appropriately set by the shell hence it does not find the keys in your ssh-agent. In fact, it searches for keys in launchd's keystore.

Workaround

✅ The workaround is to install a program named ssh-askpass thatobsidian-git uses to popup a small window asking you to enter your keystore's passphrase and adds the key in launchd's keystore.

Here is how I solved this issue:

brew tap theseal/ssh-askpass
brew install ssh-askpass
sudo ln -s /usr/local/bin/ssh-askpass /usr/X11R6/bin/ssh-askpass
  • Log out then log back in.
  • Edit ~/.ssh/config and add the 2 lines AddKeysToAgent yes and UseKeychain yes to the Host github.com section, so that you are not asked for the passphrase each time obdisian-git pushes to the remote.
Host github.com
     User git
     Hostname github.com
     #
     # use only the publickey authentication method
     # Default is  publickey,password,keyboard-interactive,hostbased
     # PreferredAuthentications publickey
     #
     IdentityFile  ~/.ssh/id_rsa
     # Use only the key specified in IdentityFile,
     # ignoring the keys already loaded in ssh-agent
     IdentitiesOnly yes
     AddKeysToAgent yes  # <===
     UseKeychain yes        # <===

ebouchut avatar Mar 14 '21 18:03 ebouchut

Hi,

I was having the same problem even though I followed @ebouchut's workaround. Turns out my problem was the permissions on the ~/.ssh/config file. After doing chmod 600 ~/.ssh/config it worked properly without an issue. Hope this helps in case anyone is still having the problem after the workaround.

mcanueste avatar Apr 01 '21 22:04 mcanueste

~~Hi, I'm encountering this issue as well for just the past few days.~~ ~~Latest versions of Obsidian Git, Obsidian, System, ect.~~ ~~Running Obsidian via the flathub flatpak build, on Fedora 33.~~ ~~Obsidian Git used to pop up a box asking for me to enter my ssh key password, and now just fails to push.~~ ~~Confirmed push works via command line and server is reachable.~~

Update: I ran the commands listed here: https://github.com/denolehov/obsidian-git/issues/23#issuecomment-806401774 and that fixed it.

AmberCronin avatar Apr 09 '21 22:04 AmberCronin

Hello, I'm on linux and tried replicating the steps outlined by https://github.com/denolehov/obsidian-git/issues/39#issuecomment-798955390 but the UseKeychain yes property seems to be a MacOS thing, and I can't get it working. I'm on Linux and installed obsidian from the AUR (https://aur.archlinux.org/packages/obsidian/). At the moment I'm prompted for my passphrase whenever obsidian-git tries to backup, this is pretty annoying so I'm turning off the "backup every X mins" option for the time being, tho i'd love to use it. I have my keychain properly setup and everything so, any help on getting obsidian to access it?

zkwinkle avatar Aug 11 '21 02:08 zkwinkle

Hi @ zkwinkle Try adding this to ~/.ssh/config:

IgnoreUnknown UseKeychain

This will prevent errors about UseKeychain not being recognized on Linux. If it keeps bothering you to enter the password each and every time you push we will dig on the cache side.

ebouchut avatar Aug 11 '21 06:08 ebouchut

Yup, still bothers me to enter password each and every time, and also I have to input it twice for some reason? I'm very lost, this is my ~/.ssh/config file just in case:

Host gitlab.com
     Hostname gitlab.com
     #
     # use only the publickey authentication method
     # Default is  publickey,password,keyboard-interactive,hostbased
     # PreferredAuthentications publickey
     #
     IdentityFile  ~/.ssh/id_ed25519
     # Use only the key specified in IdentityFile,
     # ignoring the keys already loaded in ssh-agent
     IdentitiesOnly yes
     AddKeysToAgent yes  # <===
     IgnoreUnknown UseKeychain
     UseKeychain yes        # <===

zkwinkle avatar Aug 13 '21 18:08 zkwinkle

@zkwinkle Has the ssh key a passphrase and if so, do you have to enter it when you use it via command line?

Vinzent03 avatar Oct 14 '21 11:10 Vinzent03

chmod 600 ~/.ssh/config worked for me

jasenmichael avatar Jan 04 '22 02:01 jasenmichael

I tend to forget the steps for setting up and configuring ssh until I start working with it again. In my case, I just needed to open the .git/config inside the root directory and after installing this plugin and setting up my github client. I already had ssh configured with ssh-agent and globally to use my ssh key with github so better refer to another doc for this. But once you open that file change the url from https to ssh. You can grab it from your github repo under the code dropdown.

example but substitute your info so best to copy from github.

~/.ssh/config but remember to reference another document on doing this like one.

Host *
 AddKeysToAgent yes
 UseKeychain yes
 IdentityFile ~/.ssh/id_rsa

then at /Users/aricode0/Documents/Obsidian Vaults/Testing-Github/.git/config from

[remote "origin"]
	url = https://github.com/ar-to/Testing-Github.git
	fetch = +refs/heads/*:refs/remotes/origin/*

to

[remote "origin"]
	url = [email protected]:ar-to/Testing-Github.git
	fetch = +refs/heads/*:refs/remotes/origin/*

now no worries and all works.

ar-to avatar Jan 26 '22 05:01 ar-to

chmod 600 ~/.ssh/config

Did you solve the problem? I have the same problem and have not been able to solve it.

andresmgomezg avatar Oct 02 '22 21:10 andresmgomezg

Setting the branch using the command palette under Obsidian Git: Switch branch worked for me. Somehow it got unset, IDK when and stopped working. Setting it again fixed it.

jvsteiner avatar Dec 29 '22 10:12 jvsteiner

For the ~/.ssh/config file, the GitHub Docs state you should add:

Host *.github.com AddKeysToAgent yes UseKeychain yes IdentityFile ~/.ssh/id_ed25519 (changing the SSH key file to match your setup)

I found that this was actually the problem after looking at @ar-to comment.

Changing the Host to * or github.com fixed the problem. So it should read

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

OR

Host github.com (or whatever repository you are using) AddKeysToAgent yes UseKeychain yes IdentityFile ~/.ssh/id_ed25519

ospknb avatar Jan 07 '23 21:01 ospknb

chmod 600 ~/.ssh/config worked for me

This also did the trick for me in Linux. I was getting the following error before:

node:internal/process/task_queues:96 Uncaught (in promise) Error: Bad owner or permissions on /home/<user>/.ssh/config fatal: Could not read from remote repository.

umamibeef avatar Feb 01 '23 18:02 umamibeef

Setting the branch using the command palette under Obsidian Git: Switch branch worked for me. Somehow it got unset, IDK when and stopped working. Setting it again fixed it.

thanks!

eltonleao avatar Jun 19 '23 22:06 eltonleao

Setting the branch using the command palette under Obsidian Git: Switch branch worked for me. Somehow it got unset, IDK when and stopped working. Setting it again fixed it.

thanks from me too, fixed my issue!

kindofliz avatar Jul 20 '23 13:07 kindofliz

For future generations about what was the reason of the issue and how I fixed it. I have arch with latest obsidian from AUR.

Steps that led me to this error:

  1. I tried to clone an obsidian repo from github.com
  2. Git asked me if I trust the remote server
  3. I said yes
  4. It added record to ~/.ssh/known_hosts
  5. I successfully used obsidian with this plugin to work with this repo folder locally

At some moment I deleted ~/.ssh/known_hosts and then tried to use obsidian with obsidian-git plugin enabled. It didn't work because during automatic pull at the start git was showing that confirmation dialog again and the plugin wasn't able to handle it correctly.

Step to fix the error:

  1. Open the terminal
  2. Go to your repo folder
  3. run git pull simply to invoke this "do you trust the remote server" dialog
  4. answer yes
  5. restart obsidian

Now the error will go away

nikelborm avatar Feb 24 '24 22:02 nikelborm