구축 방법
패키지 설치
[root@server ~]# yum -y install samba samba-client
공유 디렉터리 생성 및 권한부여
[root@server ~]# mkdir -p /share/samba
[root@server ~]# useradd smbuser
[root@server ~]# groupadd smbgroup
[root@server ~]# chown smbuser:smbgroup /share/samba/
[root@server ~]# ls -ld /share/samba/
drwxr-xr-x. 2 smbuser smbgroup 6 Apr 20 02:16 /share/samba/
SELinux 설정
[root@server ~]# semanage fcontext -a -t samba_share_t '/share/samba(/.*)?'
[root@server ~]# restorecon -RFv /share/samba/
restorecon reset /share/samba context system_u:object_r:default_t:s0->system_u:object_r:samba_share_t:s0
[root@server ~]# ls -ldZ /share/samba/
drwxr-xr-x. smbuser smbgroup system_u:object_r:samba_share_t:s0 /share/samba/
설정파일 등록 및 환경설정
[root@server ~]# vi /etc/samba/smb.conf
[share] << 맨 하단부 작성하기
comment = Samba Test
path = /share/samba
writable = yes
write list = smbuser, @smbgroup
valid users = smbuser, @smbgroup. @wheel
host allow = 192.168.10.0/24
browseable = no
[root@server ~]# testparm
# enter
[root@server ~]# systemctl restart smb nmb
[root@server ~]# systemctl enable smb nmb
방화벽 설정
[root@server ~]# firewall-cmd --permanent --zone=public --add-service=samba
[root@server ~]# firewall-cmd --reload
SMB 사용자 등록
[root@server ~]# useradd -s /sbin/nologin smbuser
[root@server ~]# smbpasswd -a smbuser
# 1234
# 1234
SMB 등록 사용자 확인
[root@server ~]# pdbedit --list
smbuser:1001:
client 연결
패키지 설치
[root@server ~]# yum -y install cifs-utils samba-client
공유영역 탐색
[root@client ~]# smbclient -L 192.168.10.10 -U smbuser
# 1234
Enter SAMBA\smbuser's password:
Sharename Type Comment
--------- ---- -------
print$ Disk Printer Drivers << share 영역 조회 불가능
IPC$ IPC IPC Service (Samba 4.9.1)
smbuser Disk Home Directories
Reconnecting with SMB1 for workgroup listing.
Server Comment
--------- -------
Workgroup Master
--------- -------
SAMBA SERVER
WORKGROUP DESKTOP-BRA9KRD
share 영역 탐색 불가 이유 : server에서 작성한 파일중 browseable = no 값이 "no"면 탐색 불가 "yes" 면 client에서 탐색 가능
[root@server ~]# vi /etc/samba/smb.conf
[share]
comment = Samba Test
path = /share/samba
writable = yes
write list = smbuser, @smbgroup
valid users = smbuser, @smbgroup. @wheel
host allow = 192.168.10.0/24
browseable = no
browseable = yes 설정 시 client에서 조회 가능 : (smb.conf 파일 변경 시 smb nmb 데몬 재시작 필요함)
[root@client ~]# smbclient -L 192.168.10.10 -U smbuser
Enter SAMBA\smbuser's password:
Sharename Type Comment
--------- ---- -------
print$ Disk Printer Drivers
share Disk Samba Test << share 영역 조회 가능
IPC$ IPC IPC Service (Samba 4.9.1)
smbuser Disk Home Directories
Reconnecting with SMB1 for workgroup listing.
Server Comment
--------- -------
Workgroup Master
--------- -------
SAMBA
마운트 포인트 생성 및 SMB 계정 인증정보 생성
[root@client ~]# mkdir -p /mnt/share
[root@client ~]# vi /root/smb-auth
username=smbuser
passwd=1234
domain=SAMBA
[root@client ~]# chmod 400 /root/smb-auth
[root@client ~]# mount -o credentials=/root/smb-auth //192.168.10.10/share /mnt/share
[root@client ~]# df -hT | grep /mnt/share