Linux active directory sso

Linux active directory sso

To support True SSO on an Ubuntu desktop, integrate the desktop with an Active Directory domain using the Samba and Winbind solutions.

Use the following procedure to integrate an Ubuntu desktop with an AD domain.

Some examples in the procedure use placeholder values to represent entities in your network configuration, such as the host name of your Ubuntu desktop. Replace the placeholder values with information specific to your configuration, as described in the following table.

Placeholder Value Description
dns_IP_ADDRESS IP address of your DNS name server
mydomain.com DNS name of your AD domain
MYDOMAIN.COM DNS name of your AD domain, in all capital letters
myhost Host name of your Ubuntu desktop
MYDOMAIN DNS name of the workgroup or NT domain that includes your Samba server, in all capital letters
ads-hostname Host name of your AD server
admin-user User name of the AD domain administrator

Prerequisites

  • The Active Directory (AD) server is resolvable by DNS on the Linux system.
  • The Network Time Protocol (NTP) is configured on the Linux system.

Procedure

sudo apt install samba krb5-config krb5-user winbind libpam-winbind libnss-winbind
    For Default Kerberos version 5 realm , enter the DNS name of your AD domain using all capital letters.
passwd: compat winbind group: compat winbind shadow: compat gshadow: files
  1. Open the NetworkManager control panel and navigate to the IPv4 Settings for your system connection. For Method, select Automatic (DHCP) addresses only . In the DNS servers text box, enter the IP address of your DNS name server (represented as dns_IP_ADDRESS in the examples throughout this procedure). Then click Save .
  2. Edit the configuration file for your system connection located in /etc/NetworkManager/system-connections . Use the following example.
[ipv4] dns=dns_IP_ADDRESS dns-search=mydomain.com ignore-auto-dns=true method=auto

Note: A new virtual network adapter is added when a new instant-cloned virtual desktop is created. Any setting in the network adapter, such as the DNS server, in the virtual desktop template is lost when the new network adapter is added to the instant-cloned virtual desktop. To avoid losing the DNS server setting when the new network adapter is added to a cloned virtual desktop, you must specify a DNS server for your Linux system.

nameserver dns_IP_ADDRESS search mydomain.com
127.0.0.1 localhost 127.0.1.1 myhost.mydomain.com myhost
[global] security = ads realm = MYDOMAIN.COM workgroup = MYDOMAIN idmap uid = 10000-20000 idmap gid = 10000-20000 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 = yes winbind use default domain = yes restrict anonymous = 2 kerberos method = secrets and keytab winbind refresh tickets = true
sudo systemctl restart smbd.service
[libdefaults] default_realm = MYDOMAIN.COM dns_lookup_realm = true dns_lookup_kdc = true [realms] MYDOMAIN.COM = < kdc = ads-hostname admin_server = ads-hostname > [domain_realm] .mydomain.com = MYDOMAIN.COM mydomain.com = MYDOMAIN.COM 

This command returns information about the ticket, including its valid starting time and expiration time.

sudo net ads keytab create -U admin-user
sudo net ads join -U admin-user
sudo systemctl restart winbind.service

Источник

Настройка SSO (Single Sign On) авторизации на Apache в Active Directory (Debian 8 Jessie/Ubuntu Server 14.04)

SSO (Single Sing-on) – позволяет пользователям вошедшим в систему не вводить пароль при авторизации на доменных сетевых ресурсах. Этот же механизм можно запросто прикрепить к Apache, что бы позволить доменным пользователям проходить аутентификацию, например на внутреннем сайте компании, не вводя имя пользователя и пароль.

  • Контроллер домена (DC1) на Windows Server 2012 R2, домен JAKONDA.LOCAL
  • Веб-сервер (webserver) (Apache 2.4.10) на Debian 8 Jessie

Настройка системы (Debian 8 Jessie)

Указываем FQDN ( Fully Qualified Domain Name) имя системы, в файле (/etc/hostname):

