Announcement

Collapse
No announcement yet.

AutoMounting Multiple Shared Drives using Fstab and smbcredentials

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

    AutoMounting Multiple Shared Drives using Fstab and smbcredentials

    This one should be easy: when you want to mount multiple shares automatically at startup using Fstab and .smbcredentials, is there a way to use only one .smbcredentials file and put the passwords for each share in there? Or is it really necessary to do the inelegant way that I have: just create a second file called ".smbcredentials2"? Thanks.

    Here are the general instructions from the Ubuntu wiki for automounting (NOTE: for other newbies out there, mounting is necessary to view certain files directly from the share (e.g., VLC) on Kubuntu):

    The quickest way to auto-mounting a password-protected share is to edit /etc/fstab (with root privileges), to add this line:

    Code:
    //servername/sharename  /media/windowsshare  cifs  username=msusername,password=mspassword,iocharset=utf8,sec=ntlm  0  0
    This is not a good idea however: /etc/fstab is readable by everyone and so is your Windows password in it. The way around this is to use a credentials file. This is a file that contains just the username and password.

    Using a text editor, create a file for your remote servers logon credential:

    Code:
    gedit ~/.smbcredentials
    Enter your Windows username and password in the file:

    Code:
    username=msusername
    password=mspassword
    Save the file, exit the editor.

    Change the permissions of the file to prevent unwanted access to your credentials:

    Code:
    chmod 600 ~/.smbcredentials
    Then edit your /etc/fstab file (with root privileges) to add this line (replacing the insecure line in the example above, if you added it):

    Code:
    //servername/sharename /media/windowsshare cifs credentials=/home/ubuntuusername/.smbcredentials,iocharset=utf8,sec=ntlm 0 0
    Save the file, exit the editor.

    Finally, test the fstab entry by issuing:

    Code:
    sudo mount -a
    If there are no errors, you should test how it works after a reboot. Your remote share should mount automatically.
    Last edited by Snowhog; Dec 29, 2013, 11:38 AM.

    #2
    Nothing in man mount.cifs implies that the credentials file can be made aware of different credentials for different mounts. So you'll need a separate file for each mount that requires unique credentials.

    Comment


      #3
      (NOTE: for other newbies out there, mounting is necessary to view certain files directly from the share (e.g., VLC) on Kubuntu):
      Did you add smb as a file protocol under vlc.desktop?

      Please Read Me

      Comment


        #4
        I dont remember doing that. I did set the "Access Module" under VLC advanced settings>Input/Codec>Access Modules, to "SMB Input."

        UPDATE:
        I looked at /usr/share/applications/vlc.desktop and it had this:
        Code:
        X-KDE-Protocols=ftp,http,https,mms,rtmp,rtsp,sftp,smb
        Keywords=Player;Capture;DVD;Audio;Video;Server;Broadcast;
        So I think the answer to your question is actually, yes, I did. That didn't work. I still have to mount the share.
        Last edited by mbwd1; Jan 04, 2014, 02:38 PM.

        Comment


          #5
          Hmm, I can stream from samba here by browsing to a file via dolphin and right-clicking and selecting VLC.

          Please Read Me

          Comment


            #6
            Nice. Wonder what we have set differently? My "share" is a USB stick on a router running Tomato. If I try to run it directly from Dolphin by typing in the share name (here smb://10.0.1.2/video), I get this error:

            Code:
            Your input can't be opened:
            VLC is unable to open the MRL 'smb://10.0.1.2/video/Movies/Test.mkv'. Check the log for details.
            Notably, this happens even if the share is mounted -- if I go through Dolphin and type in the smb at the top. However, if I go to the mount point on the devices list and right click and select VLC, it works fine (as long as it is mounted).

            Comment


              #7
              I had to set up a DNLA server (Mediatomb) to get my server to stream content. Otherwise, yes, you have to mount samba to use samba. I don't have any issues accessing shares via VLC, nor do I have issues viewing via UPnP.

              Unless both shares use the exact same username and password, you'll have to create a different credentials file. You don't have to name them .smbcredentials, you can name them anything you want, ie: .sharescreds and .homescreds (an example using my Shares and Homes shares) or .creds1 and .creds2. We use the dot at the beginning of the filename to hide the file, and give it permissions of 600 so if the bad guys can actually find the file, they'll have to really work to open the file.
              I do not personally use Kubuntu, but I'm the tech support for my daughter who does.

              Comment


                #8
                Thanks. I did add a third share with an identical password. I can confirm that for exact password/username combos, you can use the same .NAME file.

                Comment


                  #9
                  Originally posted by oshunluvr View Post
                  Hmm, I can stream from samba here by browsing to a file via dolphin and right-clicking and selecting VLC.
                  Dolphin auto-mounts as required.

                  Regards, John Little
                  Regards, John Little

                  Comment


                    #10
                    Is there a way to automount with a credentials file and have read-write access? I have tried using this in /etc/fstab:

                    Code:
                    //10.0.1.2/VIDEO /mnt/VIDEO cifs credentials=/home/.smbcredentials auto users,noatime,umask=0 0 0
                    and

                    Code:
                    //10.0.1.2/VIDEO /mnt/VIDEO cifs credentials=/home/.smbcredentials user,uid=1000,gid=100,dmask=027,fmask=137 0 0
                    but it does not give me rw access -- only root has that (as confirmed by mounting using sudo and also properties in Dolphin).

                    Comment


                      #11
                      It's on the server in your smb.conf

                      /etc/samba/smb.conf:

                      Code:
                      #####===== Share Definitions =====#####
                      [Homes]
                         comment = Home Directories
                         browseable = no
                         [B]read only = no[/B]
                         create mask = 0700
                         directory mask = 0700
                         valid users = %S
                      
                      [Shares]
                          path = /home/share
                          browseable = yes
                          [B]read only = no[/B]
                          guest ok = yes
                          create mask = 0755
                          directory mask = 0755
                          force user = nobody
                          force group = nogroup
                      A good site for how to set up your smb.conf is https://calomel.org/samba.html
                      The site is starting to get dated, but if your server is still samba3, then this site still has very good info
                      I do not personally use Kubuntu, but I'm the tech support for my daughter who does.

                      Comment


                        #12
                        Originally posted by jlittle View Post
                        Dolphin auto-mounts as required.

                        Regards, John Little
                        This does not explain the difference in my experience from mbwd1.

                        Please Read Me

                        Comment


                          #13
                          Thanks for the suggestion to edit the samba file. Unfortunately, it did not work. I reviewed your link too, good stuff -- but it did not point to a solution.

                          I am curious if the problem has to do with the fact that my share is mounted at /mnt. Here is the ls -la output, showing it is owned by root:

                          Code:
                          mbwd1@mbwd1-Q501LA:~$ ls -la /mnt/VIDEO
                          total 6148
                          drwxr-xr-x  6 root root      0 Jan  5 09:45 .
                          drwxr-xr-x  7 root root   4096 Jan  4 12:50 ..
                          .........
                          As I mentioned before, if I run Dolphin as root, I can read/write the share VIDEO. This leads me to question whether I should be mounting VIDEO in my home directory? That would make some logical sense, but then what would /mnt and /media be used for -- and would they ever be rw by users?

                          I apologize, as this is likely a newbie query based on a lack of understanding of the file structure and permissions, but it seems that /mnt and /media are for mount points and media, and so should be configurable to be rw for users.

                          Comment


                            #14
                            Hmmm.... On the server, my Shares is owned by 'nobody/nogroup', but my mount point (/mnt/Shares) is owned by pat/nogroup. The Homes share is owned by the users/users, mine being pat/pat.
                            I do not personally use Kubuntu, but I'm the tech support for my daughter who does.

                            Comment


                              #15
                              So maybe I should create a "Shares" folder inside /mnt, point all of my samba shares there, and then change ownership of that folder? Is that how its supposed to work? Or is it appropriate/acceptable to change the ownership of /mnt?

                              Comment

                              Working...
                              X