Tuesday, December 11, 2012

samba: Simple configuration for one Windows/Unix user

Situation: we need to set up a samba server that will serve a single directory ("share") to one user. That user needs to access the directory (share) from both Windows and Unix systems.

The important thing to grasp here is that Windows uses encrypted passwords.

I assume that you already have samba installed and running on your system. First, create a smb.conf file. On my system, it lives in the /etc/samba directory. In my case, the username is admin:
        workgroup = SIMPLE 
        security = user
        encrypt passwords = yes
        smb passwd file = /etc/samba/smbpasswd
        comment = %U home directory
        writeable = yes
        valid users = admin
        path = %H

Next, create the admin user on the server using whatever means you ordinarily use to create new users. This is so the home directory, /home/admin gets created.

Then you have to ensure that samba knows that the user "admin" exists and what its password is. Samba's username/password database is stored in the file smbpasswd. Run the smbpasswd command with the -a parameter to add admin as a user to samba's user database:
# smbpasswd -a admin
New SMB password:

Type in, and retype, the same password that you used when you created admin as a Unix user.

Then restart the samba server. On openSUSE, I do:
# rcsmb restart
Shutting down Samba SMB daemon                                 done
Starting Samba SMB daemon                                      done

Next, try browsing to smb://samba-server/admin on Unix or \\samba-server\admin on Windows. It should ask for the username/password and then give you read/write access to admin's home directory on the server.

No comments:

Post a Comment