Subscribe to How-To Geek

Create a Samba User on Ubuntu

If you are using Samba Server on your network, you will want to create users that have access to use it. There’s a very simple command structure on how to do so.

I’m assuming that you’ve already installed Samba Server at this point.

There are two steps to creating a user. First we’ll run the smbpasswd utility to create a samba password for the user.

sudo smbpasswd -a <username>

Next, we’ll add that username to the smbusers file.

sudo gedit /etc/samba/smbusers

Add in the following line, substituting the username with the one you want to give access to. The format is <ubuntuusername> = “<samba username>”. You can use a different samba user name to map to an ubuntu account, but that’s not really necessary right now.

<username> = “<username>”

Now you can create samba shares and give access to the users that you listed here.

| More
This article was originally written on 01/7/07 Tagged with: Ubuntu

Daily Email Updates

You can get our how-to articles in your inbox each day for free. Just enter your name and email below:


Name:
Email:

Comments (10)

  1. Atomicron

    Thanks for this tip. I was trying to get Mac OS 10.4.something to access a samba share on my Ubuntu file server and this did the trick. One small detail to note is that /etc/samba/smbusers file did not exist on my system (feisty fawn). However, just creating the file is the designated directory was all I had to do.

  2. Arvind

    I have no success with this method. I have installed Samba on a Debian Linux box and trying to connect from a Windows XP professional box. On the Windows box I have logged on using my corporate domain account. I created an /etc/samba/smbusers file and tried with both username= “domain\windows username” and username = “windows username”. It always prompts me for an username/password box. Am I missing something here ? Thanks.

  3. Roberto

    Thanks!

  4. stabbim

    Sweet, that worked. Like Atomicron, I had no file at /etc/samba/smbusers, but that was apparently not necessary for me. Just running the smbpasswd command was enough to get the user access.

    I assume the difference is just due to newer versions of Ubuntu/Samba, as this was originally posted over a year and a half ago. :)

  5. sathish

    Hi,

    I need to create multiple user in samba server not one by one, At the same time have to create multiple user. how to create this??

  6. Bob

    I am running Samba on Xubuntu, and your method did not work for me. Here is what I had to do:
    (in curlies are variables you must change for your own setup)

    sudo useradd -s /bin/true (user-name) | this creates the user
    sudo smbpasswd -L -a (user-name) | this will prompt you for a password
    sudo smbpasswd -L -e (username) | this enables the user

    –and then to verify–
    smbclient -L (your server name) -U(user you created)

    –I didn’t create these steps, I just copied them from other sources and they worked for me on Xubuntu–

  7. nbensa

    I’m sorry, but your “howto” won’t work. Samba needs a unix user!

    $ sudo adduser blah
    $ sudo smbpasswd -a blah

    Is the correct way. If you run a ldap backend, you can run:

    $ sudo smbldap-useradd -a blah -P

    and smbldap-tool will take care of unix user creation.

  8. james

    Thanks…this was the simplest solution to the problem. I always seem to forget how to do this when I reformat and this was very concise and direct to the point. Thanks!

  9. Al

    I disagree with James, Bobs instructions worked great.
    I did not create and Linux\Unix accounts.
    Created samba users as follows and accessed the shares from Windws Xp clients.

    sudo useradd -s /bin/true (user-name) | this creates the user
    sudo smbpasswd -L -a (user-name) | this will prompt you for a password
    sudo smbpasswd -L -e (username) | this enables the user

    –and then to verify–
    smbclient -L (your server name) -U(user you created)

    All created samba user accounts were also accessable from webmin Web GUI console.

  10. MilanK

    Al: you should learn that “useradd” creates a _linux_ account (user), not the samba one.

    The only difference to a regular user is that its shell is set to /bin/true (i.e. no shell, the command would just return “true” return code) and therefore such a linux user cannot login on console/GMD/KDM/SSH… Also, even that the user is added /etc/passwords, its home directory is not created.


Leave a Comment




Leave your friendly comment here.

If you have a computer help question, click here to leave it on the forums instead.

Note: Your comment may not show up immediately on the site.

Our Friends
Getting Started


About How-To Geek
What Is That Process?
svchost.exe
jusched.exe
dwm.exe
ctfmon.exe
wmpnetwk.exe
wmpnscfg.exe
rundll32.exe
wfcrun32.exe
Ipoint.exe
Itype.exe
Wfica32.exe
Mobsync.exe
conhost.exe
Dpupdchk.exe Adobe_Updater.exe

Copyright © 2006-2009 HowToGeek.com. All Rights Reserved.