以下備忘録です。
パッケージ一覧を更新
| user@computer:~$ sudo apt update |
パッケージを更新
| user@computer:~$ sudo apt upgrade |
sambaパッケージをインストール
| user@computer:~$ sudo apt install samba |
sambaにユーザーを追加
但しubuntuにいるユーザーでないとダメ
パスワードを促されるがここはsamba専用
| user@computer:~$ sudo pdbedit -a sambauser |
共有用のディレクトリを作る
| user@computer:~$ mkdir /home/share |
ここで特定ユーザーの階層に作ってはアクセスできない
/home/user/shareではダメ
ディレクトリのアクセス権を設定
777はフルアクセス可
| user@computer:~$ sudo chmod 777 /home/share |
◆各種設定
現在のIPアドレスを調べる
| user@computer:~$ ip address show |
sambaのサーバー設定ファイルを書き換える
| user@computer:~$ sudo nano /etc/samba/smb.conf |
以下設定ファイルの書き換え
| [global] |
| dos charset = CP932 |
| unix charset = UTF-8 |
| |
| ◆追記部分 |
| |
| # Change this to the workgroup/NT-domain name your Samba server will part of |
| workgroup = WORKGROUP |
| |
| ◆必要があれば書き換える |
| |
| #### Networking #### |
| # The specific set of interfaces / networks to bind to |
| # This can be either the interface name or an IP address/netmask; |
| # interface names are normally preferred |
| interfaces = 192.168.XX.XX/24 XXXX |
| |
| ◆行の初めについていたセミコロンを消す |
| ◆127.0.0.0/8となっていた部分をネットワークアドレスに書き換える |
| |
| # Only bind to the named interfaces and/or networks; you must use the |
| # 'interfaces' option above to use this. |
| # It is recommended that you enable this feature if your Samba machine is |
| # not protected by a firewall or is a firewall itself. However, this |
| # option cannot handle dynamic or non-broadcast interfaces correctly. |
| bind interfaces only = yes |
| |
| ◆行の初めについていたセミコロンを消す |
| |
| map to guest = bad User |
| |
| ◆追記部分 |
| |
| [share] |
| path = /home/share |
| writeable = yes |
| guest ok = yes |
| guest only = yes |
| create mode = 0777 |
| directory mode = 0777 |
| |
| ◆追記部分 |
| |
| [usb-media] |
| path = /media |
| writable = yes
|
| guest ok = yes |
| read only = no guest only = yes |
| create mode = 0777 |
| directory mode = 0777 |
| force user = smb-share |
| |
| ◆USBのSSDをシェア |
smb.confの記述が間違っていないか確認
| user@computer:~$ testparm |
Loaded services file OK.と出れば問題なし
sambaの設定を読み込む(sambaの再起動)
| user@computer:~$ sudo systemctl restart smbd nmbd |
sambaの自動起動を指定
| user@computer:~$ sudo systemctl enable smbd nmbd |