annotate Makefile @ 0:524d6c83d8ad

initial version
author Carl Byington <carl@five-ten-sg.com>
date Wed, 01 Mar 2017 10:08:26 -0800
parents
children 0e3c9806a620
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
1 #
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
2 # based on http://blog.boa.nu/2012/11/two-factor-ssh-login-google-authenticator-and-selinux.html
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
3 #
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
4
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
5 r := $(shell grep Wrote: mylog | grep -v debuginfo | awk '{print $$2}')
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
6 b := $(shell basename ${r})
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
7 m := google-authenticator.pp
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
8
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
9 all:
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
10 rpmbuild --rebuild google-authenticator-1.0-0.gita096a62.fc24.6.src.rpm >mylog 2>&1
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
11 grep Wrote: mylog
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
12 make -f /usr/share/selinux/devel/Makefile
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
13
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
14
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
15 install:
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
16 [ -f ${r} ] || /bin/false
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
17 yum -y install ${r}
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
18 semodule -i ${m}
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
19 sed -i -e 's/PAM-1.0/PAM-1.0\nauth required pam_google_authenticator.so nullok/g' /etc/pam.d/sshd
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
20 sed -i -e 's/^ChallengeResponseAuthentication no/ChallengeResponseAuthentication yes/g' /etc/ssh/sshd_config
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
21 service sshd restart
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
22
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
23
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
24 setup:
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
25 google-authenticator
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
26 # authenticator setup creates the file with the wrong label.
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
27 restorecon ~/.google_authenticator
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
28
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
29
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
30 install-remote:
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
31 scp ${r} ${m} $$target:/tmp
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
32 ssh $$target "cd /tmp; yum -y install ${b}"
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
33 ssh $$target "cd /tmp; semodule -i ${m}"
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
34 ssh $$target "sed -i -e 's/PAM-1.0/PAM-1.0\nauth required pam_google_authenticator.so nullok/g' /etc/pam.d/sshd"
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
35 ssh $$target "sed -i -e 's/^ChallengeResponseAuthentication no/ChallengeResponseAuthentication yes/g' /etc/ssh/sshd_config"
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
36 ssh $$target "service sshd restart"
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
37
524d6c83d8ad initial version
Carl Byington <carl@five-ten-sg.com>
parents:
diff changeset
38 # make install-remote target=host.domain.tld