SAMBA の基本的な設定

(1) ユーザの作成

UNIX ユーザの作成。

# useradd test01
# passwd test01
ユーザー test01 のパスワードを変更。
新しいパスワード:
よくないパスワード: 異なる文字が十分に含まれていません
よくないパスワード: 簡単すぎます
新しいパスワードを再入力してください:
passwd: 全ての認証トークンが正しく更新できました。

上記の UNIX ユーザを SAMBA 上のユーザとして作成。

# pdbedit -a -u test01
new password:
retype new password:
Unix username:        test01
NT username:
Account Flags:        [U          ]
User SID:             S-1-5-21-2724919445-2660786417-2727936258-1000
Primary Group SID:    S-1-5-21-2724919445-2660786417-2727936258-513
Full Name:
Home Directory:       \\rhel6\test01
HomeDir Drive:
Logon Script:
Profile Path:         \\rhel6\test01\profile
Domain:               RHEL6
Account desc:
Workstations:
Munged dial:
Logon time:           0
Logoff time:          木, 07  2月 2036 00:06:39 JST
Kickoff time:         木, 07  2月 2036 00:06:39 JST
Password last set:    火, 23  6月 2015 20:49:12 JST
Password can change:  火, 23  6月 2015 20:49:12 JST
Password must change: never
Last bad password   : 0
Bad password count  : 0
Logon hours         : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF

以下でユーザの一覧を表示。

# pdbedit -L
test01:500:

http://www.samba.gr.jp/project/translation/3.5/htmldocs/manpages-3/pdbedit.8.html


(2)smb.conf の設定

以下のコマンドで現在の設定を確認する。

# testparm -sv

smb.conf に以下の設定を追加。

[test]
        comment = test
        browseable = yes
        writable = yes
        path = /test

サービスを再起動。

# service smb restart
SMB サービスを停止中:                                      [  OK  ]
SMB サービスを起動中:                                      [  OK  ]
# service nmb restart
NMB サービスを停止中:                                      [  OK  ]
NMB サービスを起動中:                                      [  OK  ]
#

(3) 接続

test01 ユーザで接続。

# smbclient -L localhost -U%
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.23-14.el6_6]

        Sharename       Type      Comment
        ---------       ----      -------
        test            Disk      test
        IPC$            IPC       IPC Service (Samba Server Version 3.6.23-14.el6_6)
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.23-14.el6_6]

        Server               Comment
        ---------            -------
        RHEL6                Samba Server Version 3.6.23-14.el6_6

        Workgroup            Master
        ---------            -------
        MYGROUP              RHEL6
# smbclient //127.0.0.1/test -U test01 xxxxxx
                                       ^^^^^^★パスワード
Domain=[MYGROUP] OS=[Unix] Server=[Samba 3.6.23-14.el6_6]
smb: \> ls
  .                                   D        0  Tue Jun 23 20:55:40 2015
  ..                                 DR        0  Tue Jun 23 20:55:40 2015

                37904 blocks of size 524288. 32104 blocks available
smb: \> help
?              allinfo        altname        archive        blocksize
cancel         case_sensitive cd             chmod          chown
close          del            dir            du             echo
exit           get            getfacl        geteas         hardlink
help           history        iosize         lcd            link
lock           lowercase      ls             l              mask
md             mget           mkdir          more           mput
newer          open           posix          posix_encrypt  posix_open
posix_mkdir    posix_rmdir    posix_unlink   print          prompt
put            pwd            q              queue          quit
readlink       rd             recurse        reget          rename
reput          rm             rmdir          showacls       setea
setmode        stat           symlink        tar            tarmode
timeout        translate      unlock         volume         vuid
wdel           logon          listconnect    showconnect    ..
!
smb: \> quit
#


接続状況を確認。
2 回目の実行結果は、上記の smbclient コマンドで接続済みの状態で実行したもの。

# smbstatus

Samba version 3.6.23-14.el6_6
PID     Username      Group         Machine
-------------------------------------------------------------------

Service      pid     machine       Connected at
-------------------------------------------------------

No locked files

#
# smbstatus

Samba version 3.6.23-14.el6_6
PID     Username      Group         Machine
-------------------------------------------------------------------
2247      test01        test01        rhel6        (127.0.0.1)

Service      pid     machine       Connected at
-------------------------------------------------------
test         2247   rhel6         Tue Jun 23 20:58:00 2015

No locked files

#

https://access.redhat.com/documentation/ja-JP/Red_Hat_Enterprise_Linux/6/html/Deployment_Guide/ch-File_and_Print_Servers.html
https://www.samba.org/samba/docs/man/Samba-HOWTO-Collection/index.html
http://www.samba.gr.jp/doc/
http://www.atmarkit.co.jp/flinux/rensai/linuxtips/tipsindex_samba.html
http://centossrv.com/samba.shtml
http://d.hatena.ne.jp/perlcodesample/20090111/1230798794