My problem is that I can't push or fetch from GitLab. However, I can clone (via HTTP or via SSH). I get this error when I try to push :
Permission denied (publickey) fatal : Could not read from remote repository
From all the threads I've looked, here is what I have done :
- Set up an SSH key on my computer and added the public key to GitLab
- Done the config --global for username and email
- Cloned via SSH and via HTTP to check if it would resolve the issue
- Done the ssh -T git@gitlab.com command
Right now I want to punch my computer. If you have any insight about how to resolve my issue, it would be greatly appreciated.
I solved like this..
Generated a key for Windows using this command:
but the problem was that after running this command, it popped a line: "Enter file in which to save the key (/c/Users/xxx/.ssh/id_rsa): " Here, I was giving only file name because of which my key was getting saved in my pwd and not in the given location. When I did "git clone ", it was assuming the key to be at "/c/Users/xxx/.ssh/id_rsa" location but it was not found, hence it was throwing error.
At the time of key generation 2 files were generated say "file1" & "file1.pub". I renamed both these files as
and
and placed both in the location
"/c/Users/xxx/.ssh/"
In my case, it wasn't a gitlab problem, but a sshd configuration one. The ssh server didn't allow connection except for a list of users. The user git, the one connecting remotely to gitlab, wasn't in that list. So, check this before anything else.
You can check your ssh server configuration in
/etc/ssh/sshd_config
. If you have a line with the optionAllowUsers
, add git to it:Step 1: Added a config file in ~/.ssh/ folder which looks like
Step 2: Just clone the git repo WITHOUT sudo.
I think the simple solution is to add private key to authentication agent (if your key is not
~/.ssh/id_rsa
),You basically let the
ssh-agent
take care of it.Additionally, you can add it permanently.
Go to the terminal and regenerate the ssh key again. Type
ssh-keygen
. It will ask you where you want to save it, type the path.Then copy the public key to gitlabs platform. It usually starts with ssh-rsa.
I have gitlab running with docker, this is what I did to fix my problem.
Found that inside docker /var/log/gitlab/sshd/current there were multiple occurences of a message:
After which I changed ownership of that file from 99:users to git:users with: