Dear visitor, in case we do not cover a topic you are looking for, then feel free to ask in our freshly created forum for IT-professionals for a solution. We hope our visitors can help you out with your questions. Have a good one. ~ Tom.

How to install/configure Samba basics on CentOS7

Install Samba

# yum -y install samba*

Enable Samba

# systemctl start smb

systemctl enable smb

Sample configuration

The sample configuration below can be used to get access to your linux root folder via \ip-address\root$ with the user root.

# cat /etc/samba/smb.conf

See smb.conf.example for a more detailed config file or

read the smb.conf manpage.

Run 'testparm' to verify the config is correct after

you modified it.


[global]
workgroup = SAMBA
security = user
passdb backend = tdbsam
printing = cups
printcap name = cups
load printers = yes
cups options = raw

[homes]
comment = Home Directories
valid users = %S, %D%w%S
browseable = No
read only = No
inherit acls = Yes

[printers]
comment = All Printers
path = /var/tmp
printable = Yes
create mask = 0600
browseable = No

[print$]
comment = Printer Drivers
path = /var/lib/samba/drivers
write list = root
create mask = 0664
directory mask = 0775

[root$]
force user = root
create mask = 0755
writeable = yes
browsable = yes
path = /

Manage Samba users

In this example a new Linux user called ‘admin’ will be created/modified/removed and this user will be added to the samba configuration.

Add users

# useradd admin

passwd admin

smbpasswd -a admin

Modify users

# passwd admin

smbpasswd admin

Remove users

# smbpasswd -x admin

userdel -r admin

Allowing user to access samba share

Configure the Samba share in the /etc/samba/smb.conf configuration file to allow the new user to browse the share:

# vi /etc/samba/smb.conf
[share1]
comment = A Shared Directory
path = /var/tmp/sharedir
valid users = admin
public = no
writable = yes

Reload the smb.conf configuration file with below command.

# systemctl reload smb

Mount driveletter from windows

To mount the example above, use this command on Windows cmd.exe-terminal:

net use L: \\ip-address\root$ /user:root your_password

Troubleshooting

Looking at the message log file at /var/log/messages showed the following:

# tail -f /var/log/samba/log.smbd

smbd: make_connection_snum: canonicalize_connect_path failed for service share, path /PATH TO SHARE/share

In case you see this error message, while you try to connect to your share, then verify following settings.

Make sure the folder has the execute bit enabled

# chmod -R a+x /PATH TO SHARE/

Make sure smbv2 is enabled

# vi /etc/samba/smb.conf
[Global]
min protocol = SMB2

systemctl restart smb

Make sure SELinux is disabled

# vi /etc/selinux/config
SELINUX=disabled

reboot

 

 

One thought on “How to install/configure Samba basics on CentOS7

  • This otherwise useful explanation is fine until the net use statement, which does not follow the example and use the share name in the square brackets of the example stanza.

    On Windows 10 it should be:

    net use L: \\host.example.com\share1 /user:admin

    and it will prompt for your password.

    Besides, doing a root share is not good security. Making the username admin is also not so good .

    On macOS Catalina, instead of net use one would open Finder / Go / Connect to Server and enter:

    smb://admin@host.example.com/share1

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.