Yes, Samba can be a pain. I use it for my home as well as work.
The first thing you should do is start over from scratch to make troubleshooting easier. You can do this by running the command below in the terminal.
dpkg-reconfigure samba-common
Then go to the folder on the samba server that you want to share, and make sure that the user nobody can read and write to the share. This is because the user nobody is the username windows clients use. I usually just make a folder in the / directory just to keep things simple, but the "correct" way would be to make a subfolder of /srv. If you have not modified the permissions already, use the commands below.
sudo chown -R nobody.nogroup the_folder
sudo chmod -R 777 the_folder
You can also test to see if nobody can write to the directory by running the following command as root.
sudo -u nobody touch test_file
Edit your /etc/samba/smb.conf and add the lines below the [printers] share definition.
[share_name] ;the share name can be what ever you want
browseable = yes
path = the_complete_path_to_the_shared_folder
guest ok = yes
read only = no
create mask = 777
Then when you are done save it and run the following.
testparm
This will will warn you if you made any typos. Next, you just need to restart the samba services.
sudo systemctl restart smbd
sudo systemctl restart nmbd
Answer from Andrew on askubuntu.comYes, Samba can be a pain. I use it for my home as well as work.
The first thing you should do is start over from scratch to make troubleshooting easier. You can do this by running the command below in the terminal.
dpkg-reconfigure samba-common
Then go to the folder on the samba server that you want to share, and make sure that the user nobody can read and write to the share. This is because the user nobody is the username windows clients use. I usually just make a folder in the / directory just to keep things simple, but the "correct" way would be to make a subfolder of /srv. If you have not modified the permissions already, use the commands below.
sudo chown -R nobody.nogroup the_folder
sudo chmod -R 777 the_folder
You can also test to see if nobody can write to the directory by running the following command as root.
sudo -u nobody touch test_file
Edit your /etc/samba/smb.conf and add the lines below the [printers] share definition.
[share_name] ;the share name can be what ever you want
browseable = yes
path = the_complete_path_to_the_shared_folder
guest ok = yes
read only = no
create mask = 777
Then when you are done save it and run the following.
testparm
This will will warn you if you made any typos. Next, you just need to restart the samba services.
sudo systemctl restart smbd
sudo systemctl restart nmbd
I realise this is an old thread but it helped me to solve the issue of creating and sharing a folder with no login required. Plenty of other threads out there but they are misleading. I've given a semi biginners guide below as there are just so many small differences with other posts out there that I thought it might help someone else who's almost given up and pulled half their hair out :-)
For me, on a default AWS Linux image (Amazon Linux AMI 2017.03.0 (HVM)) I had to create the folder in the root dir / as I could not assign the permissions if created under the default ec2-user. When assigning the permissions I had to use nobody.nobody as nogroup didn't work. lastly I had to include map to guest = Bad User under the gloabl standalone server section where by default it says security = user
So the complete steps would be on deployment of a new server:
install samba if required
create the folder and assign permissions
sudo su
cd /
mkdir the_folder
chown -R nobody.nobody the_folder
chmod -R 777 the_folder
edit the samba file
nano /etc/samba/smb.conf
find the line # ---- Standalone Server Options ---- append "map to guest"
security = user
passdb backend = tdbsam
map to guest = Bad User
Under the section #==== Share Definitions ==== add your share
[SHARENAME]
path = the_folder
read only = no
create mask = 777
guest ok = yes
Save the file and restart samaba
/etc/init.d/smb restart
Videos
I finally found the solution:
[global]
workgroup = WORKGROUP
netbios name = NAS
log file = /var/log/samba/log.%m
max log size = 1000
logging = file
panic action = /usr/share/samba/panic-action %d
server role = standalone server
obey pam restrictions = yes
unix password sync = yes
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
pam password change = yes
map to guest = bad user
usershare allow guests = yes
[public]
path = /home/share
public = yes
guest only = yes
writable = yes
force create mode = 0666
force directory mode = 0777
browseable = yes
creates a share without any user/password login.
You can access it in Windows with \\NAS\public.
I use this. The script uses ACLs to gives all files in the directory to the Debian group "sambashare". This simplifies the exchange of files between local and remote users, because local and remote users can read and write all files in the directory.
mkdir /home/sambashare
chown nobody:sambashare /home/sambashare
chmod 2775 /home/sambashare
setfacl -R -dm u::rwx,g::rwx,o::r-x /home/sambashare
setfacl -R -m u::rwx,g::rwx,o::r-x /home/sambashare
cat >> /etc/samba/smb.conf <<EOF
[public]
comment = Public Share
path = /home/sambashare
browsable = yes
guest ok = yes
read only = no
create mask = 0664
directory mask = 2775
force create mode = 0660
force directory mode = 2770
force group = sambashare
inherit acls = yes
map acl inherit = yes
EOF
systemctl enable smbd
systemctl enable nmbd
usermod -aG sambashare localuser
You need guest ok = yes and guest only = yes on each service definition.
From the man page:
guest only (S)
If this parameter is yes for a service, then only guest connections to the service are permitted. This parameter will have no effect if guest ok is not set for the service.
See the section below on security for more information about this option.
Default: guest only = no
Note that either or both of these can be in the [global] section instead of the service definition. Also public is a synonym for guest ok and only guest is a synonym for guest only.
add "guest ok = yes" to your share definition. Also check folder rights.
To recheck your configuration log out and in on your windows client, that the connection is closed.
Also your should know, that your have to add the authenticated user to your guest share (when you have them), because windows only use one authentication session.
OK, I have found an answer myself.
As this is absolutely not obvious from the docs and HOWTOs and whatever, the reason this thing asks for password is because it cannot map guest user to the owner of the directory being shared.
I have NTFS partitions which I need to mount RW so I used the following setup in my /etc/fstab:
/dev/sdb1 /media/disk1 ntfs defaults,noexec,noatime,relatime,utf8,uid=1000,gid=1000 0 2
/dev/sdb2 /media/disk2 ntfs defaults,noexec,noatime,relatime,utf8,uid=1000,gid=1000 0 2
The most important pieces of config are uid and gid (maybe only uid, don't know).
They are set to the UID and GID of the user jonnie set up on the server (obviously not root). So, when ntfs-3g will mount these disks, everything will be owned by him.
After that, I have added this user to the Samba registry (or maybe created new identical one, don't care):
# smbpasswd -a jonnie
It asked for password, I have entered the same as for the main system.
After that, I have added the force user and force group settings to the smb.conf:
[global]
workgroup = WORKGROUP
netbios name = HOMESERV
security = user
map to guest = Bad User
[disk1]
comment = Disk 1 on 400GB HDD
path = /media/disk1
browsable = yes
guest ok = yes
read only = no
create mask = 666
directory mask = 777
force user = jonnie
force group = jonnie
[disk2]
comment = Disk 2 on 400GB HDD
path = /media/disk2
browsable = yes
guest ok = yes
read only = no
create mask = 666
directory mask = 777
force user = jonnie
force group = jonnie
So, most important piece of config relevant to me was force user.
Courtesy of the Samba HOWTO
The config can be shorter:
Create unix user jonnie
sudo useradd jonnie -s /usr/sbin/nologin
Create smbuser
sudo smbpasswd -a jonnie
Create the Linux directory to share
mkdir /mysmbshare
Change the owner of the directory to jonnie
sudo chown jonnie /mysmbshare
smb.conf
[global]
workgroup = MyWorkGroup
server string = Hello, use me
security = user
map to guest = Bad User
guest account = jonnie
passdb backend = tdbsam
[the_public_share]
path = /mysmbshare
writable = yes
printable = no
public = yes
All files are owned by jonnie and everyone has rw access to the files.