lazygit
lazygit copied to clipboard
Permission denied (public key) for hosted gitlab
Topic
I can't use SSH to contact a git(lab) repository, but are forced to a https url as remote.
In Lazygit i'm unable to fetch or push data, because of authentication problem.
Permission denied (public key)
Your thoughts I would expect that at least I'm prompted to enter my passphare for my private key. That isn't happening, so I assume that this is the reason why it fails. How does lazygit work with HTTPS git repostories? Can someone please help me?
Nice to have feaure: It would also be interesting in lazygit if it caches the password or the decrypted private key as long the process runs.
are forced to a https url as remote
I would expect that at least I'm prompted to enter my passphare for my private key.
I'm not sure I understand, if you use https
, why are there RSA
keys involved?
The permission denied (public key)
sounds like an error message from git
, as if it is using the wrong key, but let's try to solve the previoue question first.
Sorry, you're right. We also use SSH by default.
I can enter "git fetch" in my windows command line, then I have to enter my passphrase and then the fetch is done. If I press "f" ind lazygit to fetch data, I still get the error: permission denied (public key)
How should that work in lazygit?
I didn't configure sshCommand in my .gitconfig file, but I think it is working by default on the command line because I have the default file path with
~/.ssh/id_rsa
I also entered sshCommand = ssh -i ~/.ssh/id_rsa
, but it didn't make any difference.
I can enter "git fetch" in my windows command line, then I have to enter my passphrase and then the fetch is done
Do you have any other keys except the default one, id_rsa
? Do you have any entries for that key in ~/.ssh/config
?
How should that work in lazygit?
It should prompt you for the passphrase without any special configuration from your side. You should be able to use this feature without a config at all.
I know that in my experience, the very first git fetch
through lazygit
after a reboot results in a Enter your passphrase
prompt from lazygit
.
Nice to have feaure: It would also be interesting in lazygit if it caches the password or the decrypted private key as long the process runs.
If anyone is supposed to do that, it's git
, and not lazygit
. You could use a ssh-agent
like keygen.
Just a safety check, are you using the latest lazygit
version, namely v0.35
?
My version is very outdated.
> scoop list Installed apps:
Name Version Source Updated Info
---- ------- ------ ------- ----
7zip 19.00 main 2020-03-26 07:52:09
git 2.26.0.windows.1 main 2020-03-26 07:52:31
lazygit 0.17.4 extras 2020-03-26 07:59:19
I updated to 0.35 now. But the error remains.
I have an ~/.ssh/config file. It contains another authentication for another host.
But in my case now, I want to access gitlab.cas.de. I removed temporary the other authentication, now my .config file looks like this
Host origin
Hostname gitlab.cas.de
User Ingo.Siebert
IdentityFile ~/.ssh/id_rsa
My remote on my git repository is defined that way
[remote "origin"]
url = [email protected]:smartwe/test.git
That is odd.
Command log
(toggled in the menu under @
) should show that pressing f
results in git pull --no-edit --ff-only
or something similar. Does running the same command that appears in the Command log
work from the cli?
For fetch it looks like this
git fetch on my command line works.
If i press f on the branches tab, the executed command is
git pull --no-edit --ff-only "origin" "master"
It works also on the command line, but not in lazygit.
Would you be willing to try and reproduce that in a docker
container?
Take an ubuntu image, install git
and lazygit
, clone the repo and try fetching through lazygit
. Don't forget to enter the container
as your user, and not root
, for which you'll need to mount /etc/passwd
and use -u$(id -u):$(id -g)
when launching it.
I'm here on a Windows 10 machine and have to solve it here.
I have an Ubuntu 20.04 in WSL2 on that machine. The Linux in WSL2 uses the same home dir with the same .ssh/ files.
I've checked out the repositry there, installed lazygit and it works as expected. I was asked for the passphrase.
But I have to get it work with the Windows command line/power shell.
Ah, yes, since this isn't a bug report, there wasn't a template for you to fill out so I didn't know it were windows in question.
Windows do seem to have a bit more problems with lazygit
. Thanks for letting us know, we'll get back to you with further ideas and/or solutions!
Please let me know if I can support you and provide further details.
I have same situation too. I am using ssh remote.
When i push commits, command log says permission denied. But when i check the github, i can see the commits
I'm also facing the same issue. But it only happens on Windows, not macOS or Linux.
Facing the same issue but on Linux. Says no permission, publickey/password denied but the commit goes through. Repo set up using SSH on self-hosted Gitea (Forgejo).
Same issue, Windows 10, lazygit 0.38.2, github + ssh with passphrase and key file with not default name
I found a solution for Windows 10!
Need to:
- Install component OpenSSH client (if not installed)
- Enable service
ssh-agent
(Set-Service ssh-agent -StartupType Automatic; Start-Service ssh-agent
) - Set up Git to use OpenSSH form Windows (
git config --global core.sshcommand "C:/Windows/System32/OpenSSH/ssh.exe
) - In each session, add a key to ssh-agent (
ssh-add path/to/key
)
https://poshsecurity.com/blog/using-the-openssh-client-included-in-windows-10-1809-as-your-gits-ssh-client
Hey i'm also having this issue, tried @SeryiBaran suggestion but now i'm getting:
FYI: Its because credentials might be in https://github.com/git-ecosystem/git-credential-manager (GCM). I have the problem too. No idea how to solve it.