Файл (/etc/hosts) приводим к виду таким образом, чтобы в нём была запись с полным доменным именем компьютера и с коротким именем, ссылающаяся на один из внутренних IP:

127.0.0.1 localhost 127.0.1.1 webserver.jakonda.local webserver

Настраиваем синхронизацию времени с контроллером домена, выполняем установку NTP, выполняем синхронизацию времени с контроллером домена:

apt-get install ntp ntpdate ntpdate dc1.jakonda.local

Более подробно о синхронизации времени на Debian 8 Jessie/Ubuntu Server 14.04 можно почитать в этой статье

Настройка Active Directory (Windows Server 2012 R2)

В DNS зону (JAKONDA.LOCAL), добавляем A-запись веб-сервера:

Создаем служебного пользователя (прим. apache), с бесконечным срок действия пароля.

Создаем KEYTAB-файл (необходим для аутентификации пользователей в Active Directory). В командной строке с правами администраторы выполняем команду (соблюдая регистр):

ktpass -princ HTTP/webserver.jakonda.local@JAKONDA.LOCAL -mapuser apache@JAKONDA.LOCAL -pass Aa1234567 -crypto RC4-HMAC-NT -ptype KRB5_NT_PRINCIPAL -out C:\webserver.keytab

Полученный KEYTAB-файл, передаем любым удобным способом на Веб-сервер (расположение KEYTAB-файла на моем веб-сервере — /etc/webserver.keytab). Как передать файл посредством утилиты PuTTY можно прочитать тут

Настройка Kerberos (Debian 8 Jessie)

Установка пакетов для поддержки аутентификации Kerberos:

apt-get install krb5-user libapache2-mod-auth-kerb

В ходе установки может появится запрос указать область по-умолчанию для Kerberos, область необходимо его указать в заглавном виде (прим. JAKONDA.LOCAL)

Файл конфигурации Kerberos (/etc/krb5.conf), приводим к виду:

[logging] default = FILE:/var/log/krb5libs.log kdc = FILE:/var/log/krb5kdc.log admin_server = FILE:/var/log/kadmind.log [libdefaults] default_realm = JAKONDA.LOCAL default_keytab_name = /etc/webserver.keytab dns_lookup_kdc = false dns_lookup_realm = false forwardable = true ticket_lifetime = 24h [realms] JAKONDA.LOCAL = < kdc = dc1.jakonda.local default_domain = JAKONDA.LOCAL admin_server = dc1.jakonda.local >[domain_realm] .jakonda.local = JAKONDA.LOCAL jakonda.local = JAKONDA.LOCAL

Проверка работы Kerberos, выполним авторизацию в Active Directory:

kinit -kV -p HTTP/webserver.jakonda.local Using default cache: /tmp/krb5cc_0 Using principal: HTTP/webserver.jakonda.local@JAKONDA.LOCAL Authenticated to Kerberos v5

Настройка Apache (Debian 8 Jessie)

Выставляем права на KEYTAB-файл для веб-сервера:

chown root:www-data /etc/webserver.keytab chmod 640 /etc/webserver.keytab

В качестве примера Kerberos аутентификации в Apache, в конфигурацию веб-сервера по-умолчанию (000-default.conf), добавляем:

 # . ServerName webserver.jakonda.local AuthType Kerberos AuthName "Kerberos authenticated intranet" KrbAuthRealms JAKONDA.LOCAL KrbServiceName HTTP/webserver.jakonda.local Krb5Keytab /etc/webserver.keytab KrbMethodNegotiate On KrbMethodK5Passwd On KrbSaveCredentials Off KrbLocalUserMapping On KrbVerifyKDC Off Require valid-user 

Чтобы SSO аутентификации проходила корректно, необходимо добавить веб-сервер в зону местной интрасети:

