Bonjour,
Petite présentation sur comment rejoindre un serveur AD avec Debian 7.
Voici comment faire.
Présentation du cas :
Serveur AD :
Nom : my-adserv.fr
Serveur : fr-dc01.my-adserv.fr
Serveur Cible :
Nom : atmos
Serveur : atmos.my-adserv.fr
Renommer le serveur :
nano /etc/hostname
atmos.my-adserv.fr
Éditer votre Hosts :
nano /etc/hosts
127.0.0.1 localhost
127.0.1.1 atmos.my-adserv.fr
# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
Éditer votre fichier Resolv :
nano /etc/resolv.conf
domain my-adserv.fr
search my-adserv.fr
nameserver 10.10.28.55 (Selon vos DNS)
Éditer votre fichier krb5 :
nano /etc/krb5.conf
[libdefaults]
default_realm = MY-ADSERV.FR
dns_lookup_realm = false
dns_lookup_kdc = false
[realms]
MY-ADSERV.FR = {
kdc = fr-dc01.my-adserv.fr
}
[domain_realms]
.MY-ADSERV.FR = MY-ADSERV.FR
.kerberos.server = fr-dc01.MY-ADSERV.FR
[appdefaults]
pam = {
debug = false
ticket_lifetime = 36000
renew_lifetime = 36000
forwardable = true
krb4_convert = false
}
[domain_realm]
my-adserv.fr = MY-ADSERV.FR
.my-adserv.fr = MY-ADSERV.FR
Éditer votre fichier nsswitch :
nano /etc/nsswitch.conf
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd: compat winbind
group: compat winbind
shadow: compat
hosts: files dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
Éditer votre fichier smb :
nano /etc/samba/smb.conf
[global]
security = ADS
# security = DOMAIN
realm = my-adserv.fr
# password server = *
password server = fr-dc01.my-adserv.fr
workgroup = MY-ADSERV
idmap uid = 16777216-33554431
idmap gid = 16777216-33554431
winbind enum users = yes
winbind enum groups = yes
template homedir = /home/%D/%U
template shell = /bin/bash
client use spnego = yes
client ntlmv2 auth = yes
encrypt passwords = true
winbind use default domain = yes
restrict anonymous = 2
domain master = no
local master = no
preferred master = no
os level = 0
server string = %h server
obey pam restrictions = Yes
pam password change = Yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfu$
unix password sync = Yes
syslog = 1
log file = /var/log/samba/log.%m
max log size = 1000
dns proxy = No
panic action = /usr/share/samba/panic-action %d
winbind offline logon = true
[homes]
comment = Home Directories
valid users = %S
create mask = 0700
directory mask = 0700
browseable = No
Éditer votre fichier sshd_config :
nano /etc/ssh/sshd_config
# Package generated configuration file
# See the sshd_config(5) manpage for details
# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes
# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768
# Logging
SyslogFacility AUTH
LogLevel INFO
# Authentication:
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys
# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes
# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no
# Change to yes to enable challenge-response passwords (beware issues with
# some PAM modules and threads)
ChallengeResponseAuthentication no
# Change to no to disable tunnelled clear text passwords
#PasswordAuthentication yes
# Kerberos options
KerberosAuthentication yes
#KerberosGetAFSToken no
KerberosOrLocalPasswd yes
KerberosTicketCleanup yes
# GSSAPI options
GSSAPIAuthentication yes
GSSAPICleanupCredentials yes
X11Forwarding yes
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
#UseLogin no
#MaxStartups 10:30:60
#Banner /etc/issue.net
# Allow client to pass locale environment variablDOMAINes
AcceptEnv LANG LC_*
Subsystem sftp /usr/lib/openssh/sftp-server
# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication. Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.
UsePAM yes
Rejoindre le Domaine :
net ads join -U admin@my-adserv.fr
Appliquer les modifications :
pam-auth-update && reboot
Pour CentOS 6
authconfig --update && reboot
Voilà vous avez rejoint votre domaine via winbind
Si vous avez besoin de quitter un domaine :
Quitter le Domaine :
net ads leave -U admin@my-adserv.fr
Appliquer les modifications :
pam-auth-update
Pour CentOS 6
authconfig --update --disablekrb5 --disablekrb5realmdns --disablewinbind --disablewinbindkrb5
PS : Petit message d'avertissement car si vous ne savez pas ce que vous faite vous pouvez mettre en pérille votre infra de production !
Ceci est une note technique et donc en aucun cas une configuration à utiliser en production.
Il vous faut adapter les configurations selon vos besoins.