Mount remote home directoriesHow do I add an entry in /etc/fstab for a windows share?Issues accessing CIFS...

If I wouldn't want to read the story, is writing it still a good idea?

Can Ogre clerics use Purify Food and Drink on humanoid characters?

What is the origin of Scooby-Doo's name?

Has there been any indication at all that further negotiation between the UK and EU is possible?

expiry or manufactured date?

Can we put equal sign after aggregate functions in sql?

Tantum religio potuit suadere malorum – Lucretius

How can I politely work my way around not liking coffee or beer when it comes to professional networking?

How does Powershell create fake drive labels in Windows?

What was the Shuttle Carrier Aircraft escape tunnel?

Find the C-factor of a vote

Should my manager be aware of private LinkedIn approaches I receive? How to politely have this happen?

Can the negators "jamais, rien, personne, plus, ni, aucun" be used in a single sentence?

What's currently blocking the construction of the wall between Mexico and the US?

What is the mechanical difference between the Spectator's Create Food and Water action and the Banshee's Undead Nature Trait?

The Target Principal Name Is Incorrect. Cannot Generate SSPI Context (SQL or AD Issue)?

Wifi dongle speed is slower than advertised

Why aren't cotton tents more popular?

Why do some professors with PhDs leave their professorships to teach high school?

How does metta sutra develop loving kindness

How long would it take to cross the Channel in 1890's?

What reason would an alien civilization have for building a Dyson Sphere (or Swarm) if cheap Nuclear fusion is available?

Is it damaging to turn off a small fridge for two days every week?

Did Karl Marx ever use any example that involved cotton and dollars to illustrate the way capital and surplus value were generated?



Mount remote home directories


How do I add an entry in /etc/fstab for a windows share?Issues accessing CIFS share directoriesRaspberry Pi mount Samba Network ShareMounting ExFAT on LinuxHow to prevent: `CIFS: Unknown mount option “defaults”`?Samba External SSD Share windows but cannot write to SSD from windows 10Mouting a remote drive with cifsAutoFS for mouting Samba share with Kerberos TicketAlternative to autofs to mount CIFS folders in user home folders in multi-user environmentSamba credentials changing when attempting to mount






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I have a SAMBA/CIFS server where the users have their own directories. My client machines run Linux or Windows. What I am trying to do is to use that share in both OSes. But my users can login in any computer, and here is my problem: In Linux, I need to change the /etc/fstab and include something like this:



//sambaserver/username /mnt/samba smbfs username=<username>,password=<pass> 0 0  


My problem is I can't set the username and password statically, but I need it dynamic (I am not sure that is the proper term). So, trying to put it shortly: when some user logs in to the system I have to mount the share as its home directory, but having in mind that this user can login in other computer, so the /etc/fstab must 'catch' the username and password.

I hope my question is clear. Thanks in advance.










share|improve this question
















