0
1

More than 1 year has passed since last update.

samba グループ内でのディレクトリ・フォルダ共有

Last updated at Posted at 2022-03-08

はじめに

sambaで意図したパーミッションを付与する際に嵌ってしまったため、sambaでのファイル共有手順のフローを投稿します。
結論としてはUbuntu側のumaskによるものだったようです。

行いたいこと

windowsのファイルエクスプローラからUbuntuのディレクトリにアクセスする。
また、同一グループのユーザ間でディレクトリ・フォルダを共有する。

sambaのインストール

$ sudo apt update
$ sudo apt install -y samba 

ポート開放

$ sudo ufw allow samba

ユーザ認証

Ubuntuに登録済みのユーザを以下のコマンドでsambaに追加する。

$ sudo pdbedit -a <username> 

smb.conf

/etc/samba/smb.conf を編集する。
workgroupはwindows側と合わせること。
各ユーザはUbuntuのアカウント上でに所属していること。
以下には差分のみ記述する。

/etc/samba/smb.conf
[global]
  unix charset = UTF8
  dos charset = cp932
  unix extensions = no
  wide links = yes
  workgroup = workgroup

[share]
  path = /mnt/hdd/share
  writeable = yes
  valid_user = @<group>
  force group = +<group>
  create mode = 0775
  directory mode = 0775
  force create mode = 0775
  force directory mode = 0775

Ubuntu側のumask変更

論理式
(DOSの属性 & directory mode) | (force directory mode)

でUNIX側のパーミッションが決定されるとあるが、うまくいかず嵌ってしまった。
実際には、Ubuntu側のumaskも関係してくるようである。

論理式
{(DOSの属性 & directory mode) | (force directory mode)} & (~umask)

また、username でsambaにログインしていても、/home/username/.bashrc のumaskの記述は反映されなかった。

/etc/login.defs 1 のumaskを変更し、

$ sudo service smbd restart

で設定が反映され意図したパーミッションを付与できた。

samba.conf の各種設定は以下を参照
参考URL :
http://www.samba.gr.jp/project/translation/current/htmldocs/manpages/smb.conf.5.html

  1. /etc/profile などで変更したほうが良いのかもしれない。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1