Question

I'm building an ltsp server

All is well and is connected to my AD Server. I can login using the AD user.

My question here is how to make it mount a specific smb share from the server using the login credential a.k.a AD account ( means it's dynamic ). So when each user login it will automatically mount the smb share using their user.

Any good tutorial ?, what I find in the website mostly we have to write the user name and password in the file at let fstab read it, that's impossible .... for security

Était-ce utile?

La solution

put the samba mount command as an executable in one of your $PATH folders, you can find them trough

echo $PATH

for example the /usr/local/bin is usaly in the $PATH. an example samba mount file:

#! /bin/bash
sudo smbmount //192.168.2.28/projects /mnt/projects -o user=$1

So now you have a /usr/local/bin/mountsamba.sh, To let anyone run this:

# chmod u+x /usr/local/bin/mountsamba.sh

The third step is to allow the newly created executable to be executed as root without password, this requires editing of the sudoers file:

#visudo

and add:

%samba_mount_group ALL=(root) NOPASSWD: /usr/local/bin/mountsamba.sh

now all users can in the samba_mount_group can execute that command as sudo without password. you probalby also want to

  • create a group: linux.die.net/man/8/groupadd
  • add an user to a group: www.cyberciti.biz/faq/howto-linux-add-user-to-group/

finaly to mount the folder on user login put the command in the target user's .bashrc

$ echo "cur_user=$USER; sudo bash /usr/local/bin/mountsamba.sh $cur_user" >> .bashrc

(note: this should be executed as the target user) assuming they boot in the bourne again shell terminal

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top