Mercurial > google-authenticator
annotate Makefile @ 2:ecf6bac512ae default tip
cleanup make for c6/c7/fedora
author | Carl Byington <carl@five-ten-sg.com> |
---|---|
date | Tue, 14 Mar 2017 18:42:47 -0700 |
parents | 0e3c9806a620 |
children |
rev | line source |
---|---|
0 | 1 # |
2 # based on http://blog.boa.nu/2012/11/two-factor-ssh-login-google-authenticator-and-selinux.html | |
3 # | |
4 | |
5 r := $(shell grep Wrote: mylog | grep -v debuginfo | awk '{print $$2}') | |
6 b := $(shell basename ${r}) | |
7 m := google-authenticator.pp | |
2
ecf6bac512ae
cleanup make for c6/c7/fedora
Carl Byington <carl@five-ten-sg.com>
parents:
1
diff
changeset
|
8 c6 := $(shell grep -q 'CentOS .* 6' /etc/system-release && echo 1 || echo 0) |
ecf6bac512ae
cleanup make for c6/c7/fedora
Carl Byington <carl@five-ten-sg.com>
parents:
1
diff
changeset
|
9 sy := $(shell which systemctl 2>/dev/null) |
0 | 10 |
11 all: | |
2
ecf6bac512ae
cleanup make for c6/c7/fedora
Carl Byington <carl@five-ten-sg.com>
parents:
1
diff
changeset
|
12 yum -y install pam-devel selinux-policy-devel qrencode-devel |
0 | 13 rpmbuild --rebuild google-authenticator-1.0-0.gita096a62.fc24.6.src.rpm >mylog 2>&1 |
14 grep Wrote: mylog | |
2
ecf6bac512ae
cleanup make for c6/c7/fedora
Carl Byington <carl@five-ten-sg.com>
parents:
1
diff
changeset
|
15 [ ${c6} -eq 1 ] && make -f /usr/share/selinux/devel/Makefile |
0 | 16 |
17 install: | |
18 [ -f ${r} ] || /bin/false | |
19 yum -y install ${r} | |
2
ecf6bac512ae
cleanup make for c6/c7/fedora
Carl Byington <carl@five-ten-sg.com>
parents:
1
diff
changeset
|
20 [ ${c6} -eq 1 ] && semodule -i ${m} |
0 | 21 sed -i -e 's/PAM-1.0/PAM-1.0\nauth required pam_google_authenticator.so nullok/g' /etc/pam.d/sshd |
22 sed -i -e 's/^ChallengeResponseAuthentication no/ChallengeResponseAuthentication yes/g' /etc/ssh/sshd_config | |
2
ecf6bac512ae
cleanup make for c6/c7/fedora
Carl Byington <carl@five-ten-sg.com>
parents:
1
diff
changeset
|
23 [ -z "${sy}" ] && service sshd restart || systemctl restart sshd.service |
0 | 24 |
25 setup: | |
26 google-authenticator | |
2
ecf6bac512ae
cleanup make for c6/c7/fedora
Carl Byington <carl@five-ten-sg.com>
parents:
1
diff
changeset
|
27 # authenticator setup creates the file with the wrong label on C6 |
0 | 28 restorecon ~/.google_authenticator |
29 | |
30 | |
31 install-remote: | |
32 scp ${r} ${m} $$target:/tmp | |
33 ssh $$target "cd /tmp; yum -y install ${b}" | |
34 ssh $$target "cd /tmp; semodule -i ${m}" | |
35 ssh $$target "sed -i -e 's/PAM-1.0/PAM-1.0\nauth required pam_google_authenticator.so nullok/g' /etc/pam.d/sshd" | |
36 ssh $$target "sed -i -e 's/^ChallengeResponseAuthentication no/ChallengeResponseAuthentication yes/g' /etc/ssh/sshd_config" | |
37 ssh $$target "service sshd restart" | |
38 | |
39 # make install-remote target=host.domain.tld |