bumped to the homepage by Community 29 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • /mnt/samba is a single location and you are using a shared environment so that's not really going to work for you (you could easily have multiple users on at once). But you might have better luck with something from their home directory instead. You can't know the user's password on sambaserver but you can create a credentials file in each user's home directory. Then drop a call to smbmount in their .profile with "-o credentials=<0600 file owned by them in their homedir>". If that's something that could work for you, I can write up something a little more clear.

    – Smiling Dragon
    Jun 9 '15 at 3:54











  • Thanks for the reply @SmilingDragon! I create the shares, so, as administrator, I know the users passwords. The location /mnt/samba was an example. Can you explain me your solution in deep? Maybe it could work better than mine.

    – verovan
    Jun 9 '15 at 19:00













  • Ok @verovan, I've made a proper answer detailing how I'd approach this, with some tweaks to make it a bit more future proof (allows user's to manage their own passwords if they change them etc)

    – Smiling Dragon
    Jun 9 '15 at 21:19


















0















I have a SAMBA/CIFS server where the users have their own directories. My client machines run Linux or Windows. What I am trying to do is to use that share in both OSes. But my users can login in any computer, and here is my problem: In Linux, I need to change the /etc/fstab and include something like this:



//sambaserver/username /mnt/samba smbfs username=<username>,password=<pass> 0 0  


My problem is I can't set the username and password statically, but I need it dynamic (I am not sure that is the proper term). So, trying to put it shortly: when some user logs in to the system I have to mount the share as its home directory, but having in mind that this user can login in other computer, so the /etc/fstab must 'catch' the username and password.

I hope my question is clear. Thanks in advance.










share|improve this question
















bumped to the homepage by Community 29 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
















  • /mnt/samba is a single location and you are using a shared environment so that's not really going to work for you (you could easily have multiple users on at once). But you might have better luck with something from their home directory instead. You can't know the user's password on sambaserver but you can create a credentials file in each user's home directory. Then drop a call to smbmount in their .profile with "-o credentials=<0600 file owned by them in their homedir>". If that's something that could work for you, I can write up something a little more clear.

    – Smiling Dragon
    Jun 9 '15 at 3:54











  • Thanks for the reply @SmilingDragon! I create the shares, so, as administrator, I know the users passwords. The location /mnt/samba was an example. Can you explain me your solution in deep? Maybe it could work better than mine.

    – verovan
    Jun 9 '15 at 19:00













  • Ok @verovan, I've made a proper answer detailing how I'd approach this, with some tweaks to make it a bit more future proof (allows user's to manage their own passwords if they change them etc)

    – Smiling Dragon
    Jun 9 '15 at 21:19














0












0








0








I have a SAMBA/CIFS server where the users have their own directories. My client machines run Linux or Windows. What I am trying to do is to use that share in both OSes. But my users can login in any computer, and here is my problem: In Linux, I need to change the /etc/fstab and include something like this:



//sambaserver/username /mnt/samba smbfs username=<username>,password=<pass> 0 0  


My problem is I can't set the username and password statically, but I need it dynamic (I am not sure that is the proper term). So, trying to put it shortly: when some user logs in to the system I have to mount the share as its home directory, but having in mind that this user can login in other computer, so the /etc/fstab must 'catch' the username and password.

I hope my question is clear. Thanks in advance.










share|improve this question
















I have a SAMBA/CIFS server where the users have their own directories. My client machines run Linux or Windows. What I am trying to do is to use that share in both OSes. But my users can login in any computer, and here is my problem: In Linux, I need to change the /etc/fstab and include something like this:



//sambaserver/username /mnt/samba smbfs username=<username>,password=<pass> 0 0  


My problem is I can't set the username and password statically, but I need it dynamic (I am not sure that is the proper term). So, trying to put it shortly: when some user logs in to the system I have to mount the share as its home directory, but having in mind that this user can login in other computer, so the /etc/fstab must 'catch' the username and password.

I hope my question is clear. Thanks in advance.







fstab automounting






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jun 8 '15 at 21:49









Digital Trauma

6,2321 gold badge17 silver badges30 bronze badges




6,2321 gold badge17 silver badges30 bronze badges










asked Jun 8 '15 at 21:42









verovanverovan

367 bronze badges




367 bronze badges





bumped to the homepage by Community 29 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 29 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.















  • /mnt/samba is a single location and you are using a shared environment so that's not really going to work for you (you could easily have multiple users on at once). But you might have better luck with something from their home directory instead. You can't know the user's password on sambaserver but you can create a credentials file in each user's home directory. Then drop a call to smbmount in their .profile with "-o credentials=<0600 file owned by them in their homedir>". If that's something that could work for you, I can write up something a little more clear.

    – Smiling Dragon
    Jun 9 '15 at 3:54











  • Thanks for the reply @SmilingDragon! I create the shares, so, as administrator, I know the users passwords. The location /mnt/samba was an example. Can you explain me your solution in deep? Maybe it could work better than mine.

    – verovan
    Jun 9 '15 at 19:00













  • Ok @verovan, I've made a proper answer detailing how I'd approach this, with some tweaks to make it a bit more future proof (allows user's to manage their own passwords if they change them etc)

    – Smiling Dragon
    Jun 9 '15 at 21:19



















  • /mnt/samba is a single location and you are using a shared environment so that's not really going to work for you (you could easily have multiple users on at once). But you might have better luck with something from their home directory instead. You can't know the user's password on sambaserver but you can create a credentials file in each user's home directory. Then drop a call to smbmount in their .profile with "-o credentials=<0600 file owned by them in their homedir>". If that's something that could work for you, I can write up something a little more clear.

    – Smiling Dragon
    Jun 9 '15 at 3:54











  • Thanks for the reply @SmilingDragon! I create the shares, so, as administrator, I know the users passwords. The location /mnt/samba was an example. Can you explain me your solution in deep? Maybe it could work better than mine.

    – verovan
    Jun 9 '15 at 19:00













  • Ok @verovan, I've made a proper answer detailing how I'd approach this, with some tweaks to make it a bit more future proof (allows user's to manage their own passwords if they change them etc)

    – Smiling Dragon
    Jun 9 '15 at 21:19

















/mnt/samba is a single location and you are using a shared environment so that's not really going to work for you (you could easily have multiple users on at once). But you might have better luck with something from their home directory instead. You can't know the user's password on sambaserver but you can create a credentials file in each user's home directory. Then drop a call to smbmount in their .profile with "-o credentials=<0600 file owned by them in their homedir>". If that's something that could work for you, I can write up something a little more clear.

– Smiling Dragon
Jun 9 '15 at 3:54





/mnt/samba is a single location and you are using a shared environment so that's not really going to work for you (you could easily have multiple users on at once). But you might have better luck with something from their home directory instead. You can't know the user's password on sambaserver but you can create a credentials file in each user's home directory. Then drop a call to smbmount in their .profile with "-o credentials=<0600 file owned by them in their homedir>". If that's something that could work for you, I can write up something a little more clear.

– Smiling Dragon
Jun 9 '15 at 3:54













Thanks for the reply @SmilingDragon! I create the shares, so, as administrator, I know the users passwords. The location /mnt/samba was an example. Can you explain me your solution in deep? Maybe it could work better than mine.

– verovan
Jun 9 '15 at 19:00







Thanks for the reply @SmilingDragon! I create the shares, so, as administrator, I know the users passwords. The location /mnt/samba was an example. Can you explain me your solution in deep? Maybe it could work better than mine.

– verovan
Jun 9 '15 at 19:00















Ok @verovan, I've made a proper answer detailing how I'd approach this, with some tweaks to make it a bit more future proof (allows user's to manage their own passwords if they change them etc)

– Smiling Dragon
Jun 9 '15 at 21:19





Ok @verovan, I've made a proper answer detailing how I'd approach this, with some tweaks to make it a bit more future proof (allows user's to manage their own passwords if they change them etc)

– Smiling Dragon
Jun 9 '15 at 21:19










1 Answer
1






active

oldest

votes


















0














Rather than try to mount samba shares for the logged in user in a single reusable location (which will cause issues if you have more than one user logged in), consider mounting into a location unique to each user (eg /home/<username>/sambaserver, or /mnt/samba/<username> in a pinch)



If you are working with Linux, smbmount is a simple user-space samba mounter that should do what you need.



Create a little script a bit like this:



#!/bin/sh
# Default samba server to connect to
SAMBASERVER="sambaserver"
USERNAME="$USER"

if [ -n "$1" ]
then
# We've been given a different samba server
SAMBASERVER="$1"
fi

if [ -n "$2" ]
then
# We've been given a different user on the samba server to use
USERNAME="$2"
fi

CREDSFILE="${HOME}/.${SAMBASERVER}.credentials"

# Try and make the mount point if it doesn't yet exist (and set suitable mount dir perms)
if [ ! -d "${HOME}/${SAMBASERVER}" ]
then
mkdir "${HOME}/${SAMBASERVER}" && chmod 0555 "${HOME}/${SAMBASERVER}" || exit 1
fi

if [ ! -f "$CREDSFILE" ]
then
echo "$CREDSFILE not found!"
exit 1
fi

smbmount "\${SAMBASERVER}${USERNAME}" "${HOME}/${SAMBASERVER}" -o user="$USERNAME",credentials="$CREDSFILE" || exit 1


(Untested - you may need to tweak/debug/etc)



Then create a credentials file in each user's home directory called (for example) .sambaserver.credentials and set it's permissions to 0600, owned by that user:



username=<samba user>
password=<samba password>


Lastly, put a call to your above mount script in their .profile.
eg: /usr/local/bin/mount-user-home.sh or /usr/local/bin/mount-user-home.sh sambaserver somedifferentusername for special cases.



This should work with multiple samba servers, multiple users & multiple users with multiple samba servers.






share|improve this answer


























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "106"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f208348%2fmount-remote-home-directories%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Rather than try to mount samba shares for the logged in user in a single reusable location (which will cause issues if you have more than one user logged in), consider mounting into a location unique to each user (eg /home/<username>/sambaserver, or /mnt/samba/<username> in a pinch)



    If you are working with Linux, smbmount is a simple user-space samba mounter that should do what you need.



    Create a little script a bit like this:



    #!/bin/sh
    # Default samba server to connect to
    SAMBASERVER="sambaserver"
    USERNAME="$USER"

    if [ -n "$1" ]
    then
    # We've been given a different samba server
    SAMBASERVER="$1"
    fi

    if [ -n "$2" ]
    then
    # We've been given a different user on the samba server to use
    USERNAME="$2"
    fi

    CREDSFILE="${HOME}/.${SAMBASERVER}.credentials"

    # Try and make the mount point if it doesn't yet exist (and set suitable mount dir perms)
    if [ ! -d "${HOME}/${SAMBASERVER}" ]
    then
    mkdir "${HOME}/${SAMBASERVER}" && chmod 0555 "${HOME}/${SAMBASERVER}" || exit 1
    fi

    if [ ! -f "$CREDSFILE" ]
    then
    echo "$CREDSFILE not found!"
    exit 1
    fi

    smbmount "\${SAMBASERVER}${USERNAME}" "${HOME}/${SAMBASERVER}" -o user="$USERNAME",credentials="$CREDSFILE" || exit 1


    (Untested - you may need to tweak/debug/etc)



    Then create a credentials file in each user's home directory called (for example) .sambaserver.credentials and set it's permissions to 0600, owned by that user:



    username=<samba user>
    password=<samba password>


    Lastly, put a call to your above mount script in their .profile.
    eg: /usr/local/bin/mount-user-home.sh or /usr/local/bin/mount-user-home.sh sambaserver somedifferentusername for special cases.



    This should work with multiple samba servers, multiple users & multiple users with multiple samba servers.






    share|improve this answer




























      0














      Rather than try to mount samba shares for the logged in user in a single reusable location (which will cause issues if you have more than one user logged in), consider mounting into a location unique to each user (eg /home/<username>/sambaserver, or /mnt/samba/<username> in a pinch)



      If you are working with Linux, smbmount is a simple user-space samba mounter that should do what you need.



      Create a little script a bit like this:



      #!/bin/sh
      # Default samba server to connect to
      SAMBASERVER="sambaserver"
      USERNAME="$USER"

      if [ -n "$1" ]
      then
      # We've been given a different samba server
      SAMBASERVER="$1"
      fi

      if [ -n "$2" ]
      then
      # We've been given a different user on the samba server to use
      USERNAME="$2"
      fi

      CREDSFILE="${HOME}/.${SAMBASERVER}.credentials"

      # Try and make the mount point if it doesn't yet exist (and set suitable mount dir perms)
      if [ ! -d "${HOME}/${SAMBASERVER}" ]
      then
      mkdir "${HOME}/${SAMBASERVER}" && chmod 0555 "${HOME}/${SAMBASERVER}" || exit 1
      fi

      if [ ! -f "$CREDSFILE" ]
      then
      echo "$CREDSFILE not found!"
      exit 1
      fi

      smbmount "\${SAMBASERVER}${USERNAME}" "${HOME}/${SAMBASERVER}" -o user="$USERNAME",credentials="$CREDSFILE" || exit 1


      (Untested - you may need to tweak/debug/etc)



      Then create a credentials file in each user's home directory called (for example) .sambaserver.credentials and set it's permissions to 0600, owned by that user:



      username=<samba user>
      password=<samba password>


      Lastly, put a call to your above mount script in their .profile.
      eg: /usr/local/bin/mount-user-home.sh or /usr/local/bin/mount-user-home.sh sambaserver somedifferentusername for special cases.



      This should work with multiple samba servers, multiple users & multiple users with multiple samba servers.






      share|improve this answer


























        0












        0








        0







        Rather than try to mount samba shares for the logged in user in a single reusable location (which will cause issues if you have more than one user logged in), consider mounting into a location unique to each user (eg /home/<username>/sambaserver, or /mnt/samba/<username> in a pinch)



        If you are working with Linux, smbmount is a simple user-space samba mounter that should do what you need.



        Create a little script a bit like this:



        #!/bin/sh
        # Default samba server to connect to
        SAMBASERVER="sambaserver"
        USERNAME="$USER"

        if [ -n "$1" ]
        then
        # We've been given a different samba server
        SAMBASERVER="$1"
        fi

        if [ -n "$2" ]
        then
        # We've been given a different user on the samba server to use
        USERNAME="$2"
        fi

        CREDSFILE="${HOME}/.${SAMBASERVER}.credentials"

        # Try and make the mount point if it doesn't yet exist (and set suitable mount dir perms)
        if [ ! -d "${HOME}/${SAMBASERVER}" ]
        then
        mkdir "${HOME}/${SAMBASERVER}" && chmod 0555 "${HOME}/${SAMBASERVER}" || exit 1
        fi

        if [ ! -f "$CREDSFILE" ]
        then
        echo "$CREDSFILE not found!"
        exit 1
        fi

        smbmount "\${SAMBASERVER}${USERNAME}" "${HOME}/${SAMBASERVER}" -o user="$USERNAME",credentials="$CREDSFILE" || exit 1


        (Untested - you may need to tweak/debug/etc)



        Then create a credentials file in each user's home directory called (for example) .sambaserver.credentials and set it's permissions to 0600, owned by that user:



        username=<samba user>
        password=<samba password>


        Lastly, put a call to your above mount script in their .profile.
        eg: /usr/local/bin/mount-user-home.sh or /usr/local/bin/mount-user-home.sh sambaserver somedifferentusername for special cases.



        This should work with multiple samba servers, multiple users & multiple users with multiple samba servers.






        share|improve this answer













        Rather than try to mount samba shares for the logged in user in a single reusable location (which will cause issues if you have more than one user logged in), consider mounting into a location unique to each user (eg /home/<username>/sambaserver, or /mnt/samba/<username> in a pinch)



        If you are working with Linux, smbmount is a simple user-space samba mounter that should do what you need.



        Create a little script a bit like this:



        #!/bin/sh
        # Default samba server to connect to
        SAMBASERVER="sambaserver"
        USERNAME="$USER"

        if [ -n "$1" ]
        then
        # We've been given a different samba server
        SAMBASERVER="$1"
        fi

        if [ -n "$2" ]
        then
        # We've been given a different user on the samba server to use
        USERNAME="$2"
        fi

        CREDSFILE="${HOME}/.${SAMBASERVER}.credentials"

        # Try and make the mount point if it doesn't yet exist (and set suitable mount dir perms)
        if [ ! -d "${HOME}/${SAMBASERVER}" ]
        then
        mkdir "${HOME}/${SAMBASERVER}" && chmod 0555 "${HOME}/${SAMBASERVER}" || exit 1
        fi

        if [ ! -f "$CREDSFILE" ]
        then
        echo "$CREDSFILE not found!"
        exit 1
        fi

        smbmount "\${SAMBASERVER}${USERNAME}" "${HOME}/${SAMBASERVER}" -o user="$USERNAME",credentials="$CREDSFILE" || exit 1


        (Untested - you may need to tweak/debug/etc)



        Then create a credentials file in each user's home directory called (for example) .sambaserver.credentials and set it's permissions to 0600, owned by that user:



        username=<samba user>
        password=<samba password>


        Lastly, put a call to your above mount script in their .profile.
        eg: /usr/local/bin/mount-user-home.sh or /usr/local/bin/mount-user-home.sh sambaserver somedifferentusername for special cases.



        This should work with multiple samba servers, multiple users & multiple users with multiple samba servers.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jun 9 '15 at 21:15









        Smiling DragonSmiling Dragon

        2441 silver badge3 bronze badges




        2441 silver badge3 bronze badges






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f208348%2fmount-remote-home-directories%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

            Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

            Nicolae Petrescu-Găină Cuprins Biografie | Opera | In memoriam | Varia | Controverse, incertitudini...