반응형

 


 

작성일: 2023년 12월 11일

 

 

Ubuntu 20.04 또는 Ubuntu 22.04에 Samba(SMB) 서버를 설치하고 싶다면 아래 절차를 따라하면 잘 동작한다.

  

 

##
##  Samba 서버 프로그램을 설치한다.
##
$  sudo apt-get install -y samba

...

##
##  Samba 서버가 공유할 폴더(디렉토리) 정보를 설정한다.
##
$  vi /etc/samba/smb.conf
... 중간 생략 ...
;
; 아래 내용을 추가한다.
;
[mybox]
   comment = My File Box
   path = /home/sejong
   guest ok = no
   browseable = yes
   writable = yes
   create mask = 0777
   directory mask = 0777
   valid users = sejong
... 중간 생략 ...

##
## Linux 계정 'sejong'을 samba 접근 계정으로 추가한다.
## 암호는 Linux 계정 'sejong'의 암호와 달라도 된다.
##
$  sudo smbpasswd -a sejong

##
## Samba 서버 데몬을 재기동한다.
##
$  sudo /etc/init.d/smbd restart
## 또는 위 명령을 아래와 같이 수행해도 된다.
##  $ sudo  systemctl restart smbd

 

클라이언트 PC에서 아래와 같이 Samba 서버에 접속시도한다. (아래는 Macbook에서 실행한 화면)

 

Macbook에서 Samba 서버에 접속 시도

 

 

 

 

Samba 서버 설정 끝 !!!
Samba 서버 관리 명령을 알고 싶다면, 아래 내용을 더 읽어보아요~~

 

 

 

Samba 계정 정보를 보고 싶다면, 아래와 같이 `pdbedit` 명령으로 조회할 수 있다.

 

$  pdbedit -L -v

---------------
Unix username:        sejong
NT username:
Account Flags:        [U          ]
Home Directory:       \\ANDREW-UBUNTU\sejong
HomeDir Drive:
Logon Script:
Profile Path:         \\ANDREW-UBUNTU\sejong\profile
Domain:               ANDREW-UBUNTU
Account desc:
Workstations:
Munged dial:
Logon time:           0
Logoff time:          Thu, 07 Feb 2036 00:06:39 KST
Kickoff time:         Thu, 07 Feb 2036 00:06:39 KST
Password last set:    Wed, 07 Dec 2022 16:06:30 KST
Password can change:  Wed, 07 Dec 2022 16:06:30 KST
Password must change: never
Last bad password   : 0
Bad password count  : 0
Logon hours         : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

$

 

 

Samba 서버에 접속한 Client 정보를 보고 싶다면 아래와 같이 `smbstatus` 명령을 사용한다.

$  smbstatus

Samba version 4.15.9-Ubuntu
PID     Username     Group        Machine                                   Protocol Version  Encryption           Signing
----------------------------------------------------------------------------------------------------------------------------------------
295419  sejong       sejong       10.1.3.169 (ipv4:10.1.3.169:63352)        SMB3_11           -                    partial(AES-128-CMAC)

Service      pid     Machine       Connected at                     Encryption   Signing
---------------------------------------------------------------------------------------------
mybox        295419  10.1.3.169    Wed Dec  7 04:23:23 PM 2022 KST  -            -


Locked files:
Pid          User(ID)   DenyMode   Access      R/W        Oplock           SharePath   Name   Time
--------------------------------------------------------------------------------------------------
295419       1001       DENY_NONE  0x100081    RDONLY     NONE             /home/sejong   .   Wed Dec  7 16:23:22 2022

 

 

계정 정보를 변경하고 싶다면,  `usermod` 명령을 사용한다.

 

$  usermod --help
Usage: usermod [options] LOGIN

Options:
  -b, --badnames                allow bad names
  -c, --comment COMMENT         new value of the GECOS field
  -d, --home HOME_DIR           new home directory for the user account
  -e, --expiredate EXPIRE_DATE  set account expiration date to EXPIRE_DATE
  -f, --inactive INACTIVE       set password inactive after expiration
                                to INACTIVE
  -g, --gid GROUP               force use GROUP as new primary group
  -G, --groups GROUPS           new list of supplementary GROUPS
  -a, --append                  append the user to the supplemental GROUPS
                                mentioned by the -G option without removing
                                the user from other groups
  -h, --help                    display this help message and exit
  -l, --login NEW_LOGIN         new value of the login name
  -L, --lock                    lock the user account
  -m, --move-home               move contents of the home directory to the
                                new location (use only with -d)
  -o, --non-unique              allow using duplicate (non-unique) UID
  -p, --password PASSWORD       use encrypted password for the new password
  -R, --root CHROOT_DIR         directory to chroot into
  -P, --prefix PREFIX_DIR       prefix directory where are located the /etc/* files
  -s, --shell SHELL             new login shell for the user account
  -u, --uid UID                 new UID for the user account
  -U, --unlock                  unlock the user account
  -v, --add-subuids FIRST-LAST  add range of subordinate uids
  -V, --del-subuids FIRST-LAST  remove range of subordinate uids
  -w, --add-subgids FIRST-LAST  add range of subordinate gids
  -W, --del-subgids FIRST-LAST  remove range of subordinate gids
  -Z, --selinux-user SEUSER     new SELinux user mapping for the user account

 

 

게시물 작성자: sejong.jeonjo@gmail.com

 

 


 

반응형

CentOS인 경우에 아래와 같은 Samba(SMB)를 설정한다. 

$  yum  install  samba 
...

$  cat  /etc/samba/smb.conf 
  ... 중간 생략 ... 
        security = user 
        passdb backend = tdbsam 
  ... 중간 생략 ... 
  [homes] 
        comment = Home Directories 
        browseable = no 
        writable = yes 
        read only = no
  ... 중간 생략 ... 

<참고: UNIX 시스템 계정 andrew가 이미 생성되어 있다고 가정> 
$  smbpasswd  -a  andrew 
$  systemctl start  smb
(또는  $ systemctl start smbd)
$  systemctl enable smb
(또는  $ systemctl enable smbd)

 

'CentOS' 카테고리의 다른 글

CPU Pinning 예제 코드  (0) 2022.06.17
Install Ansible AWX (version 17.1.0)  (0) 2021.11.16
How to use Ansible and Playbook  (0) 2021.11.12
Install OS with PXE and kickstart  (0) 2021.11.12
Network config on CentOS 8  (0) 2021.07.10

+ Recent posts