FredrikNoren / ungit

The easiest way to use git. On any platform. Anywhere.
MIT License
10.44k stars 637 forks source link

Can't authorize over ssh. #989

Open Mourdraug opened 6 years ago

Mourdraug commented 6 years ago

I can't seem to get remote repos work over ssh. I tried multiple different ssh-agent setups and all did result with this warn:

Responding with ERROR:  {"isGitError":true,"errorCode":"permision-denied-publickey","command":"-c color.ui=false -c core.quotepath=false -c core.pager=cat -c credential.helper=C:/Users/User/AppData/Roaming/npm/node_modules/ungit/bin/credentials-helper 0 8448 ls-remote --tags origin","workingDirectory":"C:\\node_workspace\\testProject","error":"Permission denied (publickey).\r\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n","message":"Permission denied (publickey).\r","stderr":"Permission denied (publickey).\r\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n","stdout":""}
2017-11-15T11:37:19.091Z - warn: Responding with ERROR:  {"isGitError":true,"errorCode":"permision-denied-publickey","command":"-c color.ui=false -c core.quotepath=false -c core.pager=cat -c credential.helper=C:/Users/User/AppData/Roaming/npm/node_modules/ungit/bin/credentials-helper 0 8448 fetch origin --prune","workingDirectory":"C:\\node_workspace\\testProject","error":"Permission denied (publickey).\r\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n","message":"Permission denied (publickey).\r","stderr":"Permission denied (publickey).\r\nfatal: Could not read from remote repository.\n\nPlease make sure you have the correct access rights\nand the repository exists.\n","stdout":""}

I'm working on Windows 10. I'd say something seems to be wrong, since I don't even get prompted for passphrase, while everything works fine through git-bash with either identity added to ssh-agent or without (I just get prompted for passphrase).

crassibz commented 6 years ago

From the error msg I guess that it's trying to login using a key pair certificate, that's why it's not asking for a pass.You should generate a key pair (public/private) and set up the public key in the server in order to be accepted for login.

Mourdraug commented 6 years ago

Of course I did that. I generated pair on my machine and added public key to remote gitea repository. Everything works fine if I try to push or fetch from git-bash or powershell. My problem is that ungit does not even try to use my key.

jung-kim commented 6 years ago

Is your key defined in your home directory? ~/.ssh/ folder?

Mourdraug commented 6 years ago

Yes, it's located in ~/.ssh/id_rsa .

jung-kim commented 6 years ago

That's odd, ungit should have pick that up. is user that started ungit different than the own of the home dir? I am at a conference right now but will dive in to this sometime next week.

Mourdraug commented 6 years ago

I only have one user account on this system. I'd guess that Windows is in fault here, can't pinpoint direct cause tho.

EDIT: I did some more research with process monitor and found out that on refresh ssh.exe does open ~/.ssh/id_rsa file, but ungit does not prompt me for passphrase. So obviously it can't get authorized.

ylecuyer commented 6 years ago

I've got a similar issue. The best workaround I've found for the moment is to add the key to the ssh-agent so I can enter the passphrase

Mourdraug commented 6 years ago

I wasn't using ungit for quite some time, and now that I tested this again I'm pretty sure that ungit simply isn't starting ssh-agent, so it actually requires user to start agent and add all required keys to it before starting it. (ungit has to be started from the same powershell terminal as ssh-agent, otherwise it won't be able to connect) Shouldn't ungit start ssh-agent when needed and prompt for passphrase, and stop agent when it exits?

ylecuyer commented 6 years ago

I think it would be better for ungit to ask for the ssh-key password when interracting with the remote with an option to remember for the current session. (If you watch the log in the console you can see git find the key but the prompt for the password isn't pushed back in the interface by ungit)

codewisdom commented 6 years ago

I'm having this same type of authorization issue on macOS. I'm prompted to enter my passphrase for the key, but it won't accept the correct passphrase for some reason. I can push to Github with no issues using exactly the same passphrase seconds later in another terminal session.

miloslavnosek commented 5 years ago

I've had this issue on Windows and fixed by modifying the start script to start-ssh-agent && node bin/ungit. Oddly enough, starting ssh-agent manually in console and then running current start script did not fix the issue for some reason. Only when I modify the npm script. Git in terminal had no issues with credentials whatsoever, only happened in ungit and only on Windows. I've never seen this issue when running ungit on Linux.

jung-kim commented 5 years ago

I think this is an issue with credentials-helper.

You might want to add winston's file transport to see the logs but it is bit hard it is is a process that gets spawned via git.

I would have to come up with a better way to catch logs as we cannot simply output to console as it will mess with git credentials operation

jimrthy commented 5 years ago

I just ran into this on a fresh ungit install on ubuntu (with npm v10.15.3).

My git remote for this repo is ssh://gh/foo/bar. Foo and bar are fake, but gh is an alias that I've set up in ~/.ssh/config.

Hopefully helpful data point:

It's using the key ~/.ssh/keys/id_rsa.

After I started ssh-agent (which I despise: I want to enter my passphrase so I know when software is accessing one of my remote machines) and added the key, I was able to run without any problems.

francknos commented 4 years ago

Hi, I have the same problem if my ssh key dosen't named id_rsa it doesn't work for me. Even if I add config file in .ssh :

Host github.com IdentityFile ~/.ssh/NewKeyNamed_github

DaPa commented 4 years ago

I also have 2 keys (personal:id_rsa_github with password and work:id_rsa) and the .ssh\config is set to pick .ssh/id_rsa_github for Hostname github.com:

# my github account
Host github.com
    Hostname github.com
    User git
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa_github
    IdentitiesOnly yes
    AddKeysToAgent yes

Git BASH and Git GUI work fine using proper keys (asking for pass when cloning or fethcing), however Ungit fails for the github repos (doesn't ask for any password, so I guess tries with default id_rsa). I did try to add only personal or even both to agent: $ eval $(ssh-agent) && ssh-add ~/.ssh/id_rsa && ssh-add ~/.ssh/id_rsa_github Still no luck with Ungit when try to fetch. Same error:

git@github.com: Permission denied (publickey).

Anything else I should do to help Ungit? Any clues how I can debug this? Thanks! I'm on Windows 10 x64.

dails08 commented 2 years ago

I am also running into this problem from inside a Docker container. I can use git just fine from the terminal, I can authenticate using either ssh-agent or keychain, but even when I start ssh-agent manually from the command line and start ungit from the same terminal window, I still get the above error. Does it have to do with the credential helper? Can I get it to use keychain somehow?