Cannot get git extensions to push something to github SSH problems
Solution 1
Things to check for:
- Presence of
HOME
environment variable. - Presence of
%HOME%\.ssh\
and RSA keys there.
When you run git from command promt it is preferred to run git.cmd
, because it fixes HOME
automatically:
@if not exist "%HOME%" @set HOME=%HOMEDRIVE%%HOMEPATH%
@if not exist "%HOME%" @set HOME=%USERPROFILE%
To fix gitextensions, define HOME
variable and set it to same value as USERPROFILE
Solution 2
The correct answer is the one from 'max' (set your HOME env var manually), but it may help some to understand why the problem is happening (as Git gets more users around the world it's going to be very common).
Cygwin sets $HOME to /home/yourname, but that variable is not known in the Windows environment. So if you open a bash window and do env | grep HOME you'll see all three 'HOME' variables mentioned here, and you might wonder why Gitextensions doesn't use your proper cygwin HOME - which is because its .bat file invocation doesn't see it - it only sees what you see from doing 'set' in a windows console.
It's mystifying why it doesn't do this evaluation later and get the proper cygwin path since it knows how to invoke bash, but (at least in versions up to 2.41) you have to do this manual change in the settings or in .gitconfig.
Solution 3
Yes, not setting the HOME varible was the issue for me too.
Set the HOME variable as %USERPROFILE%
and regenerate the Private and Public keys, then try cloning—it should work now.
Solution 4
When you fire up git bash directly you'll land in your home folder for MSYS. You need to make sure you have your ssh key (id_rsa ?) in the .ssh subfolder (relative to the home folder).
Solution 5
Glad you solved the problem. Since this sounds like a serious problem I'm interested in the difference between git-bash when started from GitExtensions. In GitExtensions there is a setting that might fix this. The %HOME% directory can be changed in GitExtensios. By default it will be set to %HOMEDRIVE%%HOMEPATH%, but you can override this. Changing this probably solves your problem, since you suggest this is the problem. To change this open the settings dialog and go to the tab "git". In the section "Environment" you can set the %HOME% path.
I will appreciate it if you let me know if this also solves the problem. I'm also interested in what caused this in the first place. Maybe I can improve the check for a valid HOME directory.
Admin
Updated on June 13, 2022Comments
-
Admin almost 2 years
Im trying to use git extensions and I really like it so far, but I don't manage to push to github. The following command works fine in git bash:
git push "origin" master:master
and then when I push with git extensions I get this:
C:\Program Files\Git\bin\git.exe push "origin" master:master Permission denied (publickey). fatal: The remote end hung up unexpectedly Done
In the git settings it just has openSSH selected which I would like to keep because putty seems more hassle.
The remote addres I have added in gitextensions, actually the only thing I have done from the bash just to test is the command above and gerenating the SSH keys. All else is set up in git extensions. So I suppose everything must be set up correctly. Eg, the email adress and name are correct...
ssh [email protected]
also connects fine, from bash
edit:
So I can reproduce the error by putting the command from git-extensions in cmd. Appearantly there is a difference between running from git bash and from cmd and git-extensions runs this command like a windows command... any clues?
update: If I choose git-bash from the menu in git-extensions I get a window that is exactly the same as when I right click in explorer on my repo folder and choose git bash here. Now, in the one opened from explorer I can push and in the one opened from extensions I get the public key problem.
-
Admin over 13 yearsthat is where it is yes. I usually fire ssh through the explorer shell extension so I end up in the repo immediately. Saves a lot of typing. Some new developments in the problem, check my update above.
-
Admin over 13 yearsthanks for the effort. It turns out the home variable was indeed changed beyond my awareness.
-
Admin over 13 yearsthanks for looking into it! +1 Basically, that is exactly what I did, but I think I was confused because my initial intention was just to change the location of the git config file. The text in the settings dialog for this entry says: "The global config file located in the environment stored variable %HOME%." Next it lets you choose to "Use default for HOME" or other, which gave me the impression that it related just to the config file. I think rewriting that sentence might be a good idea. Cause thinking of it now, probably git only uses this config file if called from extensions now...
-
Admin over 13 yearsAs I understand it now, git-extensions just overrides the system environment variable %HOME% for git.exe, which is not what I understood from the dialog. In my case that actually is not very desirable, unless it is consistent with the explorer shell extension. What I was looking for was to tell git to store it's settings in a custom location.
-
Bryan about 12 yearsThanks, I had a similar issue (permission denied publickey) and setting HOME variable worked.