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 de
The problem for me was, that I switched UsePAM
from yes
to no
in the SSH configuration file under /etc/ssh/sshd_config
. With UsePAM yes
everything works perfectly.
I added my ~/.ssh/id_rsa.pub
to the list of known SSH Keys in my GitLab settings https://gitlab.com/profile/keys. That solved the problem for me. :-)
Step 1:
Added a config file in ~/.ssh/config
file which looks like
User git
Hostname gitlab.com
IdentityFile ~/.ssh/id_rsa_gitlab
TCPKeepAlive yes
IdentitiesOnly yes
Step 2: Just clone the git repo WITHOUT sudo.
Documentation: https://gitlab.com/help/ssh/README#working-with-non-default-ssh-key-pair-paths
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 option AllowUsers
, add git to it:
AllowUsers user1 user2 user3 git
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:
Authentication refused: bad ownership or modes for file /var/opt/gitlab/.ssh/authorized_keys
After which I changed ownership of that file from 99:users to git:users with:
chown git:users authorized_keys
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.