-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathldap-auth
165 lines (100 loc) · 4.01 KB
/
ldap-auth
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
on 18.04
TODO: add note about how kerberos is prefered.
sudo apt update;
sudo apt-get install -y ldap-utils libpam-ldap libnss-ldap nslcd
Or, if buggy, use:
sudo apt-get install -y ldap-utils libpam-ldap libnss-ldapd nslcd
https://bugs.launchpad.net/ubuntu/+source/libnss-ldap/+bug/1024475
==========
during package install:
on install, specify the server like this:
ldap://192.168.2.3/ ldap://192.168.3.4:389/
Search base / base DN
OU=Accounts,DC=example,DC=com
Used LDAP3 (offered 2 and 3). - MAY NEED TO REVISIT
Make local root DB admin? NO - needs root credentials on the box
DB require login? - NO for now
NSLCD config
ldap servers:
ldap://192.168.2.3/ ldap://192.168.3.4:389/
Search base / base DN
OU=Accounts,DC=example,DC=com
============
Config files;
sudo nano:
/etc/nsswitch.conf
Add "ldap" to end of lines passwd, group, and shadow.
They'll now look something like:
```
passwd: compat systemd ldap
group: compat systemd ldap
shadow: compat ldap
```
# THIS PART NOT WORKING WITH HOMEDIR CREATION
open /etc/pam.d/login
(trying common-auth instead of login)
Go to bottom, paste:
```
# LDAP configs
session required pam_mkhomedir.so skel=/etc/skel umask=0022
```
# skipping lightdm on servers
# Need bind DN:
sudo nano /etc/nslcd.conf
Add bind DN like this:
binddn cn=annonymous,dc=example,dc=net
bindpw secret
Do exactly the same in /etc/ldap.conf
Then open /etc/nslcd.conf. Add the following line:
```
pam_login_attribute sAMAccountName
displayName
```
# Restart services
```
sudo update-rc.d nslcd enable
sudo /etc/init.d/nscd restart
```
Should work now, but reboot for safe keeping
THIS WORKED for local auth, assuming the user is creatred. You can run 'su [username]'
and become a user, after querying LDAP with PW.
A few notes:
* Look into local password handling - should just disable this? or cache them?
* Need to write a script to create users, or do that on request
* SSH key handling
* Look into the default mappings below
* In particular, pamfilter to query who can log in
* Look into setting `timelimit 30 and bind_timelimit 30` lower so system is responsive with no dc connectivity
* Test network breakage
* UID assign
* Test local pw changes
* LDAPS
* Group delegation
* host restrictions
* https://www.digitalocean.com/community/tutorials/how-to-authenticate-client-computers-using-ldap-on-an-ubuntu-12-04-vps
* change config `sudo dpkg-reconfigure ldap-auth-config`
* Research SSH login vs SU login
```
# RFC 2307 (AD) mappings
#nss_map_objectclass posixAccount user
#nss_map_objectclass shadowAccount user
nss_map_attribute uid sAMAccountName
#nss_map_attribute homeDirectory unixHomeDirectory
nss_map_attribute shadowLastChange pwdLastSet
#nss_map_objectclass posixGroup group
#nss_map_attribute uniqueMember member
# pam_login_attribute sAMAccountName
#pam_filter objectclass=User
#pam_password ad
```
Debugging steps (from stack overflow post https://askubuntu.com/questions/127389/how-to-configure-ubuntu-as-an-ldap-client)
Likely problems and solutions:
Logging in as an LDAP user takes a very long time (minutes): It's very likely that nss-lap is having problems finding the user's group. Make sure that the user is in a group recognized locally, or that the user is in a group defined in LDAP. Make sure that, if the group is defined in LDAP, that it's a real POSIX group.
Always check the /var/log/auth.log log file. If you see "unable to contact ldap server", check whether the LDAP server is reachable and the port is open.
Try to ping the LDAP server by name
Try to check whether the LDAP port is open:
LDAP can listen on different ports, but can usually be found on 389 and 636
You can check that a port is open by using telnet:
telnet 389 or telnet 636
If you see any characters on the console then the port is open and the LDAP server should be running.
If you see nothing or get an error message, either the LDAP server is not running or something (such as a firewall) is preventing the connection.