0

Hi guys I'm on a osx machine and I want to push commits from a remote machine through tramp to github. I open the directory in dired on the remote machine which works fine and type M-x magit status which leads me to the status page of the repo and here I wannt to push via P and pbut I get the following error

128 git … push -v origin han\:refs/heads/han
Pushing to git@github.com:username/reponame.git

fatal: Could not read from remote repository.

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

The interesting part of this is, when I log in onto the machine via a terminal session and do a git push there it works flawlessly. So I do have the proper access rights to the repository. The ssh key is added to my local machine and the remote machine. What am I missing here? Why isn't this working in the mentioned setup?

  • Look at forwarding "ForwardAgent" (in .ssh/config) or "ssh -A" from the command line. This can be tested with ssh host ssh-add -l from your local machine (osx). – RTLinuxSW Jan 10 '18 at 22:09
  • I added ForwardAgent yes to my local config and AllowAgentForwarding yes on the server but it didn't work. – daeda Jan 16 '18 at 21:32
  • Try again after starting Emacs from a shell instead of by clicking on an icon. If that works, then the reason that it doesn't work otherwise is that your shell configuration has no effect when not using a shell, and you have to somehow carry over that configuration. – tarsius Jan 29 '18 at 14:59
  • Err, never mind, it only doesn't work for you when using Tramp, so this shouldn't make a difference. Regardless, the issue likely falls into the same category. There is some configuration but it doesn't take effect, and you have to figure out how to change that. I'm afraid I cannot help with that. – tarsius Jan 29 '18 at 15:08
0

The interesting part of this is, when I log in onto the machine via a terminal session and do a git push there it works flawlessly. So I do have the proper access rights to the repository. The ssh key is added to my local machine and the remote machine.

This is a very common issue even when only pushing from the local machine. It works from a shell but not when using Magit. The cause for this is always the same -- the shell has been properly configured to allow pushing while Emacs has not.

What am I missing here? Why isn't this working in the mentioned setup?

Magit isn't actually involved in this at all. It just calls git push and whether that works or not depends on whether the appropriate environment variables are set or not.

The reason it often does not work is that many users set (or unknowingly have some tool do so) the relevant variables in the shell's init file. Then they click on an icon to start emacs. Unless emacs is started from a shell it does not inherit its environment.

So it is possible to get this to work merely by typing emacs& in a shell instead of clicking on an icon. If that works then you can start looking into what variables are set in the shell but not emacs environment by comparing the output of env to the value of process-environment.

Possibly all that is need is that you set ForwardAgent and AllowAgentForwarding. But I know nothing about agent forwarding so this might not be enough.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.