- Install from the debian package:
sudo dpkg -i gitlabnss.deb - Configure NSS by adding
gitlabto the lines in/etc/nsswitch.confstarting withpasswd:andgroups:. - Optionally to support SSH login (via public keys added to GitLab):
Add these lines to
/etc/ssh/sshd_configAuthorizedKeysCommand /bin/fetchgitlabkeys AuthorizedKeysCommandUser root - Modify
/etc/gitlabnss/gitlabnss.confto fit your needs. Particularly: setbase_urlto the GitLab API endpoint of your choice andsecretto a FILE that contains the API key (requiresread_api). Make sure that thesecretfile can only be read by root (owner:rootand permissions0400). - Start the service: On Ubuntu run
systemctl enable gitlabnssdor/etc/init.d/gitlabnssd startto start the service.
gitlabnssd Daemon process that listens to a UNIX file socket (configured in gitlabnss.conf; default: /var/run/gitlabnss.sock) and provides means of fetching GitLab user information by ID or name. Technically, the consumers of this API (NSS and fetchgitlabkeys) could access the GitLab API directly but the API key then has to be readable by artbitrary users which is a security risk.
NSS TODO
fetchgitlabkeys If you want GitLab users to be able to login using SSH and the public keys configured in GitLab, you can direct the AuthorizedKeysCommand to use fetchgitlabkeys to load these keys. For reasons explained above, fetchgitlabkeys does not access the GitLab API directly but communicates with the daemon using gitlabnss.sock.
\dot digraph G { subgraph Files { #label = "Files"; cluster=True;
secret [color=blue];
"gitlabnss.conf" [color=blue];
};
subgraph Programs {
#label = "Programs";
cluster=True;
gitlabnssd;
authorizedkeys;
"libnss_gitlab.so";
};
"gitlabnss.sock" [color=purple];
{gitlabnssd, authorizedkeys, "libnss_gitlab.so"} -> "gitlabnss.conf" [color=blue];
gitlabnssd -> secret [color=blue];
gitlabnssd -> "gitlabnss.sock" [color=purple, label=listen];
{authorizedkeys, "libnss_gitlab.so"} -> "gitlabnss.sock" [color=purple, label=connect];
} \enddot
- Move
libnss_gitlab.sointo/usr/lib/ - Add
gitlabto/etc/nsswitch.conf
- Add these lines to
/etc/ssh/sshd_config:
AuthorizedKeysCommand /bin/fetchgitlabkeys
AuthorizedKeysCommandUser root
https://sourceware.org/glibc/manual/latest/html_mono/libc.html#NSS-Module-Names
_nss_<service>_<function>
- Create a new Release via the [https://github.com/webis-de/code-admin-gitlabnss/releases](GitHub Release page); A new action should start automatically to build the latest release and automatically adds the debian package to the released assets.