Sambaによるファイルサーバーの構築です。
NASのように使えます、ぶっちゃけNASを設置するのが一番簡単ですが、興味本位でやってみます。
sudo dnf -y install samba samba-client cifs-utils ========================================================================================================================================= パッケージ アーキテクチャー バージョン リポジトリー サイズ ========================================================================================================================================= インストール: samba x86_64 4.17.2-103.el9 cifs-utils x86_64 6.14-1.el9 baseos 98 k samba-client x86_64 4.17.2-103.el9 appstream 673 k .... .... .... 完了しました!
# ■■■■ 共有フォルダー設定 ■■■■
共有フォルダを作ります
sudo mkdir /home/share
sudo chmod 777 /home/share
sudo vi /etc/samba/smb.conf
[global]
# 11行目 : 文字コードの設定を追記
unix charset = UTF-8
dos charset = CP932
workgroup = SAMBA
security = user
# アクセス許可するネットワーク設定を追記
hosts allow = 127. 10.0.0. (ご自分のネットワークに合わせてください)
# 追記 (認証不要とする)
map to guest = Bad User
....
....
....
# ■■■■ ユーザーのホームフォルダー設定 ■■■■
[homes]
#追加(/home/ユーザー名/sambaをホームディレクトリにする)
path = %H/
#ごみ箱の有効化
vfs objects = recycle
#ごみ箱のディレクトリ名(/home/ユーザ名/.recycle)
recycle:repository = .recycle
#ごみ箱へ移動時にディレクトリ構造を維持しない
recycle:keeptree = no
#同名のファイルがごみ箱にある場合に別名で移動
recycle:versions = yes
#ごみ箱へ移動時にタイムスタンプを更新しない
recycle:touch = no
#ごみ箱へ移動するファイルのサイズ上限(0:無制限)
recycle:maxsize = 0
#ここで指定したファイルはごみ箱へ移動せずに即削除する
recycle:exclude = *.tmp ~$*
....
....
....
# 最終行に追記
# 任意の共有名を設定
# ■■■■ フルアクセスの共有フォルダー設定 ■■■■
[Share]
# 共有フォルダーを指定
path = /home/share
# 書き込みを許可する
writable = yes
# ゲストユーザー (nobody) を許可する
guest ok = yes
# 全てゲストユーザーとして扱う
guest only = yes
# ファイル作成時のパーミッションを [777] とする
force create mode = 777
# フォルダー作成時のパーミッションを [777] とする
force directory mode = 777
保存して
sudo systemctl enable --now smb
firewall-cmd --add-service=samba
success
firewall-cmd --runtime-to-permanent
success
既存ユーザーをsambaユーザーにする
--既存のユーザをSambaサーバーアクセス用ユーザとする場合はここから-- sudo pdbedit -a centos ← Linuxに登録済のユーザをSambaサーバーアクセス用ユーザとして新規登録(例としてcentosとする) new password: ← パスワード応答 retype new password: ← パスワード応答(確認) Unix username: ysfarm NT username: Account Flags: [U ] User SID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Primary Group SID: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Full Name: centos Home Directory: \\linux\centos HomeDir Drive: Logon Script: Profile Path: \\linux\centos\profile Domain: linux 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: 土, 07 1月 2023 16:42:41 JST Password can change: 土, 07 1月 2023 16:42:41 JST Password must change: never Last bad password : 0 Bad password count : 0 Logon hours : FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
※参考サイト
https://centossrv.com/samba.shtml
https://www.server-world.info/