(no commit message)
[devwiki.git] / ConfiguringRHEL.mdwn
1 First we need to install and configure moonshot, its dependencies, and a local RADIUS server for testing<br />
2 In a real deployment, a local RADIUS server is not needed, however it simplifies testing if one is available<br />
3 __gss-server__ and __gss-client__ are standard Kerberos diagnostic tools, which give us a lot of information that is helpful for debugging<br />
4 Again, in a real deployment these are not required, but help with testing
5
6 This guide walks through deploying the client, IdP and SP portions of moonshot - depending on your target, some steps may be inappropriate.
7
8 ## Environment
9 ### LD_LIBRARY_PATH
10 __LD_LIBRARY_PATH__ has to have _/opt/moonshot/lib64/_ and _/usr/lib64/freeradius_ added to it.<br />
11 The best way to do this is create a file at _/etc/profile.d/moonshot.sh_, with the following:
12
13     if [ [ $LD_LIBRARY_PATH != */opt/moonshot/lib64/:/usr/lib64/freeradius/* ] ]
14     then
15         export LD_LIBRARY_PATH=/opt/moonshot/lib64/:/usr/lib64/freeradius/:$LD_LIBRARY_PATH
16     fi
17
18 This is required as moonshot currently stores its modified libraries separately to the main system ones to avoid conflicts.  This should not be necessary in the future.
19
20
21 ### SELinux set to permissive
22 Moonshot has a couple of outstanding issues regarding proper labeling of _SELinux_ contexts, causing it to fail when _SELinux_ is enforcing.  This should be resolved soon - change the setting in _/etc/sysconfig/selinux_, or in _/etc/rc.local_:
23
24     echo 0 > /selinux/enforce
25
26 ### EPEL
27 Moonshot needs __EPEL__ for a few extra libraries (as pulling them from a semi-supported repository is preferable to repackaging).<br />
28 The simplest way to install EPEL is:
29
30     yum install epel-release
31
32 ## Moonshot Packages
33 The RPM's and SRPM's for moonshot are currently hosted at [http://yum.dev.ja.net] - this may change (and in fact, is quite likely to change) in the future.  The packages are currently unsigned.  
34
35
36
37 First we need to install and configure moonshot, its dependencies, and a local RADIUS server for testing
38 In a real deployment, a local RADIUS server is not needed, however it simplifies testing if one is available
39 __gss-server__ and __gss-client__ are standard Kerberos diagnostic tools, which give us a lot of information that is helpful for debugging
40 Again, in a real deployment these are not required, but help with testing
41
42 This guide walks through deploying the client, IdP and SP portions of moonshot - depending on your target, some steps may be inappropriate.
43
44 ## Environment
45 ### LD_LIBRARY_PATH
46 __LD_LIBRARY_PATH__ has to have _/opt/moonshot/lib64/_ and _/usr/lib64/freeradius_ added to it.<br />
47 The best way to do this is create a file at _/etc/profile.d/moonshot.sh_, with the following:
48
49     if [ [ $LD_LIBRARY_PATH != */opt/moonshot/lib64/:/usr/lib64/freeradius/* ] ]
50     then
51         export LD_LIBRARY_PATH=/opt/moonshot/lib64/:/usr/lib64/freeradius/:$LD_LIBRARY_PATH
52     fi
53
54 This is required as moonshot currently stores its modified libraries separately to the main system ones to avoid conflicts.  This should not be necessary in the future.
55
56
57 ### SELinux set to permissive
58 Moonshot has a couple of outstanding issues regarding proper labeling of _SELinux_ contexts, causing it to fail when _SELinux_ is enforcing.  This should be resolved soon - change the setting in _/etc/sysconfig/selinux_, or in _/etc/rc.local_:
59
60     echo 0 > /selinux/enforce
61
62 ### EPEL
63 Moonshot needs __EPEL__ for a few extra libraries (as pulling them from a semi-supported repository is preferable to repackaging).<br />
64 The simplest way to install EPEL is:
65
66     yum install epel-release
67
68 ## Moonshot Packages
69 The RPM's and SRPM's for moonshot are currently hosted at [[http://yum.dev.ja.net]] - this may change (and in fact, is quite likely to change) in the future.  The packages are currently unsigned.<br />
70 Example _/etc/yum.repos.d/moonshot.repo_
71
72     [Moonshot]
73     name=Moonshot
74     baseurl=http://yum.dev.ja.net/RPMS/x86_64/
75     gpgcheck=0
76
77 After setting up the repository definition, we'll set up a composite ORPS/IdP.
78
79 ##Moonshot IdP
80 To install the diagnostic tools (only needed for testing) and the RADIUSd:
81
82     yum install freeradius krb5-moonshot-devel moonshot-gss-eap
83
84
85 Once FreeRADIUS is installed, a source of identity needs to be enabled - either the roaming network in the case of an ORPS, or AD/LDAP/etc for an IdP.  For now, we'll just use a flat file.  Open _/etc/raddb/users_ and locate the following fragment:
86
87
88     # This is a complete entry for "steve". Note that there is no Fall-Through
89     # entry so that no DEFAULT entry will be used, and the user will NOT
90     # get any attributes in addition to the ones listed here.
91     #
92     #   steve   Cleartext-Password := "testing"
93     #   Service-Type = Framed-User,
94     #   Framed-Protocol = PPP,
95
96 Uncomment the line beginning __steve__.
97
98 __Chargeable-User-Identity__ is the value used to decide what user account to log in the user as on the SSH server.<br />
99 This value would normally be set by your local RADIUS proxy (ORPS) – so in a real deployment, rather than statically logging the user in as __moonshot__ you may decide to use something like __steve-camford.ac.uk__.<br />
100 If anonymity is required, you could use a Perl or Python script to generate something like __user-789-camford.ac.uk__.<br />
101 The exact value does not matter – only that the mappings are consistent, so that the user gets access to the same local account each time.
102 To allow creation of accounts on demand you could use __LDAP__ – when the ORPS sees a successful authentication, it could trigger a script that creates the desired account in an __LDAP__ domain.
103 It is not guaranteed that __Chargeable-User-Identity__ will be used permanently – in the future a specific RADIUS attribute may be created instead.
104
105 To activate CUI insertion, Edit _/etc/raddb/sites-enabled/default_, and find the post-auth section, and add the following:
106
107     update reply {
108         Chargeable-User-Identity = "moonshot"
109     }
110
111 Note in the case of an ORPS you need to unfilter this attribute in _/etc/raddb/attrs_ to prevent this attribute from being stripped on roaming requests.
112
113 A legacy attribute required for SSH at this time is the user name returned by the IdP.  To make this happen, Edit _/etc/raddb/sites-enabled/inner-tunnel_, find the following and uncomment it:
114
115                 #update outer.reply {
116                 #       User-Name = "%{request:User-Name}"
117                 #}
118
119 Finally, set the EAP type in use by moonshot (EAP-TTLS) by editing _/etc/raddb/eap.conf_ 
120
121     default_eap_type = md5
122  
123 FreeRADIUS now has a very minimal IdP/ORPS configuration, and can be started with:
124
125     service radiusd restart
126
127
128 If you encounter any issues, you can run radius in debug mode to see what is going on internally.
129
130     service radiusd stop
131     radiusd -X
132
133 When in debug mode, FreeRADIUS acts as an interactive program, so it should be run on a separate console, or under GNU Screen.
134
135 ##Moonshot Proper
136 First we need a minimal _/etc/radsec.conf_
137
138     dictionary = "/etc/raddb/dictionary"
139     
140     realm gss-eap {
141         type = "UDP"
142         timeout = 5
143         retries = 3
144         server {
145             hostname = "127.0.0.1"
146             service = "1812"
147             secret = "testing123"
148         }
149     }
150
151 This tells the moonshot SP where to find a RADIUS server for authentication - in this case, we will use the local server just configured.<br />
152 Moonshot will ultimately use RADSEC for communicating with the radius server – in which case you would use __transport="TCP"__ in _/etc/radsc.conf_<br />
153 Ultimately, the final values depend on the deployment – probably the address, port and secret used by your ORPS.
154
155 ###gss_eap_id
156
157 Next, a file is created in the home directory at _~/.gss_eap_id_ – this is the file that moonshot looks in for credentials.
158 The format is very simple – username followed by a password.  For now, set it to:
159     steve
160     testing
161
162 In a deployment with a GUI, this file is replaced by the Moonshot Identity Selector.  It is conceivable in the future that the Identity Selector GUI will be supplemented with a curses-like UI, or other mechanism allowing console usage.
163
164 ###Shibboleth
165
166 Moonshot uses _libshib_ to parse RADIUS and SAML attributes – SAML assertions can be embedded inside RADIUS responses by the IdP, allowing an ORPS to exercise a very fine-grained authorization policy.
167 In the demo we just use a very simple example – mapping the _Chargeable-User-Identity_ to a local user account, but in a real deployment you could map a SAML attribute to the user account just as easily.
168
169 Delete _/etc/shibboleth/attribute-map.xml_ and replace it with:
170
171     <Attributes xmlns="urn:mace:shibboleth:2.0:attribute-map" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
172         <GSSAPIAttribute name="urn:ietf:params:gss-eap:radius-avp urn:x-radius:89" id="local-login-user"/>
173     </Attributes>
174
175 In this case, 89 corresponds to _Chargeable-User-Identity_, which is mapped to _local-login-user_, which sets the local account that the user will be given access to.
176
177 To load the moonshot extensions, under the root node in _/etc/shibboleth/shibboleth2.xml_, add:
178     <Extensions>
179         <Library path="plugins.so" fatal="true"/>
180     </Extensions>
181
182 Further down the same file, find this line:
183
184     <AttributeExtractor type="XML" validate="true" path="attribute-map.xml"/>
185
186 Directly underneath it, add:
187
188     <AttributeExtractor type="GSSAPI" validate="true" path="attribute-map.xml"/>
189
190 Note that this file is sensitive to the order of statements.
191
192 ###/etc/gss/mech
193
194 This file tells moonshot what encryption options are valid for use with GSS.
195
196     #
197     # Sample mechanism glue configuration for EAP GSS mechanism.
198     #
199     # Any encryption type supported by Kerberos can be defined as the
200     # last element of the OID arc.
201     #
202     eap-aes128          1.3.6.1.4.1.5322.22.1.17        mech_eap.so
203     eap-aes256          1.3.6.1.4.1.5322.22.1.18        mech_eap.so
204
205 ##Testing Functionality
206
207 As mentioned earlier, we will be using the Kerberos test tools to make sure that things are working.<br />
208 To start the _gss-server_, run:
209     /opt/moonshot/sbin/gss-server host@localhost &
210
211 There are two ways to start _gss-client_ – the first specifies an encryption method to use by its OID 1.3.6.1.4.1.5322.22.1.18 (as seen in /etc/gss/mech):
212     /opt/moonshot/bin/gss-client -mech "{1 3 6 1 4 1 5322 22 1 18}" 127.0.0.1 host@localhost bar
213
214
215 The second uses __Simple and Protected GSSAPI Negotiation Mechanism (SPNEGO)__<br />
216 This chooses the "best" mutually-agreeable encryption method for between client and server.  To invoke the client using __SPNEGO__, use:
217     /opt/moonshot/bin/gss-client -spnego 127.0.0.1 host@localhost bar
218
219 ##Sample Output
220
221     Attribute local-login-user Authenticated Complete
222     
223     moonshot
224     
225     6d6f6f6e73686f74
226     
227     UID: 501
228     Accepted connection: "steve"
229     Sending init_sec_context token (size=150)...continue needed...
230     
231     context flag: GSS_C_MUTUAL_FLAG
232     context flag: GSS_C_REPLAY_FLAG
233     context flag: GSS_C_SEQUENCE_FLAG
234     context flag: GSS_C_CONF_FLAG 
235     context flag: GSS_C_INTEG_FLAG 
236     "steve" to "host/moonbuildcentos.dev.ja.net", lifetime -1, flags 13e, locally initiated, open
237     Name type of source name is { 1 2 840 113554 1 2 1 1 }.
238     Mechanism { 1 3 6 1 5 5 2 } supports 4 names
239       0: { 1 2 840 113554 1 2 1 1 }
240       1: { 1 2 840 113554 1 2 1 2 }
241       2: { 1 2 840 113554 1 2 1 3 }
242       3: { 1 2 840 113554 1 2 1 4 }
243     Received message: "testing"
244     Signature verified.
245     NOOP token
246
247 Running _gss-client_ produces a massive amount of output.<br />
248 The important part is at the end – you should see output similar to what is on the previous slide.<br />
249 If you do not see the line:
250     Attribute local-login-user Authenticated Complete
251 Then attribute mapping is not functioning properly, and you need to check your shibboleth configuration.
252
253 ##SSH
254 To install moonshot-enabled SSH:
255
256     yum install openssh-moonshot-clients openssh-moonshot-server
257
258
259 Inside _/etc/ssh/sshd\_config_, and if these values are not set already:<br />
260 Uncomment __UsePrivilegeSeparation__ and set it to __‘no’__
261
262         UsePriviligeSeparation no
263
264 Uncomment __GSSAPIAuthentication__ and set it to __‘yes’__
265
266         GSSAPIAuthentication yes
267
268 Uncomment __GSSAPIKeyExchange__ and set it to __‘yes’__
269
270         GSSAPIKeyExchange yes
271
272 Inside _/etc/ssh/ssh\_config_ and if these values are not set already:<br />
273 Uncomment __GSSAPIAuthentication__ and set it to __‘yes’__
274
275         GSSAPIAuthentication yes
276
277 Uncomment __GSSAPIKeyExchange__ and set it to __‘yes’__
278
279         GSSAPIKeyExchange yes
280
281 ###Running SSH
282
283 Finally, we need to start sshd on a seperate port:
284
285     /opt/moonshot/sbin/sshd –p 2222
286
287 At this time we do not recommend running __openssh-moonshot__ as the systemwide SSH client or server – it should be installed alongside the the standard SSH client and server.<br />
288 Also note, that sshd must be invoked with its full path, i.e. _/opt/moonshot/sbin/sshd._
289
290 Finally, try connecting with the following:
291
292     /opt/moonshot/bin/ssh –p 2222 –l "" 127.0.0.1
293
294 With any luck, magic happens and you are logged in as the user specified in your _Chargeable-User-Identity_!<br />
295 After successfully logging in, don’t forget to type __exit__ to end the SSH session and return to the root shell.<br />
296 Note in the SSH client command, the option __-l ""__ – this signifies that no username is to be sent to the SSH server. 
297
298 ##Remote IdP
299 This is left for an exercise for the user - at this stage it should just be a case of changing _/etc/radsec.conf_ to point at the right RADIUSd