当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 加入 Ubuntu 20.04|18.04/Debian 10 到 Active Directory (AD) 域

作者:精品下载站 日期:2024-12-14 12:26:58 浏览:15 分类:玩电脑

加入 Ubuntu 20.04|18.04/Debian 10 到 Active Directory (AD) 域


问题:如何将Ubuntu 20.04|18.04加入Windows域?,我可以将Debian 10加入Active Directory域吗?本文旨在向您展示如何使用 realmd 将 Ubuntu 20.04|18.04/Debian 10 服务器或桌面加入 Active Directory 域。 Active Directory 域是大多数企业环境中用户信息的中心枢纽。

例如,在我公司的基础设施中,一个关键要求是使用 Active Directory 凭据对所有 Linux 系统的所有用户进行身份验证。这应该适用于基于 Debian 和 Red Hat 的 Linux 发行版。我之前写过一份 RHEL/CentOS 指南,请从下面的链接查看。

  • 如何将 CentOS 8/RHEL 8 系统加入 Active Directory (AD) 域

本指南将说明如何配置 SSSD 以从同一 Active Directory 资源林内的域检索信息。如果您正在使用多个 AD 林,本指南可能不适合您。我们还将进一步为通过 AD 登录的用户配置 sudo 规则。这是描述设置以及设置如何工作的图表。

[玩转系统] 加入 Ubuntu 20.04|18.04/Debian 10 到 Active Directory (AD) 域

因此,请按照以下步骤将 Ubuntu 20.04|18.04/Debian 10 加入 Active Directory (AD) 域。

第 1 步:更新您的 APT 索引

首先更新您的 Ubuntu/Debian Linux 系统。

sudo apt -y update

这是至关重要的,因为如果服务器是全新安装的,安装可能会失败。

对于 Ubuntu 18.04,请将以下存储库添加到您的sources.list文件中。

sudo tee -a /etc/apt/sources.list <<EOF
deb http://us.archive.ubuntu.com/ubuntu/ bionic universe
deb http://us.archive.ubuntu.com/ubuntu/ bionic-updates universe
EOF

第 2 步:设置服务器主机名和 DNS

使用正确的域组件为您的服务器设置正确的主机名。

sudo hostnamectl set-hostname myubuntu.example.com

确认您的主机名:

$ hostnamectl
   Static hostname: myubuntu.example.com
         Icon name: computer-vm
           Chassis: vm
        Machine ID: 5beb7ac3260c4f00bcfbe1088f48b8c7
           Boot ID: b2a0d9abe43b455fb49484dbaa59dc41
    Virtualization: vmware
  Operating System: Ubuntu 18.04.1 LTS
            Kernel: Linux 4.15.0-29-generic
      Architecture: x86-64

确认 DNS ia 配置正确:

cat /etc/resolv.conf

第三步:安装所需的包

将 Ubuntu 20.04|18.04/Debian 10 系统加入 Active Directory (AD) 域需要许多软件包。

sudo apt update
sudo apt -y install realmd libnss-sss libpam-sss sssd sssd-tools adcli samba-common-bin oddjob oddjob-mkhomedir packagekit

只有成功安装依赖项后,您才能继续在 Debian 10/Ubuntu 20.04/18.04 上发现 Active Directory 域。

步骤 4:在 Debian 10/Ubuntu 20.04|18.04 上发现 Active Directory 域

realm discovery 命令返回完整的域配置以及系统注册到域中必须安装的软件包列表。

$ sudo realm discover example.com
example.com
  type: kerberos
  realm-name: EXAMPLE.COM
  domain-name: example.com
  configured: no
  server-software: active-directory
  client-software: sssd
  required-package: sssd-tools
  required-package: sssd
  required-package: libnss-sss
  required-package: libpam-sss
  required-package: adcli
  required-package: samba-common-bin

将 example.com 替换为您的有效 AD 域。

步骤 5:加入 Ubuntu 20.04|18.04/Debian 10 到 Active Directory (AD) 域

将 Linux 计算机与 Windows Active Directory 域集成需要 AD 管理用户帐户。检查并确认AD管理员帐户和密码。

Realm join 命令将通过配置本地系统服务和身份域中的条目来设置本地计算机以与指定域一起使用。该命令有许多选项,可以通过以下方式检查:

$ realm join --help

基本命令执行是:

$ sudo realm join -U Administrator example.com
Password for Administrator:

在哪里 :

  • 管理员是用于将机器集成到AD的管理员帐户的名称。
  • example.com 是AD域的名称

