2024年2月29日更新
Samba をインストール
sudo apt install samba
Sambaにユーザーを登録
sudo pdbedit -a $USER
Sambaの設定ファイルを編集
バックアップをとっておく。
sudo cp /etc/samba/smb.conf /etc/samba/smb.conf.bak
nano で編集。
sudo nano /etc/samba/smb.conf
以下のように編集。ゲストアクセスを禁止して、かつホームディレクトリを書き込み可能にしている。 最新のWindowsでは、セキュリティ上の理由でゲストアクセスが許可されているサーバーに接続できない。(最近のWindows BuildでSMBのゲストアクセスが禁止されたお話。 - Qiita)
pi@raspberrypi:~ $ diff -u /etc/samba/smb.conf.bak /etc/samba/smb.conf --- /etc/samba/smb.conf.bak 2019-09-26 14:49:35.997455457 +0100 +++ /etc/samba/smb.conf 2019-09-26 15:51:44.713498203 +0100 @@ -94,7 +94,7 @@ # This option controls how unsuccessful authentication attempts are mapped # to anonymous connections - map to guest = bad user + map to guest = never ########## Domains ########### @@ -162,7 +162,7 @@ # Allow users who've been granted usershare privileges to create # public shares, not just authenticated ones - usershare allow guests = yes + usershare allow guests = no #======================= Share Definitions ======================= @@ -172,15 +172,15 @@ # By default, the home directories are exported read-only. Change the # next parameter to 'no' if you want to be able to write to them. - read only = yes + read only = no # File creation mask is set to 0700 for security reasons. If you want to # create files with group=rw permissions, set next parameter to 0775. - create mask = 0700 + create mask = 0775 # Directory creation mask is set to 0700 for security reasons. If you want to # create dirs. with group=rw permissions, set next parameter to 0775. - directory mask = 0700 + directory mask = 0775 # By default, \\server\username shares can be connected to by anyone # with access to the samba server. @@ -234,3 +234,10 @@ # to the drivers directory for these users to have write rights in it ; write list = root, @lpadmin
一応gistに設定ファイルを貼っておく。 ホームディレクトリを読み書きするための smb.conf · GitHub
サービス再起動
sudo service smbd restart
Windows からアクセス
普通にエクスプローラーから \\raspberrypi.local
にアクセスする。(ユーザーはラズパイのもの)
Mac OS からアクセス
Finder で「移動」⇨「サーバーへ接続…」⇨「 smb://ユーザー名@raspberrypi.local/ (ここは構成次第)」⇨「接続」
iPad OS からアクセス
「ファイル」アプリで「サーバへ接続」から接続。自分の環境だと、ホスト名ではなくIPアドレスじゃないとつながらなかった。