目次 >> samba
LAN内でsambaを使って、Windowsパソコンなどとファイルを共有する。
sambaを設定する際は、一時的にファイアウォールおよびSELinuxを切っておくことを勧める。接続できないなどのトラブルが起きた際に、sambaの設定が原因ではなく、これらの設定によりつながらないという場合も多いからである。sambaが正常に動作することがわかった後に、ファイアウォールなどを設定した方が原因が切り分けやすくなる。
また、日本 Samba ユーザ会が公開している「Sambaが動作しないときの診断方法」も問題解決に有効である。
Linux Mintにはデフォルトで入っている。
ubuntuの場合、apt-get install sambaでインストールする。
$ sudo apt-get install samba Reading package lists... Done Building dependency tree Reading state information... Done The following extra packages will be installed: libwbclient0 samba-common smbclient Suggested packages: openbsd-inetd inet-superserver smbldap-tools ldb-tools The following NEW packages will be installed: samba The following packages will be upgraded: libwbclient0 samba-common smbclient 3 upgraded, 1 newly installed, 0 to remove and 105 not upgraded. Need to get 23.8 MB of archives. After this operation, 23.7 MB of additional disk space will be used. Do you want to continue [Y/n]? y Get:1 http://us.archive.ubuntu.com/ubuntu/ natty-updates/main libwbclient0 amd64 2:3.5.8~dfsg-1ubuntu2.2 [54.5 kB] Get:2 http://us.archive.ubuntu.com/ubuntu/ natty-updates/main smbclient amd64 2:3.5.8~dfsg-1ubuntu2.2 [15.2 MB] Get:3 http://us.archive.ubuntu.com/ubuntu/ natty-updates/main samba-common all 2:3.5.8~dfsg-1ubuntu2.2 [326 kB] Get:4 http://us.archive.ubuntu.com/ubuntu/ natty-updates/main samba amd64 2:3.5.8~dfsg-1ubuntu2.2 [8,209 kB] Fetched 23.8 MB in 25min 56s (15.3 kB/s) Preconfiguring packages ... (Reading database ... 135690 files and directories currently installed.) Preparing to replace libwbclient0 2:3.5.8~dfsg-1ubuntu2 (using .../libwbclient0_2%3a3.5.8~dfsg-1ubuntu2.2_amd64.deb) ... Unpacking replacement libwbclient0 ... Preparing to replace smbclient 2:3.5.8~dfsg-1ubuntu2 (using .../smbclient_2%3a3.5.8~dfsg-1ubuntu2.2_amd64.deb) ... Unpacking replacement smbclient ... Preparing to replace samba-common 2:3.5.8~dfsg-1ubuntu2 (using .../samba-common_2%3a3.5.8~dfsg-1ubuntu2.2_all.deb) ... Unpacking replacement samba-common ... Selecting previously deselected package samba. Unpacking samba (from .../samba_2%3a3.5.8~dfsg-1ubuntu2.2_amd64.deb) ... Processing triggers for man-db ... Processing triggers for ureadahead ... ureadahead will be reprofiled on next reboot Processing triggers for ufw ... Setting up libwbclient0 (2:3.5.8~dfsg-1ubuntu2.2) ... Setting up samba-common (2:3.5.8~dfsg-1ubuntu2.2) ... Setting up smbclient (2:3.5.8~dfsg-1ubuntu2.2) ... Setting up samba (2:3.5.8~dfsg-1ubuntu2.2) ... Generating /etc/default/samba... Importing account for nobody...ok Importing account for satod...ok Importing account for yfxie...ok update-alternatives: using /usr/bin/smbstatus.samba3 to provide /usr/bin/smbstatus (smbstatus) in auto mode. smbd start/running, process 2542 nmbd start/running, process 2570 Processing triggers for libc-bin ... ldconfig deferred processing now taking place
yum install sambaでインストールする。
# yum install samba
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: ftp.tsukuba.wide.ad.jp
* extras: ftp.tsukuba.wide.ad.jp
* updates: ftp.tsukuba.wide.ad.jp
Resolving Dependencies
--> Running transaction check
---> Package samba.x86_64 0:4.2.3-10.el7 will be installed
--> Processing Dependency: samba-libs = 4.2.3-10.el7 for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: samba-common-tools = 4.2.3-10.el7 for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: samba-common-libs = 4.2.3-10.el7 for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: samba-common = 4.2.3-10.el7 for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: samba-common = 4.2.3-10.el7 for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: samba-client-libs = 4.2.3-10.el7 for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libwbclient = 4.2.3-10.el7 for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libxattr-tdb-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libwbclient.so.0(WBCLIENT_0.9)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libutil-tdb-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libutil-reg-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libtevent.so.0(TEVENT_0.9.9)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libtevent.so.0(TEVENT_0.9.16)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libtevent-util.so.0(TEVENT_UTIL_0.0.1)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libtdb.so.1(TDB_1.2.1)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libtalloc.so.2(TALLOC_2.0.2)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsocket-blocking-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsmbregistry-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsmbd-shim-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsmbd-base-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsmbconf.so.0(SMBCONF_0)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsmb-transport-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsecrets3-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsamba3-util-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsamba-util.so.0(SAMBA_UTIL_0.0.1)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsamba-sockets-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsamba-security-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsamba-passdb.so.0(SAMBA_PASSDB_0.2.0)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsamba-hostconfig.so.0(SAMBA_HOSTCONFIG_0.0.1)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsamba-debug-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsamba-cluster-support-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libreplace-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libpopt-samba3-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libndr.so.0(NDR_0.0.1)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libndr-standard.so.0(NDR_STANDARD_0.0.1)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libndr-samba-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libndr-nbt.so.0(NDR_NBT_0.0.1)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: liblibsmb-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libgse-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: liberrors-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libdbwrap-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libcliauth-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libcli-smb-common-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libcli-nbt-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libcli-cldap-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libccan-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libauth-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libCHARSET3-samba4.so(SAMBA_4.2.3)(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libxattr-tdb-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libwbclient.so.0()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libutil-tdb-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libutil-reg-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libtevent.so.0()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libtevent-util.so.0()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libtdb.so.1()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libtalloc.so.2()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsocket-blocking-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsmbregistry-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsmbd-shim-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsmbd-base-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsmbconf.so.0()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsmb-transport-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsecrets3-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsamba3-util-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsamba-util.so.0()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsamba-sockets-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsamba-security-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsamba-passdb.so.0()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsamba-hostconfig.so.0()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsamba-debug-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libsamba-cluster-support-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libreplace-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libpopt-samba3-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libndr.so.0()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libndr-standard.so.0()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libndr-samba-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libndr-nbt.so.0()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: liblibsmb-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libgse-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: liberrors-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libdbwrap-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libcliauth-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libcli-smb-common-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libcli-nbt-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libcli-cldap-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libccan-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libauth-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libaio.so.1()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Processing Dependency: libCHARSET3-samba4.so()(64bit) for package: samba-4.2.3-10.el7.x86_64
--> Running transaction check
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
---> Package libtalloc.x86_64 0:2.1.2-1.el7 will be installed
---> Package libtdb.x86_64 0:1.3.6-2.el7 will be installed
---> Package libtevent.x86_64 0:0.9.25-1.el7 will be installed
---> Package libwbclient.x86_64 0:4.2.3-10.el7 will be installed
---> Package samba-client-libs.x86_64 0:4.2.3-10.el7 will be installed
--> Processing Dependency: libldb.so.1(LDB_1.1.1)(64bit) for package: samba-client-libs-4.2.3-10.el7.x86_64
--> Processing Dependency: libldb.so.1(LDB_0.9.23)(64bit) for package: samba-client-libs-4.2.3-10.el7.x86_64
--> Processing Dependency: libldb.so.1(LDB_0.9.15)(64bit) for package: samba-client-libs-4.2.3-10.el7.x86_64
--> Processing Dependency: libldb.so.1(LDB_0.9.10)(64bit) for package: samba-client-libs-4.2.3-10.el7.x86_64
--> Processing Dependency: libldb.so.1()(64bit) for package: samba-client-libs-4.2.3-10.el7.x86_64
--> Processing Dependency: libcups.so.2()(64bit) for package: samba-client-libs-4.2.3-10.el7.x86_64
---> Package samba-common.noarch 0:4.2.3-10.el7 will be installed
---> Package samba-common-libs.x86_64 0:4.2.3-10.el7 will be installed
---> Package samba-common-tools.x86_64 0:4.2.3-10.el7 will be installed
---> Package samba-libs.x86_64 0:4.2.3-10.el7 will be installed
--> Processing Dependency: libpytalloc-util.so.2(PYTALLOC_UTIL_2.0.6)(64bit) for package: samba-libs-4.2.3-10.el7.x86_64
--> Processing Dependency: libpytalloc-util.so.2()(64bit) for package: samba-libs-4.2.3-10.el7.x86_64
--> Running transaction check
---> Package cups-libs.x86_64 1:1.6.3-22.el7 will be installed
---> Package libldb.x86_64 0:1.1.20-1.el7 will be installed
---> Package pytalloc.x86_64 0:2.1.2-1.el7 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
samba x86_64 4.2.3-10.el7 base 601 k
Installing for dependencies:
cups-libs x86_64 1:1.6.3-22.el7 base 355 k
libaio x86_64 0.3.109-13.el7 base 24 k
libldb x86_64 1.1.20-1.el7 base 123 k
libtalloc x86_64 2.1.2-1.el7 base 31 k
libtdb x86_64 1.3.6-2.el7 base 45 k
libtevent x86_64 0.9.25-1.el7 base 32 k
libwbclient x86_64 4.2.3-10.el7 base 95 k
pytalloc x86_64 2.1.2-1.el7 base 13 k
samba-client-libs x86_64 4.2.3-10.el7 base 4.3 M
samba-common noarch 4.2.3-10.el7 base 269 k
samba-common-libs x86_64 4.2.3-10.el7 base 155 k
samba-common-tools x86_64 4.2.3-10.el7 base 443 k
samba-libs x86_64 4.2.3-10.el7 base 258 k
Transaction Summary
================================================================================
Install 1 Package (+13 Dependent packages)
Total download size: 6.7 M
Installed size: 22 M
Is this ok [y/d/N]: y
Downloading packages:
(1/14): libaio-0.3.109-13.el7.x86_64.rpm | 24 kB 00:00
(2/14): cups-libs-1.6.3-22.el7.x86_64.rpm | 355 kB 00:00
(3/14): libldb-1.1.20-1.el7.x86_64.rpm | 123 kB 00:00
(4/14): libtalloc-2.1.2-1.el7.x86_64.rpm | 31 kB 00:00
(5/14): libtdb-1.3.6-2.el7.x86_64.rpm | 45 kB 00:00
(6/14): libtevent-0.9.25-1.el7.x86_64.rpm | 32 kB 00:00
(7/14): libwbclient-4.2.3-10.el7.x86_64.rpm | 95 kB 00:00
(8/14): pytalloc-2.1.2-1.el7.x86_64.rpm | 13 kB 00:00
(9/14): samba-4.2.3-10.el7.x86_64.rpm | 601 kB 00:00
(10/14): samba-common-4.2.3-10.el7.noarch.rpm | 269 kB 00:00
(11/14): samba-common-libs-4.2.3-10.el7.x86_64.rpm | 155 kB 00:00
(12/14): samba-client-libs-4.2.3-10.el7.x86_64.rpm | 4.3 MB 00:00
(13/14): samba-common-tools-4.2.3-10.el7.x86_64.rpm | 443 kB 00:00
(14/14): samba-libs-4.2.3-10.el7.x86_64.rpm | 258 kB 00:00
--------------------------------------------------------------------------------
Total 7.7 MB/s | 6.7 MB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : libtalloc-2.1.2-1.el7.x86_64 1/14
Installing : libtdb-1.3.6-2.el7.x86_64 2/14
Installing : libtevent-0.9.25-1.el7.x86_64 3/14
Installing : libldb-1.1.20-1.el7.x86_64 4/14
Installing : pytalloc-2.1.2-1.el7.x86_64 5/14
Installing : 1:cups-libs-1.6.3-22.el7.x86_64 6/14
Installing : samba-libs-4.2.3-10.el7.x86_64 7/14
Installing : samba-common-tools-4.2.3-10.el7.x86_64 8/14
Installing : samba-common-4.2.3-10.el7.noarch 9/14
Installing : libwbclient-4.2.3-10.el7.x86_64 10/14
Installing : samba-client-libs-4.2.3-10.el7.x86_64 11/14
Installing : samba-common-libs-4.2.3-10.el7.x86_64 12/14
Installing : libaio-0.3.109-13.el7.x86_64 13/14
Installing : samba-4.2.3-10.el7.x86_64 14/14
Verifying : libwbclient-4.2.3-10.el7.x86_64 1/14
Verifying : samba-client-libs-4.2.3-10.el7.x86_64 2/14
Verifying : libaio-0.3.109-13.el7.x86_64 3/14
Verifying : samba-common-libs-4.2.3-10.el7.x86_64 4/14
Verifying : libldb-1.1.20-1.el7.x86_64 5/14
Verifying : samba-common-tools-4.2.3-10.el7.x86_64 6/14
Verifying : 1:cups-libs-1.6.3-22.el7.x86_64 7/14
Verifying : samba-libs-4.2.3-10.el7.x86_64 8/14
Verifying : samba-4.2.3-10.el7.x86_64 9/14
Verifying : libtalloc-2.1.2-1.el7.x86_64 10/14
Verifying : libtdb-1.3.6-2.el7.x86_64 11/14
Verifying : samba-common-4.2.3-10.el7.noarch 12/14
Verifying : libtevent-0.9.25-1.el7.x86_64 13/14
Verifying : pytalloc-2.1.2-1.el7.x86_64 14/14
Installed:
samba.x86_64 0:4.2.3-10.el7
Dependency Installed:
cups-libs.x86_64 1:1.6.3-22.el7
libaio.x86_64 0:0.3.109-13.el7
libldb.x86_64 0:1.1.20-1.el7
libtalloc.x86_64 0:2.1.2-1.el7
libtdb.x86_64 0:1.3.6-2.el7
libtevent.x86_64 0:0.9.25-1.el7
libwbclient.x86_64 0:4.2.3-10.el7
pytalloc.x86_64 0:2.1.2-1.el7
samba-client-libs.x86_64 0:4.2.3-10.el7
samba-common.noarch 0:4.2.3-10.el7
samba-common-libs.x86_64 0:4.2.3-10.el7
samba-common-tools.x86_64 0:4.2.3-10.el7
samba-libs.x86_64 0:4.2.3-10.el7
Complete!
主要な設定は(CentOS7、openSUSE 10.0、ubuntu 15.10)
/etc/samba/smb.conf
で行う。
[共有名]でアクセス可能な共有フォルダを作成するが、[global]、[homes]、[printers]の各セクションは、特殊な設定を行うセクションである。
参考:http://www.samba.gr.jp/project/translation/3.0/htmldocs/
参考:http://www.samba.gr.jp/project/translation/3.0/htmldocs/smb.conf.5.html
FC5のデフォルトでは下記のようになっている。
# This is the main Samba configuration file. You should read the # smb.conf(5) manual page in order to understand the options listed # here. Samba has a huge number of configurable options (perhaps too # many!) most of which are not shown in this example # # Any line which starts with a ; (semi-colon) or a # (hash) # is a comment and is ignored. In this example we will use a # # for commentry and a ; for parts of the config file that you # may wish to enable # # NOTE: Whenever you modify this file you should run the command "testparm" # to check that you have not made any basic syntactic errors. # #======================= Global Settings ===================================== [global] # workgroup = NT-Domain-Name or Workgroup-Name workgroup = MYGROUP # server string is the equivalent of the NT Description field server string = Samba Server # This option is important for security. It allows you to restrict # connections to machines which are on your local network. The # following example restricts access to two C class networks and # the "loopback" interface. For more examples of the syntax see # the smb.conf man page ; hosts allow = 192.168.1. 192.168.2. 127. # if you want to automatically load your printer list rather # than setting them up individually then you'll need this printcap name = /etc/printcap load printers = yes # It should not be necessary to spell out the print system type unless # yours is non-standard. Currently supported print systems include: # bsd, sysv, plp, lprng, aix, hpux, qnx ; printing = cups # This option tells cups that the data has already been rasterized cups options = raw # Uncomment this if you want a guest account, you must add this to /etc/passwd # otherwise the user "nobody" is used ; guest account = pcguest # this tells Samba to use a separate log file for each machine # that connects log file = /var/log/samba/%m.log # all log information in one file # log file = /var/log/samba/log.smbd # Put a capping on the size of the log files (in Kb). max log size = 50 # Security mode. Most people will want user level security. See # security_level.txt for details. security = user # Use password server option only with security = server ; password server = <NT-Server-Name> # Password Level allows matching of _n_ characters of the password for # all combinations of upper and lower case. ; password level = 8 ; username level = 8 # You may wish to use password encryption. Please read # ENCRYPTION.txt, Win95.txt and WinNT.txt in the Samba documentation. # Do not enable this option unless you have read those documents ; encrypt passwords = yes ; smb passwd file = /etc/samba/smbpasswd # The following are needed to allow password changing from Windows to # update the Linux system password also. # NOTE: Use these with 'encrypt passwords' and 'smb passwd file' above. # NOTE2: You do NOT need these to allow workstations to change only # the encrypted SMB passwords. They allow the Unix password # to be kept in sync with the SMB password. ; unix password sync = Yes ; passwd program = /usr/bin/passwd %u ; passwd chat = *New*UNIX*password* %n\n *ReType*new*UNIX*password* %n\n *passwd:*all*authentication*tokens*updated*successfully* # Unix users can map to different SMB User names ; username map = /etc/samba/smbusers # Using the following line enables you to customise your configuration # on a per machine basis. The %m gets replaced with the netbios name # of the machine that is connecting ; include = /etc/samba/smb.conf.%m # Most people will find that this option gives better performance. # See speed.txt and the manual pages for details socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 # Configure Samba to use multiple interfaces # If you have multiple network interfaces then you must list them # here. See the man page for details. ; interfaces = 192.168.12.2/24 192.168.13.2/24 # Configure remote browse list synchronisation here # request announcement to, or browse list sync from: # a specific host or from / to a whole subnet (see below) ; remote browse sync = 192.168.3.25 192.168.5.255 # Cause this host to announce itself to local subnets here ; remote announce = 192.168.1.255 192.168.2.44 # Browser Control Options: # set local master to no if you don't want Samba to become a master # browser on your network. Otherwise the normal election rules apply ; local master = no # OS Level determines the precedence of this server in master browser # elections. The default value should be reasonable ; os level = 33 # Domain Master specifies Samba to be the Domain Master Browser. This # allows Samba to collate browse lists between subnets. Don't use this # if you already have a Windows NT domain controller doing this job ; domain master = yes # Preferred Master causes Samba to force a local browser election on startup # and gives it a slightly higher chance of winning the election ; preferred master = yes # Enable this if you want Samba to be a domain logon server for # Windows95 workstations. ; domain logons = yes # if you enable domain logons then you may want a per-machine or # per user logon script # run a specific logon batch file per workstation (machine) ; logon script = %m.bat # run a specific logon batch file per username ; logon script = %U.bat # Where to store roving profiles (only for Win95 and WinNT) # %L substitutes for this servers netbios name, %U is username # You must uncomment the [Profiles] share below ; logon path = \\%L\Profiles\%U # All NetBIOS names must be resolved to IP Addresses # 'Name Resolve Order' allows the named resolution mechanism to be specified # the default order is "host lmhosts wins bcast". "host" means use the unix # system gethostbyname() function call that will use either /etc/hosts OR # DNS or NIS depending on the settings of /etc/host.config, /etc/nsswitch.conf # and the /etc/resolv.conf file. "host" therefore is system configuration # dependant. This parameter is most often of use to prevent DNS lookups # in order to resolve NetBIOS names to IP Addresses. Use with care! # The example below excludes use of name resolution for machines that are NOT # on the local network segment # - OR - are not deliberately to be known via lmhosts or via WINS. ; name resolve order = wins lmhosts bcast # Windows Internet Name Serving Support Section: # WINS Support - Tells the NMBD component of Samba to enable it's WINS Server ; wins support = yes # WINS Server - Tells the NMBD components of Samba to be a WINS Client # Note: Samba can be either a WINS Server, or a WINS Client, but NOT both ; wins server = w.x.y.z # WINS Proxy - Tells Samba to answer name resolution queries on # behalf of a non WINS capable client, for this to work there must be # at least one WINS Server on the network. The default is NO. ; wins proxy = yes # DNS Proxy - tells Samba whether or not to try to resolve NetBIOS names # via DNS nslookups. The built-in default for versions 1.9.17 is yes, # this has been changed in version 1.9.18 to no. dns proxy = no # Case Preservation can be handy - system default is _no_ # NOTE: These can be set on a per share basis ; preserve case = no ; short preserve case = no # Default case is normally upper case for all DOS files ; default case = lower # Be very careful with case sensitivity - it can break things! ; case sensitive = no #============================ Share Definitions ============================== [homes] comment = Home Directories browseable = no writable = yes # Un-comment the following and create the netlogon directory for Domain Logons ; [netlogon] ; comment = Network Logon Service ; path = /home/netlogon ; guest ok = yes ; writable = no ; share modes = no # Un-comment the following to provide a specific roving profile share # the default is to use the user's home directory ;[Profiles] ; path = /home/profiles ; browseable = no ; guest ok = yes # NOTE: If you have a BSD-style print system there is no need to # specifically define each individual printer [printers] comment = All Printers path = /var/spool/samba browseable = no # Set public = yes to allow user 'guest account' to print guest ok = no writable = no printable = yes # This one is useful for people to share files ;[tmp] ; comment = Temporary file space ; path = /tmp ; read only = no ; public = yes # A publicly accessible directory, but read only, except for people in # the "staff" group ;[public] ; comment = Public Stuff ; path = /home/samba ; public = yes ; read only = yes ; write list = @staff # Other examples. # # A private printer, usable only by fred. Spool data will be placed in fred's # home directory. Note that fred must have write access to the spool directory, # wherever it is. ;[fredsprn] ; comment = Fred's Printer ; valid users = fred ; path = /homes/fred ; printer = freds_printer ; public = no ; writable = no ; printable = yes # A private directory, usable only by fred. Note that fred requires write # access to the directory. ;[fredsdir] ; comment = Fred's Service ; path = /usr/somewhere/private ; valid users = fred ; public = no ; writable = yes ; printable = no # a service which has a different directory for each machine that connects # this allows you to tailor configurations to incoming machines. You could # also use the %u option to tailor it by user name. # The %m gets replaced with the machine name that is connecting. ;[pchome] ; comment = PC Directories ; path = /usr/pc/%m ; public = no ; writable = yes # A publicly accessible directory, read/write to all users. Note that all files # created in the directory by users will be owned by the default user, so # any user with access can delete any other user's files. Obviously this # directory must be writable by the default user. Another user could of course # be specified, in which case all files would be owned by that user instead. ;[public] ; path = /usr/somewhere/else/public ; public = yes ; only guest = yes ; writable = yes ; printable = no # The following two entries demonstrate how to share a directory so that two # users can place files there that will be owned by the specific users. In this # setup, the directory should be writable by both users and should have the # sticky bit set on it to prevent abuse. Obviously this could be extended to # as many users as required. ;[myshare] ; comment = Mary's and Fred's stuff ; path = /usr/somewhere/shared ; valid users = mary fred ; public = no ; writable = yes ; printable = no ; create mask = 0765
[global]では、samba全体の設定を行う。以下、記述順序は関係ない。
項目 | 設定値 | デフォルト | 内容 |
---|---|---|---|
netbios name | 文字列 | PCのDNS名 | ネットワークコンピュータ名 |
server string | 文字列 | なし | ネットワークコンピュータで表示される説明文字列 |
security | share|user|domain | user | セキュリティモデルを指定する。userの場合、アクセスする際に、ユーザー名とパスワードが自動的に送信される。userの場合、guestユーザを使うにはひと工夫いる。shareの場合、ユーザー名とパスワードを入力する必要があり、このユーザー名とパスワードを知っている人なら誰でも共有フォルダにアクセスできる。domainはドメインを使用するときに使う。 なおshareは廃止予定であるので注意。(実際、CentOS7では使えない)user + map to guest=Bad Userで代用可能。 |
workgroup | 文字列 | WORKGROUP | ワークグループ名を指定する |
wins support | Yes|No | No | wins support, prefered master, local master, os levelの項目を調整することで、ネットワーク内のほかのパソコンを見えるようにする。 |
preferred master | Yes|No | auto | Yesにするとワークグループのマスタブラウザになりやすくなる |
local master | Yes|No | auto | |
os level | 数値 | 20 | 数値が高いほど優先順位が高くなり、ローカルマスタブラウザになりやすくなる。 |
map to guest | Bad User|Never | Never | この項目はsecurityがshare 以外の時のみ有効。Bad Userの場合、ゲストとしてのアクセスを許可します。Neverの場合、ゲストとしてはアクセスできません。 |
hosts allow | IPアドレス | なし(全てOK) | アクセスを許可するIPアドレスを指定する。hosts denyと矛盾する場合allowが優先される |
hosts deny | IPアドレス | なし | アクセスを拒否するIPアドレスを指定する。 |
unix charset dos charset display charset |
なし | 文字化けする場合に変更する。 | |
ldap ssl | |||
printcap name |
各ユーザーが自分のユーザー名でアクセスしたときに、自分のホームディレクトリに接続されるようになる。すなわち、同じマシンから同じ共有名で接続しても、接続するユーザー名によって、接続されるディレクトリが変わる。
例えば、fooというユーザー名であれば、
\\example.com\foo
で自分のホームディレクトリにアクセスすることができる。
設定可能な項目一覧は、[共有名]セクションと共通。
項目 | 設定値 | デフォルト | 内容 |
---|---|---|---|
comment | 文字列 | なし | ネットワークコンピュータ名 |
項目 | 設定値 | デフォルト | 内容 |
---|---|---|---|
writeable | Yes|No | No | このフォルダへの書き込みを許可する |
read only | Yes|No | Yes | writeableの逆 |
guest only | Yes|No | No | このフォルダは常にguestユーザーでログインする |
guest ok | Yes|No | No | guestアカウントでのログインを許可する |
public | Yes|No | No | guest okと同義 |
browseable | Yes|No | Yes | フォルダ一覧に表示する |
create mask | 数値 | 0744 | ファイル作成時のパーミッションを指定する |
comment | 文字列 | なし | server stringのフォルダ版。 |
hide dot files | Yes|No | ||
inherit acls | Yes|No | ||
valid users | |||
veto files | 文字列 | なし | アクセスを許可しないファイルを指定する。 |
パスワード不要でアクセスするディレクトリのみである場合はこの設定は不要
SambaはLinuxのユーザーが存在しているだけでは使えない。Sambaが独自に持つデータベースにユーザーを登録してやる必要がある。
sambaユーザーの追加はsmbpasswdを-aオプションをつけてrootで起動する。具体的には、fooというユーザー名のユーザーを追加するには
# smbpasswd -a foo
smbpasswdは各ユーザーも使うことができ、その際は自分のsambaのパスワードを変更することが出来る。この際に、globalセクションで
unix password sync = Yes
の設定がなされていると、Linuxのパスワードも同時に変更される。(その逆にpasswdでLinuxのパスワードを変更しても、samba側に反映するというようなことは出来ない。)
FC5の場合は、下記のコマンドでsmbとnmbの両方が起動される。
# /etc/init.d/smb startopenSUSE 10.0の場合は、必ず、smbとnmbデーモンの両方を手動で起動する必要がある。
Starting SMB services: [ OK ]
Starting NMB services: [ OK ]
# /etc/init.d/smb stop
Shutting down SMB services: [ OK ]
Shutting down NMB services: [ OK ]
# /etc/init.d/smb restart
Shutting down SMB services: [ OK ]
Shutting down NMB services: [ OK ]
Starting SMB services: [ OK ]
Starting NMB services: [ OK ]
/etc/init.d/smb start
/etc/init.d/nmb start
/etc/init.d/smb stop
/etc/init.d/nmb stop
/etc/init.d/smb restart
/etc/init.d/nmb restart
ubuntu 15.10、Linux Mint17.3では
$ sudo service smbd restart
smbd stop/waiting
smbd start/running, process 6876
/ $ sudo service nmbd restart
nmbd stop/waiting
nmbd start/running, process 6901
CentOS7でもsmbとnmbデーモンの両方を手動で起動する必要がある。
#systemctl start smb
#systemctl start nmb
サーバの状態は
#systemctl status smb
#systemctl status nmb
で調べることができる。
サーバ起動時に自動起動するようにするには、
FC5では
# chkconfig smb on
念のため確認
# chkconfig smb --list
smb 0:off 1:off 2:on 3:on 4:on 5:on 6:off
openSUSE 10.0では
# chkconfig smb on
# chkconfig nmb on
念のため確認
# chkconfig smb --list
smb 0:off 1:off 2:off 3:on 4:off 5:on 6:off
# chkconfig nmb --list
nmb 0:off 1:off 2:off 3:on 4:off 5:on 6:off
CentOS7ではsystemdを使う
# systemctl enable smb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/smb.service to /usr/lib/systemd/system/smb.service.
# systemctl enable nmb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/nmb.service to /usr/lib/systemd/system/nmb.service.
設定されているか確認するにはsystemctl is-enabledコマンドを使う。
# systemctl is-enabled smb
enabled
# systemctl is-enabled nmb
enabled
sambaにうまく接続できないという場合の原因の解明はなかなか難しい。まずは、ファイアウォール、SELinuxなど、samba以外の原因を排除した後に、sambaの設定を見直す。sambaの設定の見直し方については下記のサイトを参照のこと。
参考:http://www.samba.gr.jp/doc/diag.html
以下いくつかの例をあげる
これは、会社内などで、ネットワークにつながったどのパソコンからも資料などにアクセスしたいが、ほかの人には勝手に書き換えられてしまっては困るなど、保護したい場合に適している。
[global] include = /etc/samba/dhcp.conf domain master = No map to guest = Bad User wins support = true netbios name = SERVER cups options = raw server string = smb workgroup = WORKGROUP os level = 65 server signing = auto printcap name = cups security = share add machine script = /usr/sbin/useradd -c Machine -d /var/lib/nobody -s /bin/false %m$
[global] workgroup = WORKGROUP server string = Samba Server log file = /var/log/samba/%m.log os level = 65 local master = yes preferred master = yes wins support = yes [public] path = /usr/somewhere/else/public public = yes only guest = yes writable = yes printable = no
これは、家庭内などで誰でも自由にアクセスできるネットワークドライブが必要な場合に適している。
ギガビット接続におけるsambaのベンチマークの一例。この程度あれば、ローカルディスクと変わりないレベルで使用できる。
----------------------------------------------------------------------- CrystalDiskMark 3.0 x64 (C) 2007-2010 hiyohiyo Crystal Dew World : http://crystalmark.info/ ----------------------------------------------------------------------- * MB/s = 1,000,000 byte/s [SATA/300 = 300,000,000 byte/s] Sequential Read : 73.010 MB/s Sequential Write : 113.098 MB/s Random Read 512KB : 72.375 MB/s Random Write 512KB : 108.903 MB/s Random Read 4KB (QD=1) : 8.647 MB/s [ 2111.2 IOPS] Random Write 4KB (QD=1) : 7.224 MB/s [ 1763.7 IOPS] Random Read 4KB (QD=32) : 116.537 MB/s [ 28451.3 IOPS] Random Write 4KB (QD=32) : 116.595 MB/s [ 28465.6 IOPS] Test : 100 MB [Y: 7.8% (17.1/219.9 GB)] (x5) Date : 2010/11/10 12:44:49 OS : Windows XP Professional SP2 [5.2 Build 3790] (x64)
globalセクションに
vfs objects = recycle
を追加する。
MacのOSXでは、Lionでそれまでのsambaサーバから独自のサーバになり、さらにMavericksではSMB2が、YosemiteではSMB3が標準のプロトコルとなった。これは数々の問題を引き起こしており、WindowsやAndroidなどApple製品以外から接続する場合は特に深刻である。先進的なプロトコルにはそれなりに利点はあるものの、ファイルサーバというサーバとしてはかなり基本的な機能がこのような問題を多く抱えた状態でリリースされたことにははなはだ疑問である。いずれにせよ、抜本的な改善にはApple製のSMBサーバを切り、sambaサーバをインストールするのが最も手っ取り早く、かつ、問題が起きた際も、今まで蓄積された知識を元に解決しやすい。
さて、sambaのインストールであるが、MacPorts(https://www.macports.org/)を使ってインストールする。
https://www.macports.org/install.phpから、使用しているOSバージョンに適切なものをダウンロードする。 もしXcodeをインストールしていないなら、あらかじめインストールし、少なくとも一度は起動して、ライセンスに同意しておく。 MacpPortsのインストールは、ダウンロードしたファイルをダブルクリックで開き、基本的に次へ次へと進めていけばよい。たいていの場合、デフォルトで問題ないはずである。
sambaのインストールはコマンドプロンプトを開き
$sudo port install samba3
と打つ。
設定ファイルは
/opt/local/etc/samba3/smb.conf
になるが、インストール直後は存在しない。サンプルファイルが同じフォルダにあるので、
$sudo cp smb.conf.sample smb.conf
とコピーしてやる。smb.confファイルはLinuxなどの時と同様に書けばよい。
workgroupは初期状態では
workgroup = MYGROUP
となっているので、Windowsのデフォルトとあわせるなら、
workgroup = WORKGROUP
に書き換える。
MacとWindowsでは濁点、半濁点の扱い方が少々違っているので、何も設定しない場合、文字化けではないが、少しおかしくなっている。そのときは、[global]セクション内で
unix charset = UTF-8-MAC
を追加してやるとよい。
まず、OSXのNETBIOSサーバを停止しておく。
$sudo launchctl stop com.apple.netbiosd $sudo launchctl unload -w /System/Library/LaunchDaemons/com.apple.netbiosd.plist
次に、/Library/LaunchDaemons/org.samba.smbd.plistというテキストファイルを下記の内容で作成
<plist version="1.0"> <dict> <key>Label</key> <string>org.samba.smbd</string> <key>OnDemand</key> <false/> <key>ProgramArguments</key> <array> <string>/opt/local/sbin/smbd</string> <string>-F</string> </array> <key>RunAtLoad</key> <true/> <key>ServiceDescription</key> <string>samba</string> </dict> </plist>
また、/Library/LaunchDaemons/org.samba.nmbd.plistというテキストファイルを下記の内容で作成
<plist version="1.0"> <dict> <key>Label</key> <string>org.samba.nmbd</string> <key>OnDemand</key> <false/> <key>ProgramArguments</key> <array> <string>/opt/local/sbin/nmbd</string> <string>-F</string> </array> <key>RunAtLoad</key> <true/> <key>ServiceDescription</key> <string>netbios</string> </dict> </plist>
する。
そして、下記のコマンドで起動する。
$sudo launchctl load /Library/LaunchDaemons/org.samba.smbd.plist $sudo launchctl load /Library/LaunchDaemons/org.samba.nmbd.plist
これで、ほかのパソコンから共有フォルダを見られるはずである。
smb.confで設定を書き換えた場合は、再起動してやる必要がある。再起動コマンドはないので、停止しコマンドを発行しその後起動コマンドを発行する
$sudo launchctl unload /Library/LaunchDaemons/org.samba.smbd.plist $sudo launchctl unload /Library/LaunchDaemons/org.samba.nmbd.plist
で停止の後、
$sudo launchctl load /Library/LaunchDaemons/org.samba.smbd.plist $sudo launchctl load /Library/LaunchDaemons/org.samba.nmbd.plist
で、再度起動。
Windows 10ではSambaサーバーがSMB2もしくはSMB3を使用してマスタブラウザになっていると、エクスプローラー上に表示されない(\\serverではアクセスできるし、net
viewでも表示される、net useでも接続可能にもかかわらずである)。
解決法の一つは、SambaサーバーのSMBのバージョンを下げることである。
max protocol = NT1
しかし、これは性能を犠牲にすることにもなる。
一般的には、常時起動しているLinuxサーバーがwinsサーバーになったり、マスタブラウザになるのが望ましいが、ここではLinuxがマスタブラウザにならないようにすることによって解決する。具体的には
[global] wins support = no domain master = no local master = no preferred master = no os level = 0
とするとよい。
LAN外のサーバのディレクトリをLAN内で使えるようにするには2つの方法がある。一つは、OpenVPNを使う方法、もう一つはsshfsを使う方法である。OpenVPNを使う方法では、クライアントは遠隔地のサーバに直接つなぎにいく。一方、sshfsを使う方法では、LAN内のサーバが、sshfsで遠隔地のサーバのディレクトリをマウントして、それをsambaで公開する。詳しいやり方についてはそれぞれの解説ページを参照されたし。
最終更新日