====== Samba のインストール ====== * OpenWrt: ATTITUDE ADJUSTMENT (12.09, r36088) - [[http://wiki.openwrt.org/doc/howto/cifs.server|Samba]] ===== パッケージをインストール ===== 最新の samba バージョンを調べる。 # opkg update # opkg list | grep samba luci-app-samba - 0.11.1-1 - Network Shares - Samba SMB/CIFS module samba36-client - 3.6.5-3 - Samba 3.6 SMB/CIFS client samba36-server - 3.6.5-3 - The Samba software suite is a collection of programs that implements the SMB protocol for UNIX systems, allowing you to serve files and printers to Windows, NT, OS/2 and DOS clients. This protocol is sometimes also referred to as the LanManager or Netbios protocol. 最新の samba サーバと Web で設定可能にするパッケージをインストール。 # opkg install samba36-server luci-app-samba Installing samba36-server (3.6.5-3) to root... Downloading http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/samba36-server_3.6.5-3_ar71xx.ipk. Installing luci-app-samba (0.11.1-1) to root... Downloading http://downloads.openwrt.org/attitude_adjustment/12.09/ar71xx/generic/packages/luci-app-samba_0.11.1-1_ar71xx.ipk. Configuring samba36-server. Configuring luci-app-samba. Samba を起動時に自動起動するように設定。 # /etc/init.d/samba enable Samba を起動。 # /etc/init.d/samba start ===== アクセスするユーザの追加 ===== ユーザ単位のアクセス制限をする。まずは、 Samba に接続するユーザを作成する。 # vi /etc/passwd 以下の行を追加してユーザを新規作成する。(username は作成するユーザ名) username:*:1000:100:SambaUser:/var:/bin/false ^ username | ユーザー名 | ^ * | '*' はパスワードログインを許可していないことを意味する。Samba の認証ユーザなので、OS自体にログインする必要はないので '*'。 \\ 'x' という文字か、暗号化されたパスワードを指定するとパスワードでログインできる。'x' はシャドウパスワードを使用している事を意味する。| ^ 1000 | ユーザーID。1000 以上の既に使用されていない数値を選ぶ。 | ^ 100 | グループID。users グループに所属させる。 | ^ SambaUser | コメント。氏名や部署名等。| ^ /var | ホームディレクトリを指定。ログインしないので、 /var を指定。 | ^ /bin/false | ユーザーのログインシェル。ログインしないので、 /bin/false を指定。 | users グループに追加する。 # vi /etc/group root:x:0: daemon:x:1: adm:x:4: mail:x:8: audio:x:29: www-data:x:33: ftp:x:55: users:x:100:username network:x:101: nogroup:x:65534: smbpasswd でユーザのパスワードを設定。新規の場合は -a オプションを付ける。変更の場合はオプションなし。 # smbpasswd -a username New SMB password: Retype SMB password: 次は /etc/config/samba に設定を記述する。 # vi /etc/config/samba config samba option 'name' 'openwrt' option 'workgroup' 'WORKGROUP' option 'description' 'openwrt' option 'homes' '0' config 'sambashare' option 'name' 'SambaShare' option 'path' '/mnt/usb-disk' option 'users' 'username' option 'guest_ok' 'no' option 'create_mask' '0755' option 'dir_mask' '0755' option 'read_only' 'no' Samba に設定ファイルを再読み込みさせる。 # /etc/init.d/samba restart ===== 設定 ===== [[http://wiki.openwrt.org/doc/uci/samba|The UCI System >> Samba (smb)]] OpenWrt の Samba は設定ファイルが2つあるらしい。 ^ /etc/config/samba | 基本設定 | ^ /etc/samba/smb.conf.template | 詳細設定 | /etc/config/samba は先ほど設定した。 次は /etc/samba/smb.conf.template を編集する。 # vi /etc/samba/smb.conf.template [global] netbios name = |NAME| display charset = UTF-8 interfaces = |INTERFACES| server string = |DESCRIPTION| unix charset = UTF-8 workgroup = |WORKGROUP| browseable = yes deadtime = 30 domain master = yes encrypt passwords = true enable core files = no guest account = nobody guest ok = no invalid users = root local master = yes load printers = no map to guest = Bad User max protocol = SMB2 min receivefile size = 16384 null passwords = no obey pam restrictions = yes os level = 20 passdb backend = smbpasswd preferred master = yes printable = no security = user smb encrypt = disabled smb passwd file = /etc/samba/smbpasswd socket options = TCP_NODELAY IPTOS_LOWDELAY syslog = 2 use sendfile = yes writeable = yes 変更部分は以下。 ^ display charset = UTF-8 | 日本語のファイル名も扱えるように UTF8 を使用。 | ^ unix charset = UTF-8 | 日本語のファイル名も扱えるように UTF8 を使用。 | ^ guest ok = no | guest ユーザはすべて不許可に変更。 | ^ null passwords = no | すべてのユーザにパスワード認証を要求するように変更。 | ===== 起動 ===== Samba を再起動し設定ファイルを再読み込みする。 # /etc/init.d/samba restart