This package enables Google Cloud OS Login features on Google Compute Engine instances.
Table of Contents
The OS Login package has the following components:
In addition to the main components, there are also utilities for packaging and installing these components:
.deb
and .rpm
packages for the OS Login components.The google_authorized_keys
binary is designed to be used with the sshd AuthorizedKeysCommand option in sshd_config
. It does the following:
http://metadata.google.internal/computeMetadata/v1/oslogin/users?username=<username>
http://metadata.google.internal/computeMetadata/v1/oslogin/authorize?email=<user_email>&policy=login
The nss_oslogin
module is built and installed in the appropriate lib
directory as a shared object with the name libnss_oslogin.so.2
. The module is then activated by an oslogin
entry in /etc/nsswitch.conf
. The NSS module supports looking up passwd
entries from the metadata server via getent passwd
.
http://metadata.google.internal/computeMetadata/v1/oslogin/users?pagesize=<pagesize>
http://metadata.google.internal/computeMetadata/v1/oslogin/users?username=<username
http://metadata.google.internal/computeMetadata/v1/oslogin/users?uid=<uid>
The pam_module
directory contains two modules used by Linux PAM (Pluggable Authentication Modules).
The first module, pam_oslogin_login.so
, determines whether a given user is allowed to SSH into an instance. It is activated by adding an account requisite
line to the PAM sshd config file and does the following:
http://metadata.google.internal/computeMetadata/v1/oslogin/users?username=<username>
http://metadata.google.internal/computeMetadata/v1/oslogin/authorize?email=<user_email>&policy=login
The second module, pam_oslogin_admin.so
, determines whether a given user should have admin (sudo) permissions on the instance. It is activated by adding an account optional
line to the PAM sshd config file and does the following:
http://metadata.google.internal/computeMetadata/v1/oslogin/users?username=<username>
http://metadata.google.internal/computeMetadata/v1/oslogin/authorize?email=<user_email>&policy=adminLogin
/var/google-sudoers.d/
. The file gives the user sudo privileges./var/google-sudoers.d/
if it exists.oslogin_utils
contains common functions for making HTTP calls, interacting with the metadata server, and for parsing JSON objects.
The bin
directory contains a shell script called google_oslogin_control
that activates or deactivates the OS Login features. It is called in the pre and post install scripts in the .deb
and .rpm
packages. The control file performs the following tasks:
sshd_config
and restarts sshd.oslogin
to (from) nsswitch.conf
.account
entries to (from) the PAM sshd config. Also adds (or removes) the pam_mkhomedir.so
module to automatically create the home directory for an OS Login user./var/google-sudoers.d/
directory, and a file called google-oslogin
in /etc/sudoers.d/
that includes the directory.The packaging
directory contains files for creating .deb
and .rpm
packages. See Source Packages for details.
The policy
directory contains .te
(type enforcement) files used by SELinux to give the OS Login features the appropriate SELinux permissions. These are compiled using checkmodule
and semodule_package
to create an oslogin.pp
that is intstalled in the appropriate SELinux directory.
There is currently support for creating packages for the following distros:
Note: the packaging/setup_deb.sh
script performs these steps, but is not production quality.
sudo apt-get -y install make g++ libcurl4-openssl-dev libjson-c-dev libpam-dev
sudo apt-get -y install debhelper devscripts build-essential
google-compute-engine-oslogin_M.M.R.orig.tar.gz
using the files in this directory, excluding the packaging
directory (where M.M.R is the version number)..orig.tar.gz
file and copy the appropriate debian
directory into the top level. (e.g. When working on Debian 8, copy the debian8
directory to a directory named debian
within the code directory.)debbuild -us -uc
Note: the packaging/setup_rpm.sh
script performs these steps, but is not production quality.
sudo yum -y install make gcc-c++ libcurl-devel json-c json-c-devel pam-devel policycoreutils-python
sudo yum -y install rpmdevtools
google-compute-engine-oslogin_M.M.R.orig.tar.gz
using the files in this directory, excluding the packaging
directory (where M.M.R is the version number).rpmbuild
and a subdirectory called SOURCES
. Copy the .orig.tar.gz
file into the SOURCES
directory.SPECS
directory from the rpmbuild
directory here into the rpmbuild
directory you created.rpmbuild --define "_topdir /path/to/rpmbuild" -ba /path/to/rpmbuild/SPECS/google-compute-engine-oslogin.spec
When updating version numbers, changes need to be made in a few different places:
Makefile
Update the MAJOR, MINOR, and REVISION variables.packaging/debian8/changelog
Add a new entry with the new version.packaging/debian9/changelog
Add a new entry with the new version.packaging/debian8/google-compute-engine-oslogin.links
Update the libnss version string.packaging/debian9/google-compute-engine-oslogin.links
Update the libnss version string.packaging/rpmbuild/SPECS/google-compute-engine-oslogin.spec
Update the Version field.packaging/setup_deb.sh
Update VERSION variable.packaging/setup_rpm.sh
Update VERSION variable.