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.

Answer from ron on Stack Exchange
Top answer
1 of 3
3

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.

2 of 3
3

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.

๐ŸŒ
TechRepublic
techrepublic.com โ€บ home โ€บ networking
How to Use Samba File Sharing for Linux and Windows
November 6, 2025 - Lists all shares available on the local Samba server. ... Youโ€™ll be prompted for the Samba password set with smbpasswd.
๐ŸŒ
Linux Mint Forums
forums.linuxmint.com โ€บ board index โ€บ main edition support โ€บ networking
Samba share password retrievel - Linux Mint Forums
June 10, 2015 - There are Samba file shares created which are visible on the network (when you try to map a drive in windows machine, they with other windows machine, Linux Server (Samba Server) and printers get visible). When you click to map these Samba Shares to a network drive letter on a windows machine, the windows machine prompts you to enter a username and password.
๐ŸŒ
FOG Project
wiki.fogproject.org โ€บ wiki โ€บ index.php
Password Protected Samba Share - FOG Project
October 11, 2016 - Feel free to copy/paste. security ... type ยท \\x.x.x.x\fogshare You will be prompted for a user and pass, give the smalluser as username, and the password you setup....
๐ŸŒ
Puppy Linux Discussion Forum
forum.puppylinux.com โ€บ board index โ€บ puppy linux main โ€บ house training โ€บ instructional how-to section โ€บ network/server
How to password protect Samba shares? (solved) - Puppy Linux Discussion Forum
February 9, 2021 - Add puppy users for each of the shares you want to protect: example is for new user = joe -open a terminal -type: adduser joe -enter a password for joe when prompted (write it down) Add samba users for each new user: example is for new user = joe -open a terminal -type: smbpasswd -a joe -enter a samba password for joe when prompted (use same password entered above)
๐ŸŒ
YouTube
youtube.com โ€บ watch
Set a password for your Samba share - YouTube
hey! in this clip i will tell how you can secure your samba share with a password and protect your files.#sambapassword, #smb, #samba, #sambashare
Published ย  January 17, 2022
Top answer
1 of 5
36

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

2 of 5
6

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.

Find elsewhere
๐ŸŒ
Samba
samba.org โ€บ samba โ€บ docs โ€บ using_samba โ€บ ch09.html
Samba
If a user attempts to connect to an ordinary share that doesn't appear in the smb.conf file (such as specifying it with a UNC in Windows Explorer), Samba will search for a [homes] share. If one exists, the incoming share name is assumed to be a username and is queried as such in the password database ( /etc/passwd or equivalent) file of the Samba server.
Top answer
1 of 1
1

I finally got it to work. Here's what I had to change:

  1. Windows 10/11 have disabled the SMB1 protocol for security reasons. This is a good thing. While you can add SMB1 to Windows, as you'll see others suggests in posts, this is very insecure. Instead, we set the samba server to use at least SMB2 with "min protocol = SMB2".
  2. By upping the log level, I saw that even with SMB2 enabled, the connections were not using encryption, which causes a rejection. So we add "server smb encrypt = desired".
  3. Finally, Windows will send samba the currently logged in user name when it connects. So, for every user name you want to give access to the shares, make sure there is a corresponding user on the Linux system via "sudo useradd [user name]" and in samba "sudo smbpasswd -a [user]; sudo smbpasswd -e [user]".
  4. After that's done, the samba server can be restarted with "sudo systemctl restart smbd.service nmbd.service"

The smb.conf is below.

As an aside, if you're having trouble getting Windows to see your samba server, try installing avahi-daemon and wsdd. I needed both for the machine to advertise its name correctly. You can install them with "sudo apt install avahi-daemon wsdd"

FYI: you can have spaces in the names for the shares, but I removed them anyway.

smb.conf:

[global]
   encrypt passwords = yes
   server smb encrypt = desired
   min_protocol = SMB2
   
   workgroup = WorkGroup
   netbios name = sambaserver

   # Uncomment the following line for detailed logs in /var/log/samba
   # log level = 5

   server string = %h server (Samba, Ubuntu)
   wins support = yes
   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


