If you’re like me and have recently setup a Gitlab server running on CentOS 8 or CentOS Stream for your Git-needs, then you might have ran into the issue were Gitlab is asking you for the Git users password when pushing your code for the first time.
This could be caused by SELinux being incorrectly configured for the SSH authorized keys file created by Gitlab.
To test this, first disable SELinux by running sudo setenforce 0.
Remember to enable SELinux after you’re done or if it didn’t help.
Then run ssh -T git@your-gitlab-machine, which should print back
Welcome to Gitlab, @username!.
If that’s the case, then we know that the issue is with SELinux.
To remediate the issue permanently, run the following commands:
sudo setenforce 1
sudo semanage fcontext -a -t ssh_home_t /var/opt/gitlab/.ssh/
sudo semanage fcontext -a -t ssh_home_t /var/opt/gitlab/.ssh/authorized_keys
sudo restorecon -F -Rv /var/opt/gitlab/.ssh/
Then run the test command once more and you should once again see the welcome message.
That’s it! You have now successfully configured SELinux for Gitlabs SSH files.