ひとり勉強ログ

ITエンジニアの勉強したことメモ

CentOS7.1にSambaをインストールしてファイルサーバーにする方法

CentOS7.1(1503)にSamba4.4.4をインストールし、Windowsクライアントからアクセスできるようにするための設定。

1.SELinuxを無効化

ファイルを開き [bash] [root@localhost ~]# vi /etc/selinux/config [/bash]

下記のように「SELINUX=」の部分を修正 [bash] SELINUX=disabled [/bash]

[bash] [root@localhost ~]# reboot [/bash]

2.Samba4.4.4をインストール

[bash] [root@localhost ~]# yum -y install samba4 samba4-client [/bash]

インストール後、バージョンを確認

[bash] [root@localhost ~]# smbd -V Version 4.4.4 [/bash]

3.共有させるフォルダの作成

[bash] [root@localhost ~]# mkdir /home/share [/bash]

共有フォルダのアクセス権は0777に設定

[bash] [root@localhost ~]# chmod 0777 /home/share [/bash]

4.Samba設定ファイルに追記

ファイルを開く [bash] [root@localhost ~]# vi /etc/samba/smb.conf [/bash]

下記のように表示される

[bash]

See smb.conf.example for a more detailed config file or

read the smb.conf manpage.

Run 'testparm' to verify the config is correct after

you modified it.

[global] workgroup = MYGROUP security = user

    passdb backend = tdbsam

    printing = cups
    printcap name = cups
    load printers = yes
    cups options = raw

[homes] comment = Home Directories valid users = %S, %D%w%S browseable = No read only = No inherit acls = Yes

[printers] comment = All Printers path = /var/tmp printable = Yes create mask = 0600 browseable = No

[print$] comment = Printer Drivers path = /var/lib/samba/drivers write list = root create mask = 0664 directory mask = 0775 [/bash]

workgroupを下記に変更

[bash] [global] workgroup = WORKGROUP [/bash]

下記を追記

[bash] [Share] comment = Share directory path = /home/share writable = yes guest ok = yes guest only = yes create mode = 0777 directory mode = 0777 [/bash]

5.Sambaユーザーの登録

既にLinuxで存在するユーザーを設定

[bash] [root@localhost ~]# pdbedit -a ユーザー名 [/bash]

上記コマンド実行後、パスワードを聞かれるので入力します。LinuxとSambaのユーザーは同一ですが、パスワードはそれぞれ違うものを設定することができます。

登録したSambaアカウントの情報は下記のコマンドで確認できます。

[bash] [root@localhost ~]# pdbedit -L -v [/bash]

6.Linux側で通信が行えるよう、firewallの設定を変更

[bash] [root@localhost ~]# firewall-cmd --permanent --zone=public --add-service=samba [/bash]

firewallを再起動

[bash] [root@localhost ~]# firewall-cmd --reload [/bash]

7.Sambaの再起動

[bash] [root@localhost ~]# systemctl restart smb nmb [/bash]

8.Windows10からSambaへアクセスする

エクスプローラー]を起動、「\192.168.0.11\share」にアクセス ※LinuxのプライベートIPアドレスが「192.168.0.11」の場合。

→上記pdbeditで設定したユーザー名、パスワードを入力

Linuxの「/home/share/」ディレクトリにアクセス可能に。

9.ネットワークドライブの割当

エクスプローラー]左メニュー内から「PC」を選択

→メニューの[コンピューター]から[ネットワークドライブの割り当て]を選択

→[ドライブ]を選択し、[フォルダー]に「\192.168.0.11\share」と入力、[完了]を押下