terça-feira, 26 de junho de 2018

Server AD com Samba4 no Debian 9 - Parte 1





Server AD com Samba4 no Debian 9


O que usei:


1 - VirtualBox-5.1.22-115126-Win
2 - PUTTY
3 - debian-9.0.0-amd64-netinst (instalação básica com SSh)


Dados para configurar

Verificar dados da interface


#ip a

Configurar ip fixo


#nano  /etc/network/interfaces

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug enp0s3
iface enp0s3 inet static
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1


Configurar arquivo hosts

#nano /etc/hosts

127.0.0.1       localhost
127.0.1.1       smbdc01.resulti.tux smbdc01

# The following lines are desirable for IPv6 capable hosts
::1     localhost ip6-localhost ip6-loopback
#ff02::1 ip6-allnodes
#ff02::2 ip6-allrouters

Configurar arquivo resolv.conf


#nano /etc/resolv.conf

nameserver 192.168.0.10
nameserver 192.168.0.1
nameserver 8.8.8.8

Instalar dependências

               
                (Executar todo o comando abaixo na mesma linha - cole no putty para ficar mais fácil)

                apt-get update ; apt-get install ntp acl attr autoconf bind9utils bison build-essential debhelper dnsutils docbook-xml docbook-xsl flex gdb libjansson-dev krb5-user libacl1-dev libaio-dev libarchive-dev libattr1-dev libblkid-dev libbsd-dev libcap-dev libcups2-dev libgnutls28-dev libgpgme11-dev libjson-perl libldap2-dev libncurses5-dev libpam0g-dev libparse-yapp-perl libpopt-dev libreadline-dev nettle-dev perl perl-modules-5.24 libsystemd-dev pkg-config python-all-dev python-crypto python-dbg python-dev python-dnspython python3-dnspython python-gpgme python3-gpgme python-markdown python3-markdown python3-dev xsltproc zlib1g-dev -y

Crie o Diretório SAMBA

#mkdir SAMBA

Entre no diretório SAMBA

#cd SAMBA
               

Download da última versão do samba


wget https://download.samba.org/pub/samba/stable/samba-4.8.2.tar.gz
               
                Extraindo o arquivo - Execute execute:
                tar -zxvf samba-xyztar.gz
               
                Mude para o diretório com as fontes extraídas:
                cd samba-xyz /

Fazer compilação

               
                > Entre dentro da pasta do samba e execute os comandos abaixo um após o outro:
               
Iremos personalizar a instalação, instalando o samba dentro do diretório /opt/samba

                ./configure --prefix=/opt/samba -j 5
                make -j 5
                make install -j 5
               
                 Se o comando ./configure falhar, leia a mensagem de erro e corrija o problema.
Um problema comum é falta de dependências
Se o script configure for encerrado sem erro, você verá uma saída parecida com essa:
'configure' finished successfully (1m2.432s)


Fazer o provisionamento



#samba-tool domain provision --realm=resulti.tux --use-rfc2307 --domain=resulti --dns-backend=SAMBA_INTERNAL --adminpass=smb@640 --server-role=dc



Resultado:

root@smbdc01:~/samba/samba-4.8.2# samba-tool domain provision --realm=resulti.tux --use-rfc2307 --domain=resulti --dns-backend=SAMBA_INTERNAL --adminpass=smb@640 --server-role=dc
Looking up IPv4 addresses
Looking up IPv6 addresses
No IPv6 address will be assigned
Setting up share.ldb
Setting up secrets.ldb
Setting up the registry
Setting up the privileges database
Setting up idmap db
Setting up SAM db
Setting up sam.ldb partitions and settings
Setting up sam.ldb rootDSE
Pre-loading the Samba 4 and AD schema
Unable to determine the DomainSID, can not enforce uniqueness constraint on local domainSIDs

Adding DomainDN: DC=resulti,DC=tux
Adding configuration container
Setting up sam.ldb schema
Setting up sam.ldb configuration data
Setting up display specifiers
Modifying display specifiers and extended rights
Adding users container
Modifying users container
Adding computers container
Modifying computers container
Setting up sam.ldb data
Setting up well known security principals
Setting up sam.ldb users and groups
Setting up self join
Adding DNS accounts
Creating CN=MicrosoftDNS,CN=System,DC=resulti,DC=tux
Creating DomainDnsZones and ForestDnsZones partitions
Populating DomainDnsZones and ForestDnsZones partitions
Setting up sam.ldb rootDSE marking as synchronized
Fixing provision GUIDs
A Kerberos configuration suitable for Samba AD has been generated at /opt/samba/private/krb5.conf
Merge the contents of this file with your system krb5.conf or replace it with this one. Do not create a symlink!
Setting up fake yp server settings
Once the above files are installed, your Samba AD server will be ready to use
Server Role:           active directory domain controller
Hostname:              smbdc01
NetBIOS Domain:        RESULTI
DNS Domain:            resulti.tux
DOMAIN SID:            S-1-5-21-572021044-4051568208-157862981

Configurar arquivo kerberos


#ln -sf /opt/samba/private/krb5.conf /etc/krb5.conf

EXECUTAR O SAMBA

/caminho/da/instalacao/sbin/samba ( -i *** modo interativo )
Ex:

#/opt/samba/sbin/samba -i

Ou

#/opt/samba/sbin/samba


Verificar se o samba esta UP

#ps aux | grep samba


Testar os compartilhamentos padrão ( sysvol e netlogon)


#smbclient -L localhost -U%


Testar autenticação, conecte-se ao compartilhamento netlogon como administrador do domínio.


#smbclient //localhost/netlogon -UAdministrator -c 'ls'

Verificar registro srv _ldap baseado em tcp no domínio.


#host -t SRV _ldap._tcp.resulti.tux.


Verificar registro srv _kerberos no domínio.


#host -t SRV _kerberos._udp.resulti.tux.


Verificar registro a do controlador de domínio.



#host -t A smbdc01.resulti.tux.

Testar se o kerberos está emitindo tickets.


#kinit administrator


Verificar o ticket.


#klist


Pratica teste!


Após configurar os dados acima, tente colocar uma máquina Windows no domínio RESULTI.TUX

User: administrator
Password: smb@640

Lembre-se de apontar o Ip do DNS para o ip do Samba. Exemplo: 192.168.0.10



Visite e conheça!

Dicas diversas



Nenhum comentário:

Postar um comentário