目录
通过winbind在centos7上加域
基础环境
域控制器:
版本:windows server 2019 数据中文版
IP:192.168.80.251
根域名:bresee.cn
centos7:
# 最小化安装,永久关闭防火墙和selinux
systemctl disable --now firewalld
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
hostnamectl set-hostname test9.bresee.cn
[root@test9 ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root@test9 ~]# hostname -I
192.168.80.144
# 使用静态IP,DNS指向域控制器
# 重启电脑,最好是重启一下;
centos7 的操作
# 软件安装
yum install -y samba samba-common samba-client
yum -y install samba-winbind* krb5-workstation ntp vim setuptool fprintd-pam
#这两个服务要开机启动
systemctl enable smb
systemctl enable winbind
# hosts文件要指一下,bresee.cn是域的根域名,ad1是主机名
192.168.80.251 bressee.cn ad1.bresee.cn
# 运行setup,运行完成之后报错也没事,多运行几次,
# 再手动重启两次
systemctl restart winbind
# 更改smb的配置文件,在全局里面加
vim /etc/samba/smb.conf
encrypt passwords = yes
winbind enum users = yes
winbind enum groups = yes
template homedir = /home/%U
# 设置nsswitch,找到以下三行并将winbind移至sss前面
vim /etc/nsswitch.conf
passwd: files winbind sss
shadow: files winbind sss
group: files winbind sss
# 最后加一行
vim /etc/pam.d/system-auth
session required pam_mkhomedir.so
vim /etc/pam.d/password-auth
session required pam_mkhomedir.so
# 加域
net ads join -U administrator
[root@xxxx]# net ads join -U administrator
Enter administrator's password:
Using short domain name -- BRESEE
Joined 'TEST9' to dns domain 'bresee.cn'
No DNS domain configured for test9. Unable to perform DNS Update.
DNS update failed: NT_STATUS_INVALID_PARAMETER
[root@c72 network-scripts]# echo $?
0
# 通过echo $? 来判断上一个命令是否执行成功
# wbinfo -t
checking the trust secret for domain JUNSON via RPC calls succeeded # 表示成功
# 重启
systemctl restart smb
systemctl restart winbind
# 这一个可以不加
vim /etc/samba/smb.conf
[share]
comment = Share Directories
path = /share
valid users = %U
browseable = No
writable = Yes
效果
要先用ssh登录,登录之后会产生家目录,然后这个家目录只能自己访问,别人不能访问;
原创文章,作者:sunnyman218,如若转载,请注明出处:https://blog.ytso.com/268218.html