Хочу обратить внимание, что при попытке доступа на сайт по IP-адресу SSO аутентификация работать не будет. Необходимо обязательно использовать доменное имя (прим. http://webserver)

ПОНРАВИЛАСЬ ИЛИ ОКАЗАЛАСЬ ПОЛЕЗНОЙ СТАТЬЯ, ПОБЛАГОДАРИ АВТОРА

Источник

The Mirror

Step 2. Update system and install required software

# yum update
# yum install mc vim httpd php svn httpd-devel make autoconf gcc ntp krb5-workstation samba-common authconfig samba-winbind
— In centos install additional package required : samba-winbind-clients

Step 3. Connect to active directory

# authconfig —enableshadow —enablemd5 —passalgo=md5 —krb5kdc=DC.domain.com —krb5realm=domain.com —smbservers=DC.domain.com —smbworkgroup=domain —enablewinbind —enablewinbindauth —smbsecurity=ads —smbrealm=domain.com —smbidmapuid=»16777216-33554431″ —smbidmapgid=»16777216-33554431″ —winbindseparator=»+» —winbindtemplateshell=»/bin/false» —enablewinbindusedefaultdomain —disablewinbindoffline —winbindjoin=admin.user —disablewins —disablecache —enablelocauthorize —updateall

# service winbind start ; chkconfig winbind on
# setsebool -P allow_httpd_mod_auth_ntlm_winbind on

Now check your winbind connection using the following commands:
# wbinfo -u
# wbinfo -g

— The socket /var/lib/samba/winbindd_privileged/pipe should be writable by the webserver. To allow that access, I add user apache to the group wbpriv: usermod -G wbpriv apache

— create file, permissions and ownerships. All files should be under apace ownership and apace user in wbpriv group :
# usermod -aG wbpriv apache
# chown root:wbpriv winbindd_privileged
# ln -s /var/lib/samba/winbindd_privileged/pipe /var/run/samba/winbindd_privileged/pipe

Step 4. Download and compile mod_auth_ntlm_winbind

svn co svn://svnanon.samba.org/lorikeet/trunk/mod_auth_ntlm_winbind mod_auth_ntlm_winbind
or download from https://github.com/rodpaddock/mod_auth_ntlm_winbind-

# unzip mod_auth_ntlm_winbind.zip
# cd mod_auth_ntlm_winbind/

Step 5. Configure it

In /etc/httpd/conf.d/mod_auth_ntlm_winbind.conf I put the following configuration

LoadModule auth_ntlm_winbind_module /usr/lib64/httpd/modules/mod_auth_ntlm_winbind.so

Options ExecCGI FollowSymLinks SymLinksIfOwnerMatch
AllowOverride None
Order allow,deny
Allow from all
AuthName «NTLM Authentication»
AuthType NTLM
Require valid-user
NTLMAuth on
NTLMAuthHelper «/usr/bin/ntlm_auth —helper-protocol=squid-2.5-ntlmssp»
NTLMBasicAuthoritative on

In /etc/httpd/conf/httpd.conf, change KeepAlive Off to KeepAlive On.

Step 6. Change your firewall to enable incoming HTTP

# iptables -I INPUT -p tcp —dport 80 -j ACCEPT

Step 7. Go!

Run # service httpd restart, make httpd start on reboot using chkconfig httpd on and test your configuration.

Additional debugging:
Let’s try to authenticate with NTLM, Type the following line
# ntlm_auth –-request-nt-key –-domain= –-username=

Check apache loaded modules: # httpd -M

To debug logs: add «LogLevel debug» in /etc/httpd/conf/httpd.conf

To test:
To test the settings are returning remote user parameter, add code below in /var/www/html/user.php file:
$user = $_SERVER[‘REMOTE_USER’];
?>


If the SSO is configured correctly and you are logged in to a browser where the AD key is already authenticated (I have a laptop authenticated with AD user and IE browser already having the AD ticket), your logged in user name will be displayed in the web page accessed from server.

Источник

Читайте также:  Linux touch all file
Оцените статью
Adblock
detector