https://www.samba.org/samba/docs/using_samba/ch09.html
you can configure a share using guest ok = yes to allow access to guest users.
This works only when using share-level security
when needing info on something, consider going to the source rather than some other website, here is the table of contents to samba: https://www.samba.org/samba/docs/using_samba/toc.html
you are using
[GLOBAL]
security = user
which is the most restrictive, and for anyone from a Microsoft Windows system to even access any samba share from your linux system they will need to either have or know an account on that linux system, and then know the password.
part of my smb.conf is this
[global]
workgroup = WORKGROUP
passdb backend = tdbsam
security=user
map to guest = Bad User
# map to guest = nobody
usershare allow guests = No
server signing = auto
similiar to yours, the above will cause anyone on a windows system who does not have an account on the linux system to never connect, microsoft windows will respond with cannot access \\whatever_server_you_typed.
This is because Map to Guest = Bad User where "Bad User" does not exist on the linux system as a user account, it is also syntactically invalid because it has a space.
Using Map to Guest = nobody where nobody however is a valid linux account will result in microsoft windows prompting for a username and password, and this will happen when the given username from microsoft windows is not also a username on the linux system running samba-server.
If you choose this method under Security = User you can use the method i described above to potentially satisfy your security needs. Otherwise you would need to do security = share to accomplish what you initially asked to do- where anyone on the network can access a specific folder without being prompted for a password.
For Security the choices are User, Share, Server, and Domain. The samba help documents will describe what functionality is and is not available under each.
And I recommend you undo the guest account = root
I did not track down the guest account = option in the help docs, I assume it is the same as Map to Guest (just like the Public option is really Guest OK = yes) and for obvious security implications you don't want to map some unknown user to the root account.
https://www.samba.org/samba/docs/using_samba/ch09.html
you can configure a share using guest ok = yes to allow access to guest users.
This works only when using share-level security
when needing info on something, consider going to the source rather than some other website, here is the table of contents to samba: https://www.samba.org/samba/docs/using_samba/toc.html
you are using
[GLOBAL]
security = user
which is the most restrictive, and for anyone from a Microsoft Windows system to even access any samba share from your linux system they will need to either have or know an account on that linux system, and then know the password.
part of my smb.conf is this
[global]
workgroup = WORKGROUP
passdb backend = tdbsam
security=user
map to guest = Bad User
# map to guest = nobody
usershare allow guests = No
server signing = auto
similiar to yours, the above will cause anyone on a windows system who does not have an account on the linux system to never connect, microsoft windows will respond with cannot access \\whatever_server_you_typed.
This is because Map to Guest = Bad User where "Bad User" does not exist on the linux system as a user account, it is also syntactically invalid because it has a space.
Using Map to Guest = nobody where nobody however is a valid linux account will result in microsoft windows prompting for a username and password, and this will happen when the given username from microsoft windows is not also a username on the linux system running samba-server.
If you choose this method under Security = User you can use the method i described above to potentially satisfy your security needs. Otherwise you would need to do security = share to accomplish what you initially asked to do- where anyone on the network can access a specific folder without being prompted for a password.
For Security the choices are User, Share, Server, and Domain. The samba help documents will describe what functionality is and is not available under each.
And I recommend you undo the guest account = root
I did not track down the guest account = option in the help docs, I assume it is the same as Map to Guest (just like the Public option is really Guest OK = yes) and for obvious security implications you don't want to map some unknown user to the root account.
This is explained very well in this video.
https://www.youtube.com/watch?v=7Q0mnAT1MRg
I found it works better if you backup old smb.conf file and create a new one from scratch.
Go to /etc/samba folder.
sudo mv smb.conf smb.conf.bak
We can create a [global] settings in smb.conf file and a seperate file shares.conf for the individual folders.
Create a new smb.conf file.
sudo nano smb.conf
In smb.conf:
[global]
server string = File server
workgroup = WORKGROUP
security = user
map to guest = Bad User
name resolve order = bcast host
include = /etc/samba/shares.conf
Now create shares.conf file. Here i will show the password protected option since you already succeeded in public shares.
shares.conf:
[Private Share]
path=[give here the path to the folder to be shared]
force user = smbuser
force group = smbgroup
create mask = 0664
force create mode = 0664
directory mask = 0775
force directory mode = 0775
writable = yes
Create a system group smbuser.
sudo groupadd --system smbgroup
Now create a user smbuser,in smbgroup but do not create a home directory, and also deny the ability to log in to the system.
sudo useradd --system --no-create-home --group smbgroup -s /bin/false smbuser
Change the ownership of folder to be shared.
sudo chown -R smbuser:smbuser [folder path]
Give write access
sudo chmod -R g+w [folder path]
Add samba passwword to smbuser. This will be the password you have to give in windows for authentication to view the shared folder.
sudo smbpasswd -a smbuser
New SMB password:[password]
Retype new SMB password:[password]
Now restart smbd.
sudo systemctl restart smbd
In windows Run \\[ip address of samba system]
It will ask for username and password. Username is smbuser and the password is the one you gave.
Hope this was helpful.
Videos
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.
I understand I must use the credentials option like so
mount -t cifs //ip/share /mnt/backups -o credentials=/path/filename
But how do I set the username/password for the share? I guess I am confused.
In top menu of the file browser click Go>Location and enter smb://user@host/sharename.
You will then be prompted to enter a password.
If you have a Guest account without a password:
smb://Guest:@server_name
If you have a user account with a password:
smb://user_name:password@server_name
If you have a user account but only want to be prompted for the password:
smb://user_name:*@server_name
when you connect to a network that requires a password, a dialog box opens and a list of previous usernames and passwords are present in the drop down list, my question is, how do i delete them?
i'm a terrible typer (as-well as figuring out samba connections on arch) my list is sooo long and i cant find any way to clear it.
i am using KDE plasma 5 as my desktop environment.
i have reinstalled samba.
i have cleared application cache
honestly i don't know where to look, any help would be greatly appreciated!!
This was the key option to set to resolve this issue:
[global]
map to guest = bad user
From:
$ man smb.conf | grep -m1 -B8 -A16 'Bad User'
Bad User - Means user logins with an invalid password are rejected, unless the username does not exist, in which case it is treated as a guest login and mapped into the guest account.
This is the config that (finally) worked here. I can access a linux server from Windows without asking for a user/password:
[global]
workgroup = MYGROUP
server string = Samba Server %v
netbios name = debian
security = user
map to guest = bad user
dns proxy = no
#============= Share Definitions =================
[adriano]
force user = adriano
path = /home/adriano
browsable =yes
writable = yes
guest ok = yes
read only = no