SEARCH

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.

Lowell Heddings, better known online as the How-To Geek, spends all his free time bringing you fresh geekery on a daily basis. You can follow him on if you'd like.

  • Published 01/7/07

Comments (13)

  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.

  11. Najum

    Now all read this, since I explained more the following commands, because a Unix user is needed & most of you are thinking a Unix user is not needed. Seems like those who dont know that didnt even know Linux enough to figure out what “useradd” is doing here.

    #############################################
    sudo useradd -s /bin/true (user-name) | this creates the (UNIX) user not samba user
    sudo smbpasswd -L -a (user-name) | this will prompt you for a password (-a means add the existing Unix user to Samba password Data base).
    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.

  12. chris

    Thanks!

  13. shirish s

    Hi,
    I followed the given steps but still it dod not work.
    I think in some cases if it does not work then we need to add the below in the /etc/samba/smb.conf

    [username]
    path = /home/username
    guest ok = yes
    browseable = yes
    available = yes
    writable = yes
    public = yes

Get Free Articles in Your Inbox!

Join 134,000 newsletter readers

Email:

Go check your email!