# My file shares!
[public]
  comment = File Server Share
  path = /mypool/shared
  browseable = yes
  guest ok = yes
  read only = no
  create mask = 0755
  force user = nobody

[restricted]
  comment = Restricted Server Share
  path = /mypool/restricted
  browseable = yes
  guest ok = no
  read only = no
  create mask = 0755
  valid users = max
๐ŸŒ
Raspberry Pi Forums
forums.raspberrypi.com โ€บ board index โ€บ using the raspberry pi โ€บ beginners
SMB share only as guest, I want a password - Raspberry Pi Forums
If you just ran 'sudo smbpasswd -a' , then you set the Samba password for the user 'root', you should have run 'sudo smbpasswd -a pi' ... Thu Mar 11, 2021 12:16 pm What @topguy said and remove "public = yes" from your share definition then restart smbd. With "public = yes" guest logins are ...
๐ŸŒ
Linux Mint Forums
forums.linuxmint.com โ€บ board index โ€บ main edition support โ€บ networking
Which password is required by Samba? - Linux Mint Forums
August 24, 2019 - sudo smbpasswd -a clientuser It's that user and that samba password that needs to be passed to the server. And clientuser on the server must have Linux permissions to access the shared folder.
๐ŸŒ
Virtono
virtono.com โ€บ community โ€บ tutorial-how-to โ€บ samba-sharing-with-authentication
Samba Sharing With Authentication - Virtono Community
June 10, 2020 - $ sudo mount -t cifs // <IP-of-Samba-Server> / restricted / media / tniedermeier / test -o user = smbuser Password for smbuser @ // <IP-the-Samba-Server> / restricted: ******** For more information about mounted shares, use the mount terminal call .
๐ŸŒ
SambaWiki
wiki.samba.org โ€บ index.php โ€บ Setting_up_Samba_as_a_Standalone_Server
Setting up Samba as a Standalone Server - SambaWiki
Unfortunately this option does not work as intended at end-user access time, but it can be leveraged to simplify adding users to your samba Standalone Server. Because, when adding a samba user with ยท # smbpasswd -a demoUser New SMB password: Passw0rd Retype new SMB password: Passw0rd Added user demoUser.
๐ŸŒ
OneUptime
oneuptime.com โ€บ home โ€บ blog โ€บ how to configure samba user authentication and permissions on rhel
How to Configure Samba User Authentication and Permissions on RHEL
March 4, 2026 - Samba maintains its own password database (tdbsam) separate from the system's /etc/shadow. The security setting in smb.conf determines how Samba authenticates users: [global] # user - Samba handles authentication locally security = user # ads - Authentication via Active Directory # security = ads ยท Every Samba user must have a corresponding Linux system account: # Create a system account (no login shell, no home directory needed for share access) sudo useradd -M -s /sbin/nologin smbuser # Set the Samba password (separate from the system password) sudo smbpasswd -a smbuser
๐ŸŒ
Reddit
reddit.com โ€บ r/archlinux โ€บ where are the saved usernames and password saved for samba?
r/archlinux on Reddit: where are the saved usernames and password saved for samba?
September 23, 2020 -

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!!

๐ŸŒ
Ask Ubuntu
askubuntu.com โ€บ questions โ€บ 1341054 โ€บ samba-password-protected-share
server - Samba - Password protected share - Ask Ubuntu
We are a small company and the laptops are there to be used by several people, so it would be fantastic if I could lock the password protected folder after I finished with the laptop. We use Ubuntu 18.04 and about all our machines are windows 10 machines. ... [global] workgroup = WORKGROUP server string = PRIMARY %v netbios name = PRIMARY disable netbios = Yes security = user map to guest = bad user dns proxy = no ... Please format the pasted text as code using the { } icon above the edit question window. ... Have you tried matching samba username and password with the Windows username and password?