本文最后更新于 977 天前,其中的信息可能已经有所发展或是发生改变。
Simple Samba file sharing server setup
This is a minimal Samba setup to let other machines access files on a Debian machine.
Install Samba Server and Samba Client
sudo apt-get install samba
sudo apt-get install samba-client
Server
Edit the Samba configuration file.
sudo vim /etc/samba/smb.conf
To share files in some other path on the system, add another share definition such as:
[ourfiles]
comment = Some useful files
read only = no
locking = no
path = /path_to_our_files
guest ok = no
Add Samba users
Samba uses it’s own password system so users need to be added by root. Note that the users have to exist in /etc/passwd
sudo smbpasswd -a username
You will be prompted for a password for each of those users.
To list existing Samba users:
sudo pdbedit -w -L
Restart the Samba daemon
sudo /etc/init.d/samba restart
//or, if you are using systemd
sudo systemctl restart smbd
Client
Try to access the shares (as a normal user)
Try locally first, then from another machine on the network which also installed samba client. When prompted, use the password entered when adding the user to Samba.
To access my share:
$ smbclient //ourmachine/me
To access your share:
$ smbclient -U you //ourmachine/you
To access our shared(!) share:
$ smbclient //ourmachine/ourfiles