This repo contains the code for ☝️. And the RPM itself is under releases.
You may want to read my article about this solution first: "Dynamic MOTD on Centos 7, like on Ubuntu".
Or you may just scroll down and start using this. :)
It works! 🎉
If you trust me then do the following:
yum install https://github.com/gdubicki/centos-pam-with-update-motd/releases/download/1.1.8-1022.3/pam-1.1.8-1022.el7.x86_64.rpm
If not, then no hard feelings - PAM is a pretty critical part of GNU/Linux so it is wise to be careful. Please skip to the Building your own binary below for info how to build your own binary.
- Delete the default static
/etc/motd
. - Make SSHD not show the static MOTD with lines
PrintMotd no
,Banner none
,UsePAM yes
(and optionallyPrintLastLog no
) in your/etc/ssh/sshd_config
& reloadsshd
service. - Add this line to your
/etc/pam.d/sshd
:session optional pam_motd.so motd=/run/motd.dynamic
. - Add some scripts to generate your dynamic MOTD in
/etc/update-motd.d
.
Test it by SSHing to your machine.
Try to run the same command as PAM is to generate your dynamic MOTD: run-parts-debian --lsbsysinit /etc/update-motd.d
and check if it shows any output.
If yes then please open an issue in this repo, I will try (but not promise) to help.
If not then please check your scripts in /etc/update-motd.d
for:
- permissions - they should be at least readable and executable by root (
0500
), - file names - they have to have LSB init-compatible names, good:
10hello
, bad:10_hello
(!),
If above conditions are not met then they will fail to run without a warning! Yeah, it's a pain but that's how it works in Ubuntu too and we are using the same code for compatibility...
If you want to build the RPMs using code in this repo on your machine then please do the following:
- Docker
Obviously.
Let's use the branch of the latest as of now LTS version of Ubuntu, 16.04 (Xenial Xerus):
cd debian-run-parts-for-centos/
git clone --single-branch --branch ubuntu/xenial https://git.launchpad.net/ubuntu/+source/debianutils
This step is optional as I have pushed gdubicki/debian-run-parts-for-centos
Docker image to Dockerhub,
so you can just pull it in the next step.
# assuming that you still are in debian-run-parts-for-centos/ subdir
docker build --tag gdubicki/debian-run-parts-for-centos .
(About that autoreconf
: Debian sources contain files generated by autoconf 1.16 while
Centos 7 contains autoconf 1.13, which is incompatible with them. Therefore we need to
run autoheader, aclocal, automake, autopoint and libtoolize as required using this command.
Source: https://stackoverflow.com/a/33286344/2693875)
# assuming that you still are in debian-run-parts-for-centos/ subdir
docker run -it \
-v $(pwd)/bin:/root/bin \
-v $(pwd)/Makefile.am:/root/debianutils/Makefile.am \
gdubicki/debian-run-parts-for-centos:latest \
/bin/bash -c "cd /root/debianutils ; autoreconf -f -i ; ./configure ; make ; cp run-parts /root/bin/"
Created binary file will be placed in bin
subdirectory.
In this case c7
is the branch of Centos 7:
# cd to update-motd subdirectory of this repo
git clone --single-branch --branch c7 https://git.centos.org/rpms/pam.git
This step is optional as I have pushed gdubicki/centos-pam-with-update-motd
Docker image to Dockerhub,
so you can just pull it in the next step.
# assuming that you are are in update-motd/ subdir
docker build --tag gdubicki/centos-pam-with-update-motd .
# assuming that you still are in update-motd/ subdir
cp ../debian-run-parts-for-centos/bin/run-parts bin/run-parts-debian
# assuming that you still are in update-motd/ subdir
docker run -it \
-v $(pwd)/bin/run-parts-debian:/root/rpmbuild/SOURCES/run-parts-debian \
-v $(pwd)/pam.spec:/root/rpmbuild/SPECS/pam.spec \
-v $(pwd)/pam-1.1.8-update-motd.patch:/root/rpmbuild/SOURCES/pam-1.1.8-update-motd.patch \
-v $(pwd)/rpmbuild/RPMS:/root/rpmbuild/RPMS \
gdubicki/centos-pam-with-update-motd:latest \
/bin/bash -c "spectool --get-files -C /root/rpmbuild/SOURCES/ /root/rpmbuild/SPECS/pam.spec ; rpmbuild --define '_topdir /root/rpmbuild' -bb /root/rpmbuild/SPECS/pam.spec"
Created RPMs will be places in the RPMS
directory.
(Points 1. & 2. that were here are done!)
- Add a build pipeline running in GitHub (Travis? Circle CI? Note to self: building in DockerHub seems to not work, avoid.)
run-parts as a part of debianutils package is distributed under GPL v2.
PAM license is attached in the pam.LICENSE file.
update-motd patch has been written at Canonical by Dustin Kirkland, probably under GPL v2. The patch has been downloaded from here: https://git.launchpad.net/ubuntu/+source/pam/tree/debian/patches-applied/update-motd
Centos PAM package is also licensed under GPL v2.
So this code is also licensed under GPL v2 ...right? 😅