该命令首先尝试在没有凭据的情况下进行连接,但如果需要,它会提示输入密码。

查看当前realmd详细信息。

$ realm  list
example.com
  type: kerberos
  realm-name: EXAMPLE.COM
  domain-name: example.com
  configured: kerberos-member
  server-software: active-directory
  client-software: sssd
  required-package: sssd-tools
  required-package: sssd
  required-package: libnss-sss
  required-package: libpam-sss
  required-package: adcli
  required-package: samba-common-bin
  login-formats: %[email 
  login-policy: allow-realm-logins

在基于 RHEL 的系统上,将自动创建用户的主目录。在 Ubuntu/Debian 上,您需要启用此功能。

sudo bash -c "cat > /usr/share/pam-configs/mkhomedir" <<EOF
Name: activate mkhomedir
Default: yes
Priority: 900
Session-Type: Additional
Session:
        required                        pam_mkhomedir.so umask=0022 skel=/etc/skel
EOF

然后使用以下命令激活:

sudo pam-auth-update

选择

[玩转系统] 加入 Ubuntu 20.04|18.04/Debian 10 到 Active Directory (AD) 域

确保选择“激活 mkhomedir ”,它应该具有[*]

[玩转系统] 加入 Ubuntu 20.04|18.04/Debian 10 到 Active Directory (AD) 域

然后选择保存更改。

您的sssd.conf配置文件位于/etc/sssd/sssd.conf。每当文件发生变化时,就需要重新启动。

sudo systemctl restart sssd

状态应该是正在运行。

systemctl status sssd

如果集成正常,应该可以获得 AD 用户信息。

$ id jmutai
uid=1783929917([email ) gid=1784800513(domain [email ) groups=1783870513(domain [email )

第 6 步:控制访问 - 限制用户/组

可以通过仅允许特定用户/和组来限制对注册服务器的访问。

限制用户

要允许用户通过 SSH 和控制台进行访问,请使用以下命令:

sudo realm permit [email 
sudo realm permit [email  [email 

允许访问组 - 示例

sudo ream permit -g sysadmins
sudo realm permit -g 'Security Users'
sudo realm permit 'Domain Users' 'admin users'

这将修改sssd.conf文件。

如果您想允许所有用户访问,请运行:

sudo realm permit --all

要拒绝所有域用户访问,请使用:

sudo realm  deny --all

步骤 7:配置 Sudo 访问

默认情况下,域用户没有权限升级

我们首先创建 sudo 权限授予文件。

sudo vim /etc/sudoers.d/domain_admins

添加单个用户:

[email         ALL=(ALL)       ALL

添加另一个用户:

[email      ALL=(ALL)   ALL
[email      ALL=(ALL)   ALL

添加群组

%[email      ALL=(ALL)   ALL

添加具有两个或三个名称的组。

%security\ [email        ALL=(ALL)       ALL
%system\ super\ [email  ALL=(ALL)       ALL

第 8 步:测试 SSH 访问

以 AD 上允许登录的用户身份远程访问服务器。

$ ssh user1@localhost
The authenticity of host 'localhost (::1)' can't be established.
ECDSA key fingerprint is SHA256:wmWcLi/lijm4zWbQ/Uf6uLMYzM7g1AnBwxzooqpB5CU.
ECDSA key fingerprint is MD5:10:0c:cb:22:fd:28:34:c6:3e:d7:68:15:02:f9:b4:e9.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'localhost' (ECDSA) to the list of known hosts.

这是我们配置成功的确认。访问realmd 和sssd wiki 页面以了解更多信息。

标签:

  • 将 Ubuntu 20.04|18.04 加入 Windows 域
  • 将 Ubuntu 20.04|18.04 加入 AD
  • 将 Ubuntu 20.04|18.04 加入 Active Directory
  • 将 Ubuntu 20.04|18.04 加入 Samba 域
  • 将 Debian 10 加入 Windows 域
  • 加入 Debian 10 到 AD
  • 将 Debian 10 加入 Active Directory
  • 将 Debian 10 加入 Samba 域

相关指南:

  • 使用 FreeIPA 在 SSSD 上为 AD 信任用户设置默认登录 Shell
  • 在 Ubuntu/CentOS 7 上配置 FreeIPA 客户端
  • 在 Debian 上安装和配置 OpenLDAP 服务器
  • 在 Ubuntu LTS 上安装和配置 OpenLDAP 服务器

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