Announcement

Collapse
No announcement yet.

[Almost SOLVED] Very very frustrated. Setting up a file server with samba

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    [Almost SOLVED] Very very frustrated. Setting up a file server with samba

    Hello,

    I'm writing here after having wasted literally tens of hours of time on this issue. I've searched the web, read tutorials and manuals, experimented, reinstalled, and so on... for weeks now.

    All I want to do, is create a simple file server where I can put all the files I want to use from all my computers (4 for now, 3 with Linux and 1 with Windows XP).
    Every user must have a share just for himself (not readable/browsable by others). And there must be at least 2 shares where a given set of users can all read/write/delete/whatever.
    As most users of these computers are not "computer-literate", I want a simple way to graphically see the available shares, click on them, give their username/password, and have it mounted (if they're authorized of course).
    At first I bought a NAS, thinking it would be really simple to set up. I used it with smb4k, which I like because it's intuitive. You can see all the shares, click, and connect to them.
    But the NAS didn't do exactly what I wanted, and was a nightmare to configure, having a limited web interface. It was especially limited about setting writing permissions to different users on a single share.
    And for every setting not present on the web interface, I had to set up scripts to change them again at every reboot, because the changes got lost at power down.

    So I built a bare-bone new system just for that purpose, spending time and money. I installed the latest Kubuntu on it, and set it up so that it doesn't start X at boot (after all it's not needed, it only has to serve files, and while I need X for configuring it, I prefer it to run as "lean" as possible during regular use).
    I set up ssh to be able to manage it remotely. And this all works well. The system is stable, and I can control it remotely from here.

    Before going on, I'm posting here the smb.conf of the server:

    Code:
    [global]
    encrypt passwords = true
    name resolve order = hosts wins bcast
    server string =
    socket options = SO_KEEPALIVE TCP_NODELAY IPTOS_LOWDELAY SO_SNDBUF=8192 SO_RCVBUF=8192
    announce version = 5.0
    syslog only = yes
    username map = /etc/samba/smbusers
    null passwords = yes
    printcap name = CUPS
    passdb backend = tdbsam
    wins support = yes
    read only = no
    restrict anonymous = no
    domain master = no
    preferred master = no
    max protocol = NT
    acl compatibility = winnt
    ldap ssl = No
    server signing = Auto
    security = share
    ; General server settings
    
    
    ; NOTE: Inside this place you may build a printer driver repository for
    ; Windows - I'll cover this topic in another HOWTO.
    [print$]
    path = /var/lib/samba/printers
    guest ok = yes
    write list = root
    create mask = 0664
    directory mask = 0775
    
    [printers]
    path = /tmp
    printable = yes
    guest ok = yes
    browseable = no
    
    [C_CRISTIAN]
    path = /data/C_Cristian/
    valid users = cristian
    admin users = cristian
    
    [S_SELENE]
    path = /data/S_Selene/
    admin users = selene
    valid users = selene
    
    [M_MUSICA]
    path = /data/M_Music/
    guest ok = yes
    comment = Tutta la musica
    valid users = cristian,selene,mp3
    admin users = cristian,selene,mp3
    and of the client:

    Code:
    #
    # Sample configuration file for the Samba suite for Debian GNU/Linux.
    
    [global]
    
    ## Browsing/Identification ###
    
     workgroup = WORKGROUP
     server string = %h server (Samba, Ubuntu)
     dns proxy = no
    
    #### Debugging/Accounting ####
    
    # This tells Samba to use a separate log file for each machine
    # that connects
     log file = /var/log/samba/log.%m
    
    # Cap the size of the individual log files (in KiB).
     max log size = 1000
    
    # We want Samba to log a minimum amount of information to syslog. Everything
    # should go to /var/log/samba/log.{smbd,nmbd} instead. If you want to log
    # through syslog you should set the following parameter to something higher.
     syslog = 0
    
    # Do something sensible when Samba crashes: mail the admin a backtrace
     panic action = /usr/share/samba/panic-action %d
    
    
    ####### Authentication #######
    
    # You may wish to use password encryption. See the section on
    # 'encrypt passwords' in the smb.conf(5) manpage before enabling.
     encrypt passwords = true
    
    # If you are using encrypted passwords, Samba will need to know what
    # password database type you are using.
     passdb backend = tdbsam
    
     obey pam restrictions = yes
    
    ; guest account = nobody
     invalid users = root
    
    # This boolean parameter controls whether Samba attempts to sync the Unix
    # password with the SMB password when the encrypted SMB password in the
    # passdb is changed.
     unix password sync = yes
    
    # For Unix password sync to work on a Debian GNU/Linux system, the following
    # parameters must be set (thanks to Ian Kahan <<kahan@informatik.tu-muenchen.de> for
    # sending the correct chat script for the passwd program in Debian Sarge).
     passwd program = /usr/bin/passwd %u
     passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
    
    # This boolean controls whether PAM will be used for password changes
    # when requested by an SMB client instead of the program listed in
    # 'passwd program'. The default is 'no'.
     pam password change = yes
    
    # This option controls how nsuccessful authentication attempts are mapped
    # to anonymous connections
    map to guest = bad user
    
    ############ Misc ############
    
    
    # Most people will find that this option gives better performance.
    # See smb.conf(5) and /usr/share/doc/samba-doc/htmldocs/Samba3-HOWTO/speed.html
    # for details
    # You may want to add the following on a Linux system:
    #    SO_RCVBUF=8192 SO_SNDBUF=8192
     socket options = TCP_NODELAY
    
    
    # Allow users who've been granted usershare privileges to create
    # public shares, not just authenticated ones
     usershare allow guests = yes
    
    #======================= Share Definitions =======================
    
    [printers]
     comment = All Printers
     browseable = no
     path = /var/spool/samba
     printable = yes
     guest ok = no
     read only = yes
     create mask = 0700
    
    # Windows clients look for this share name as a source of downloadable
    # printer drivers
    [print$]
     comment = Printer Drivers
     path = /var/lib/samba/printers
     browseable = yes
     read only = yes
     guest ok = no
    I have modified the folders on the server's HD so that they belong to the user who will have to use them:
    Code:
    drwxr-xr-x 2 cristian cristian 4096 2008-05-05 19:16 C_Cristian
    drwx------ 2 root  root  16384 2008-05-05 00:36 lost+found
    drwxr-xr-x 3 mp3   mp3   4096 2008-05-05 18:19 M_Music
    drwxr-xr-x 2 selene selene  4096 2008-05-05 17:56 S_Selene
    The users currently configured are cristian, selene and mp3. The shares are C_Cristian, belonging to cristian; S_Selene, belonging to selene; and M_Music, belonging to mp3 but "open" r/w to everyone.


    But configuring samba is a nightmare. I can't do what I need to. As it is now (and I'm close to just admitting defeat, and throwing everything out of the window and buying some web-space somewhere), I can open smb4k, see the server and all the shares.
    If I click on my private share, it asks for username and password (as expected) and accepts them. So it mounts the share. And this is the only share that "seems" to be OK.
    If I click on the private share of another user, it asks for usr and pwd, but doesn't accept them. It doesn't accept *any* usr and pwd, even those of the legitimate owner of the share.
    If I click on one of the "shared" shares - the one where several users must have access - it only accepts *my* usr and pwd, and not the others; but even then, after mounting it, I have no write access on it.

    Abandoning smb4k to experiment, if I run
    Code:
    sudo mount -t cifs //192.168.1.3/M_Music /home/cristian/mp3 -o user=mp3
    it asks for the password and gives this error:
    Code:
    mount error 13 = Permission denied
    Refer to the mount.cifs(8) manual page (e.g.man mount.cifs)
    I tried adding the domain name, both of the client
    Code:
    sudo mount -t cifs //192.168.1.3/M_Musica /home/cristian/smb4k/sel -o user=P4-Kubuntu804/mp3
    and of the server
    Code:
    sudo mount -t cifs //192.168.1.3/M_Musica /home/cristian/smb4k/sel -o user=server/mp3
    but nothing changes. Still the same error.



    I would like to try using smbfs instead of cifs, because I heard it's more stable (and because I was using it on Kubuntu 7.10), but in 8.04 smbfs seems to be just a "symlink" to cifs. I couldn't find a way to use (or install) smbfs, as it says it's already installed and current.

    Any help to sort the problem would be *very* welcome. I wonder if it's just plain difficult to set up samba, or if there's some problem with Kubuntu 8.04...

    Thanks in advance,
    Cristian (frustrated).

    #2
    Re: Very very frustrated. Setting up a file server with samba

    I completely understand your frustration. Been there. Done that. I still have issues with my XP >Samba>Linux connection but I did learn two critical things:

    (1) The username and password of your Samba user must = the username and password he uses to login to his XP machine upon booting. For example, let's say my XP username and password on my laptop is as follows:
    username = Luke
    password = Skywalker
    I've asked you if you will let me connect to your Linux machine and you are happy to do so. So, you ask me what my username and password is on my XP machine and I tell you "Luke" and "Skywalker". You take that information and set me up the exact same username and password as a new user on your Linux machine. You then have to explicitly tell Samba what password to use for me. Although you've specified me a system password for your machine, Samba does not know about it and requires one be setup. The password that you setup in Samba must be the same password that I use to login to my own laptop (Skywalker). That way, when I connect, Samba automatically reads my username and password as XP authenticates itself to Samba. Samba then allows the connection.

    Hopefully.
    Maybe.
    If your lucky.

    Read this article and notice how he setups the usernames and passwords. Hopefully this will help you.

    http://samba.netfirms.com/index.htm

    Mike


    sudo make me rich<br /><br />Kubuntu Gutsy 7.10<br />KDE 3.5<br />Compaq Presario 5000<br />Intel Celeron 1.2 Ghz<br />512 Ram, Riva TNT2 Video Card<br />All the above hardware is 7 year old junk but<br />Linux runs great on it.&nbsp; :&gt<br />Ham Radio Rules

    Comment


      #3
      Re: Very very frustrated. Setting up a file server with samba

      Hello Mike,
      Well, first of all, I haven't even tried using Windows yet. Right now I'm still having problems connecting my Kubuntu desktop with the Kubuntu server. One would think that should be trivial, but it's not...

      The user names I set up on the server are exactly the same than the user names I have on the clients. With the same passwords.
      And I need to be able to log onto the server with different user names - say, if I'm using my sister's PC and I need to access one of my files on the server, I must be able to log in with my user name. Because I want my personal folder to be accessible only by me.

      I tried installing, on the server machine, "FreeNAS" - but it won't allow the creation of shares.
      I've tried OpenFiler - but it's a mess to configure, I couldn't get past the Admin configuration screen, it wouldn't accept any users/groups.

      I really don't know what to do. I just want a small, simple file server with 4-5 folders accessible by 4-5 users across the network. Why must it be so frustrating? I've tried to set something up for months now...

      I'm reading the link you gave me. I hope that can shed some light. But somehow I'm loosing hope. Maybe I should just buy a few external USB hard drives, and lug those around, syncing them manually... Not very elegant eh? ...

      Cristian

      Comment


        #4
        Re: Very very frustrated. Setting up a file server with samba

        Cristian,

        Samba is used to allow Windows-to-Linux communication not Linux-to-Linux. Well, at least I don't think you can use it Linux-to-Linux. Please, someone correct me if I am wrong. I do not have another Linux computer in a desktop/laptop sense but I do have an Hewlett-Packard Media Vault (NAS) which runs on Linux. I connect to it using NFS and have no problem mounting the files shares. I can set folder permissions with either Kubuntu or via the Media Vaults internal software.

        Here is a line from my /etc/fstab file that tells my Linux machine how to communicate / mount the NAS:

        hpmediavault:/shares/Volume1/FileShare /mnt/mediavault/FileShare nfs defaults 0 0
        Also, if you are not using NetBios recognition (not on by default) then you can use the NAS's IP address instead:

        192.168.2.102:/shares/Volume1/FileShare /mnt/mediavault/FileShare nfs defaults 0 0
        Here, "FileShare" is a directory on the Media Vault. NFS is used for the connection. In retrospect, I think I had the option to use Samba - wait, now I remember ---(old age kicking in here) ---I did try to use Samba first but it would never connect so I used NFS and it connected just fine. It most likely has to do with the fact that I am a Linux Noob and do not understand all that there is to know BUT I do know that NFS works for me.

        Have you tried NFS?
        sudo make me rich<br /><br />Kubuntu Gutsy 7.10<br />KDE 3.5<br />Compaq Presario 5000<br />Intel Celeron 1.2 Ghz<br />512 Ram, Riva TNT2 Video Card<br />All the above hardware is 7 year old junk but<br />Linux runs great on it.&nbsp; :&gt<br />Ham Radio Rules

        Comment


          #5
          Re: Very very frustrated. Setting up a file server with samba

          Also, the directories you mounting in Windows must not have spaces in the names. For example, your My Documents folder has a space in it and can not be mounted without using a special octal code in the space between "y D" which fills in that space. The easier route is to just rename the share "My_Documents".

          Likewise, the mount location on the Linux client must not have a space in its name either.

          AND....there should be only one Window share mounted to a directory on the Linux machine. No more than one. Just one. If you have more shares to mount then mount them to other directories on your Linux machine which you must create BEFORE mounting.
          sudo make me rich<br /><br />Kubuntu Gutsy 7.10<br />KDE 3.5<br />Compaq Presario 5000<br />Intel Celeron 1.2 Ghz<br />512 Ram, Riva TNT2 Video Card<br />All the above hardware is 7 year old junk but<br />Linux runs great on it.&nbsp; :&gt<br />Ham Radio Rules

          Comment


            #6
            Re: Very very frustrated. Setting up a file server with samba

            Well, Samba is supposed to work even Linux-Linux. I chose to use it because I need a graphical share browser (not all users in my home network want, or are able to, use the shell) and Smb4K was great. I couldn't find a graphical NFS share browser.

            I don't want to add the shares to the /etc/fstab because I want them to be only mounted "on demand". If in a given session the user doesn't plan to use the share, I prefer it to not be mounted, and leave the server sleep peacefully.

            Also, I want that when an user requests to mount a share, the server should ask for username and password, and only grant access if they match with that I programmed into it. Can this be done with NFS? For example, I want to be able to access to my own private files while using another computer. So it should ask for user/pwd when I try to connect. And conversely, I don't want that anyone using my computer can access my private files on the share without giving my password. This was all nicely handled by Smb4k...

            About the directory names: I know, there are no spaces in the paths of the shares that I configured (as you can see in the smb.conf file). And they were mounted either one at a time, or anyway into different folders, which were already existing (Smb4K takes care of this, too).

            Tomorrow I will make some experiments...

            Thanks,
            Cristian

            Comment


              #7
              Re: Very very frustrated. Setting up a file server with samba

              Ok...maybe I was confused.

              You have SSH installed. Have you looked at MySecureShell? It works with SSH vis SFTP and can lock a user to a certain folder on the server (CHROOTED). Your users could access it with several programs that support sftp but my favorite is FileZilla which works on both WinXP and Linux.

              It will basically be an SFTP server / client relationship. Might work great for you.

              Mike

              sudo make me rich<br /><br />Kubuntu Gutsy 7.10<br />KDE 3.5<br />Compaq Presario 5000<br />Intel Celeron 1.2 Ghz<br />512 Ram, Riva TNT2 Video Card<br />All the above hardware is 7 year old junk but<br />Linux runs great on it.&nbsp; :&gt<br />Ham Radio Rules

              Comment


                #8
                Re: Very very frustrated. Setting up a file server with samba

                Well, Samba is supposed to work even Linux-Linux.
                Yep, it works nicely (except that I can't get the Samba server to work in Hardy...), I use it because I have a mixed environment and don't want the trouble of using different protocols/setups for different machines.

                Comment


                  #9
                  Re: Very very frustrated. Setting up a file server with samba

                  Originally posted by Quaxo76

                  I tried installing, on the server machine, "FreeNAS" - but it won't allow the creation of shares.

                  Cristian
                  I have a 3terabyte FreeNas server that I use with smb/cifs shares. I can connect to it without doing anything special in Kubuntu, Ubuntu, and Windows. I have it behind a firewall and do not require a login to access it with smb/cifs. I let all users access all files on it, I gather you are looking to restrict users from seeing others folders/files. I have not tried that.

                  Perhaps what you are looking for is an OpenLDAP system.

                  Comment


                    #10
                    Re: Very very frustrated. Setting up a file server with samba

                    I gather you are looking to restrict users from seeing others folders/files.
                    Actually, I want to have a single partition on the HD, that is divided in different folders, and every folder is a share. It will not allow that. Every partition is a share on Freenas. I could re-partition the HD, but then the sizes would be fixed - which could lead to waste of space if one or more shares are only used for a few files.
                    I've read on the site that this feature will be included in one of the next versions...

                    Right now, I'm experimenting with Kubuntu again, with a "minimalist" smb.conf. I'm trying to put in only the lines I know exactly what they do. I'll post the results...

                    Cristian

                    Comment


                      #11
                      Re: Very very frustrated. Setting up a file server with samba

                      OK. Things are looking better. Now the user authorizations are more or less what I want them to be.
                      Now there are 2 weird things:

                      1) When I write *to* the server from my laptop (Kubuntu 8.04) and from my sister's PC (Kubuntu 7.10) I get write speeds of about 5-6 MB/Second (acceptable, as I'm on 100MBit/sec). But when I try to write to the server from my desktop (Kubuntu 8.04) I get 800KB/sec. Way too slow. I couldn't find any differences between my pc and the others. What could be the reason?

                      2) This is weird. If I want to copy an entire folder to the share on the desktop, by dragging it from one Konqueror window to another (or even by the konsole "cp" command) I get an error ("Permission denied"), but the folder (empty) is created. If then I give the command again, then the files are created without problems. Looks like the "create new folder" command takes some time to be executed; and the client tries to push the files before the folder has actually been created, thus failing. This is a big problem as it's difficult to manage file moves this way. How could I fix that?

                      Edit: From the "slow" computer, the "permission denied" problem doesn't occur. As if, being slower, the server has the time to create the folder. Could that be? And how can I fix that? Could it be a problem that the server has a slow CPU (300 MHz)? I would think that if it takes a longer time, the client should just wait for it to finish...

                      Thanks
                      Cristian

                      Comment


                        #12
                        Re: Very very frustrated. Setting up a file server with samba

                        Update: "Permission denied" problem solved. I had to manually clear the "Do Permission Checks" and "Do not use Locking" checkboxes in the Smb4k configuration's CIFS options.
                        Now I "only" have to figure out why the transfer is so slow with one pc, and fast with the others...

                        Cristian

                        Comment


                          #13
                          [Almost SOLVED] Very very frustrated. Setting up a file server with samba

                          Further update...

                          Following some more research on Internet, I found that other users who had slow samba performance, found out it was a bad kernel module for their realtek LAN card. And it turns out I had a Realtek card (RTL8139).
                          That card has always worked flawlessly (and fast) with every other application, but it seems that it's not well compatible with Samba.
                          So I put in a very old 3com 10/100 card, rebooted, configured it and - wonder - I get almost 8MB/s. Weeks wasted for nothing... Luckily today I had to use my sister's PC, and I noticed the transfer was fast from there!
                          Oh well. At least I learned a lot about Samba.

                          Now I have only one gripe left... I wanted one share that was writable by several users. I can't get that. Only one user can write on a share, and that user must be put in the "write list" in smb.conf for that share; AND that user must own the actual share folder on the server. If I log onto that share with another user name, who doesn't own the folder, even if that user is on the write list for that share, he can't write there. But I might open a new thread for this!
                          I'm changing the title to "Almost solved"...

                          Cristian

                          Comment


                            #14
                            Re: [Almost SOLVED] Very very frustrated. Setting up a file server with samba

                            You've managed to get it working now? Could you please post your smb.conf, maybe I could work out why Samba stopped working for me when I upgraded to Hardy?

                            Comment


                              #15
                              Re: [Almost SOLVED] Very very frustrated. Setting up a file server with samba

                              Here's the smb.conf:

                              Code:
                              [global]
                              encrypt passwords = yes
                              workgroup = WORKGROUP
                              netbios name = server
                              socket options = SO_KEEPALIVE TCP_NODELAY IPTOS_LOWDELAY SO_SNDBUF=8192 SO_RCVBUF=8192
                              security = share
                              
                              [homes]
                              read only = no
                              browseable = no
                              
                              [Cristian]
                              path = /data/Cristian/
                              browsable = yes
                              read only = no
                              comment = My data
                              valid users = cristian
                              write list = cristian
                              
                              [Selene]
                              path = /data/Selene/
                              browsable = yes
                              read only = no
                              comment = Selene's stuff
                              valid users = selene
                              write list = selene
                              
                              [Music]
                              path = /data/Music/
                              read only = no
                              browsable = yes
                              comment = MP3 music
                              valid users = cristian, selene, mp3
                              write list = cristian, selene, mp3
                              It's very basic, I rewrote it from scratch, without all the fancy options.
                              Now transfers are fast. Very fast compared to what I experienced before (6-7 MB/s vs 0.8 MB/s). But remember that the real problem was the network card - I had to change it to get decent speeds. There's a problem with the Realtek driver module.
                              I still have the problem (with the "Music" share) that only the user who actually owns the folder on the server is allowed to write on it, despite all users being in the write list.

                              Cristian

                              Comment

                              Working...
                              X