Let's presume we have a specific folder on a Raspi that we want to share over the network, be it for file read/write access as a drive or as a media streaming endpoint.
The following sections explain how to configure the different protocol daemons.
For the sake of consistency, we define our shared folder as /mnt/mountpoint/share
and a user account without root priviledges pi
.
## create user
sudo adduser pi
## add user to group 'users'
sudo usermod -a -G users pi
## create group 'shareusers'
sudo groupadd shareusers
## add 'pi' to 'shareusers'
sudo usermod -a -G shareusers pi
sudo apt install samba samba-common-bin avahi-daemon
sudo nano /etc/samba/smb.conf
# /etc/samba/smb.conf
[Share]
Comment = Raspberry Pi Shared Folder
Path = /mnt/mountpoint/share
Browseable = yes
Writeable = Yes
only guest = no
create mask = 0777
directory mask = 0777
Public = yes
Guest ok = yes
Optionally, add a [global]
section to the top to specify protoctol versions.
# /etc/samba/smb.conf
[global]
client min protocol = SMB3
client max protocol = SMB3
lanman auth = yes
keepalive = 0
Provide a (optionally different) password for user pi
.
sudo smbpasswd -a pi
sudo systemctl start smbd
# Windows
\\my-raspi\Share
# Posix
smb://my-raspi/Share
sudo apt install nfs-kernel-server
sudo nano /etc/exports
# /etc/exports
/mnt/mountpoint/share *(rw,all_squash,insecure,async,no_subtree_check,anonuid=1000,anongid=1000)
sudo exportfs -ra
nfs://my-raspi/mnt/mydrive/share
sudo apt install netatalk avahi-daemon
OR
sudo nano /etc/nsswitch.conf
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd: compat
group: compat
shadow: compat
gshadow: files
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4 mdns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
sudo nano /etc/netatalk/afp.conf
# /etc/netatalk/afp.conf
[Share]
path = /mnt/mountpoint/share
sudo service avahi-daemon start
sudo service netatalk start
afp://my-raspi/Share
The Rsync daemon can expose any folder to read/write access over rsync
.
rsync
can be used without running the daemon, via SSH or SMB.
This guide descibes how to install the daemon.
sudo apt install rsync xinetd
sudo nano /etc/default/rsync
# /etc/default/rsync
RSYNC_ENABLE=inetd
RSYNC_CONFIG_FILE=/etc/rsyncd.conf
RSYNC_NICE='10'
RSYNC_IONICE='-c3'
sudo nano /etc/rsyncd.conf
# /etc/rsyncd.conf
max connections = 2
log file = /var/log/rsync.log
timeout = 300
[Share]
comment = Rsync Share
path = /mnt/mountpoint/share
read only = no
list = yes
uid = pi
gid = shareusers
auth users = pi
secrets file = /etc/rsyncd.secrets
sudo nano /etc/rsyncd.secrets
sudo chmod 600 /etc/rsyncd.secrets
# /etc/rsyncd.secrets
pi:password
sudo nano /etc/xinetd.d/rsync
# /etc/xinetd.d/rsync
service rsync
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
flags = IPv6
}
sudo service xinetd restart
sudo apt install python3
python3 -m pip install python-ftp-server
python3 -m python-ftp-server -d "/mnt/mountpoint/share"
DO NOT USE FILEZILLA!
The simplest way to get a cheap HTTP server, is to run Python's http.simple
on a specified share.
It's not utterly performant, nor secure, but it's good enough to get access to a few files over HTTP.
(And since we're aiming for a local LAN access, it's ok. -- YMMV for production usage).
sudo apt install python3
python3 -m pip install http.simple
python3 -m http.simple 8100 ## e.g. for port 8100
sudo apt install minidlna
don't install Plex as it forces you to login to their service to access your own data
Rclone allows to mount a number a networked/cloud file services and to expose them through another network service. E.g. Google Drive to FTP or Local drive to DLNA is possible as well.
sudo apt install rclone
TODO: test configs
HTGWA: Create a Samba (SMB) share on a Raspberry Pi
HTGWA: Create an NFS share in Linux on a Raspberry Pi
Assign Read/Write Access to a User on Specific Directory in Linux
Raspberry Pi Time Machine (2021 update)
Python3 SimpleHTTPServer: The Complete Guide
Raspberry Pi Documentation
How to setup the rsync daemon on Linux
(in German) Tutorial: Raspberry Pi als rsync-Server für Backup der DS basteln
(in German) rsync on ubuntuusers.de