[RHEL 8] Samba の設定

[RHEL 8] Samba の設定

https://bitwalk.blogspot.com/2021/02/rhel-8-samba.html

RHEL 側の設定
参考サイト [2] の Samba の設定方法を参考にさせていただきました。

ホスト名の設定
まず NetworkManager のツール nmcli を使用して、/etc/hostname ファイル内の静的ホスト名を ‘smbfs’ に設定します。あとで Samba の設定をを /etc/samba/smb.conf ファイルにしますが、netbios name で設定する名前にもこのホスト名を使います。

$ sudo nmcli general hostname smbfs
$ hostname
smbfs
Samba のインストール
次に dnf コマンドで samba と関連パッケージをインストールします。

$ sudo dnf install samba
[sudo] bitwalk のパスワード:
Updating Subscription Management repositories.
メタデータの期限切れの最終確認: 0:02:12 時間前の 2021年02月10日 07時43分23秒 に実施しました。
依存関係が解決しました。
================================================================================
パッケージ Arch バージョン リポジトリー サイズ
================================================================================
インストール:
samba x86_64 4.12.3-12.el8.3 rhel-8-for-x86_64-baseos-rpms 840 k
依存関係のインストール:
samba-common-tools x86_64 4.12.3-12.el8.3 rhel-8-for-x86_64-baseos-rpms 484 k
samba-libs x86_64 4.12.3-12.el8.3 rhel-8-for-x86_64-baseos-rpms 188 k

トランザクションの概要
================================================================================
インストール 3 パッケージ

ダウンロードサイズの合計: 1.5 M
インストール済みのサイズ: 4.0 M
これでよろしいですか? [y/N]: y
:
:
Samba サービスの起動
Samba のサービスを利用するには、smb に加えて(ホスト名取得のため)nmb(NetBIOS 対応)のサービスも起動する必要があります。

$ sudo systemctl start smb nmb
$ sudo systemctl enable smb nmb
ファイアウォールの設定
Samba のサービスがファイアウォールを通るように設定します。

$ sudo firewall-cmd –add-service=samba –permanent
success
$ sudo firewall-cmd –reload
success
$ sudo firewall-cmd –list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: enp1s0
sources:
services: cockpit dhcpv6-client samba ssh
ports: 3389/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules:
$
smb.conf の設定
ルート権限で /etc/samba/smb.conf を編集します。今回は、Linux (RHEL) のユーザーアカウントのディレクトリを共有するだけです。

/etc/samba/smb.conf の設定例
# 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 = WORKGROUP
server string = SAMBA SERVER Version %v
netbios name = smbfs
security = user

passdb backend = tdbsam

dos charset = CP932
wins support = yes
#printing = cups
#printcap name = cups
load printers = no
disable spoolss = yes
#cups options = raw
unix extensions = no
wide links = yes

[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 = @printadmin root
# force group = @printadmin
# create mask = 0664
# directory mask = 0775
testparm コマンドで、編集した内容にスペルミスなどがないか確認します。

$ testparm
Load smb config files from /etc/samba/smb.conf
Loaded services file OK.
Server role: ROLE_STANDALONE

Press enter to see a dump of your service definitions

# Global parameters
[global]
disable spoolss = Yes
dos charset = CP932
load printers = No
security = USER
server string = SAMBA SERVER Version %v
unix extensions = No
wins support = Yes
idmap config * : backend = tdb
wide links = Yes

[homes]
browseable = No
comment = Home Directories
inherit acls = Yes
read only = No
valid users = %S %D%w%S
$
Samba ユーザーの追加とパスワードの設定
Samba ユーザーを登録するには、Linux 上の既存ユーザーの情報を使うか、あるいは新しいユーザーを作成してそのユーザー情報を使います。Samba の pdbedit コマンドに -a -u オプションを指定して以下のように実行します。ここでは、ユーザー bitwalk を Samba ユーザーに追加しています。パスワードは、Linux の bitwalk ユーザーと同じものを設定しています。

$ sudo pdbedit -a -u bitwalk
[sudo] bitwalk のパスワード:
new password:
retype new password:
:
:
トップへ
SELinux の設定
SELinux の setsebool コマンドで下記を実行します。

$ sudo setsebool -P samba_export_all_rw 1
$ sudo setsebool -P samba_enable_home_dirs 1
サービスの再起動
編集した設定を反映させるために、サービスを再起動します。

$ sudo systemctl restart smb nmb
トップへ
Windows から接続
Samba サーバへの接続を確認した Windows PC は下記のバージョンを使いました。

Windows 10 Home 20H2 (19042.789) x64 ベース
まず、エクスプローラを開いて、Samba サーバーのアドレスを入力します。この例では ¥¥192.168.0.25 と入力しています。

すると、ネットワーク資格情報の入力が求められますので、設定した Samba のユーザー名とパスワードを入力して OK ボタンをクリックします。

すると Samba サーバー側の bitwalk フォルダが表示されますので、フォルダを開けることを確認しておきます。

 

Linux、Netatalk、Samba、NFSを使用したファイルサーバーについて研究・運用しています。

fsをフォローする
参考リンク

コメント