티스토리 뷰

IT/RHEL

[RHCE] CIFS (SAMBA) 파일공유

트래이닝맨 2014. 8. 17. 13:10
728x90
반응형

17장 CIFS를 사용한 파일 공유


*CIFS 공유 액세스
==================

사용하는 이유 : windows와 unix 사이에 파일을 공유하기 위한 방법

*서버
=====

설치 패키지 : samba, samba-common, samba-client

설정 파일 : /etc/samba/smb.conf

[global] 섹션
-----------------

workgroup - 네트워크의 Windows 작업 그룹 또는 도메인 이름을 지정하는 데 사용

hosts allow - 서비스에 접근이 가능한 호스트들의 집합(ex, hosts allow =150.203.5. (연달아 찍은 도트 기호를 사용함)

security 
  1) =user 특정 사용자만 가능
  2) = share 누구나 가능
  3) = domain NT 도메인에 추가된 경우 (encrypted passwords =yes)
  4) = server  Samba가 사용자 이름/암호를 다른 SMB 서버에 전달하여 검증(password server를 설정해야함)


기타섹션
-------------

 [home] -  홈 디렉토리를 자동으로 공유됨.
 [printers]  - 기본적으로 사용 가능하며 사용 가능한 프린터를 공유
 [share]  다른 공유를 만들려면 이렇게 대괄호에 이름을 넣으면 됨.



*Sample
========

[global]

 workgroup = MYGROUP
 server string = Samba Server Version %v
 log file = /var/log/samba/log.%m
 max log size = 50
 hosts allow = 127. 192.168.12. 192.168.13.

 security = user
 passdb backend = tdbsam

 load printers = yes    ===> if no, 프린트를 공유하지 않는다.
 cups options =raw

 

[home]

comment = Home Directories
browsable = no
writable = yes

[printers]
comment = All Printers
path = /var/spool/samba
browsable = no
guest ok = no
writable = no
printable = yes


Samba 전용 user 생성

#useradd -s /sbin/nologin test1
#smbpasswd -a test1
New SMB password: winpass
Retype new SMB password: winpass



*클라이언트
===========

1. GUI 이용
Places - Connect to Server

2.samba client 이용(FTP 스타일)
# smbclient //server1/proj/ -U test1

#smbclient //server18/winuser18                    -U        winuser18%winpass
                      IP           home/winuser18                      user           password

3.수동으로 CIFS 공유 마운트
#mount -t cifs -o user=username //server/share /mntpoint
#mount -t cifs -o user=winuserX //server1/winuser1 /mnt/

4.영구적으로 CIFS 공유 마운트

 

*예제
=====

#useradd test1~3까지 생성
#groupadd proj
#usermod -G proj test1~3
#mkdir -p /shared/dir
#ls -ld /shard => rwxr-xr-x root root 
#chmod 755  /shared
#chgrp -R proj /shared/dir
#chmod -R 775 /shared/dir (chmod -R 660 files)
#chmod 2770 /shard/dir ==> 앞으로 생성될 파일에 대해서 r-w를 사용하겠다.

 

# vi /etc/samba/smb.conf

[proj]
comment = Proj Stuff
path = /shared/dir
public =no
writable = yes
printable = no
write list = @proj



Samba 유저 암호 생성

# smbpasswd -a test1
New SMB password:
Retype new SMB password:
Added user test1.

# smbpasswd -a test2
New SMB password:
Retype new SMB password:
Added user test2.


SELINUX 설정

# getenforce
Enforcing
# ls -Z /shared
drwxrwsr-x. root proj unconfined_u:object_r:default_t:s0 dir

# semanage fcontext -a -t public_content_t '/shared(/.*)?'
# semanage fcontext -a -t samba_share_t '/shared/dir(/.*)?'
# restorecon -Rvv /shared
restorecon reset /shared context unconfined_u:object_r:default_t:s0->unconfined_u:object_r:public_content_t:s0
restorecon reset /shared/dir context unconfined_u:object_r:default_t:s0->unconfined_u:object_r:samba_share_t:s0
restorecon reset /shared/dir/t.txt context unconfined_u:object_r:default_t:s0->unconfined_u:object_r:samba_share_t:s0

#setsebool -P samba_enable_home_dirs on   ==> 홈 디렉토리 액세스를 활성화 함.


IPTABLES 설정

iptables -I INPUT -p udp --dport 137:138 -j ACCEPT
iptables -I INPUT -p tcp --dport 139 -j ACCEPT
iptables -I INPUT -p tcp --dport 445 -j ACCEPT
service iptables save




반응형

'IT > RHEL' 카테고리의 다른 글

[RHCE] 부팅시 문제해결 - Trouble Shooting  (0) 2014.08.17
[RHCE] FTP 파일공유  (0) 2014.08.17
[RHCE] NFS 파일 공유  (0) 2014.08.17
[RHCE] 캐싱전용 DNS 서버  (0) 2014.08.17
[RHCE] SMTP (postfix) 설정  (0) 2014.08.17
댓글
250x250
반응형
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/10   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31
글 보관함