Mount Windows Network Share At Linux Login

Has anyone successfully mounted a Windows share based on a user’s login to the system over LDAP? Essentially what we’re aiming to do is, have the users log into their server via SSH, and authenticate using the same Active Directory accounts they use to log into their Windows workstations. Once they’re logged in, they will have their Windows home network share mounted to some directory. Is this possible?

I’ve been using OpenLDAP to handle the authentication part. However, I am getting stuck on the mounting of the network share. I can mount the CIFS shares via the mount command, so I know that’s working. I’ve tried using AutoFS…

File: /etc/auto.master
/directory/path /etc/auto.sharedfs

File: /etc/auto.sharedfs
USERNAME -fstype=cifs,username=USERNAME ://server/path/USERNAME

Is there an easier way to accomplish this, without creating a credentials file that would have to be updated every time the password expires in AD, or is there something I’m doing wrong in the files above?

The correct way to accomplish this thru /etc/fstab way

1 Like

@MayurIT thanks for the response. Sorry for the delay, I got pulled into a different project and actually just resolved this last week. However, I have actually resolved the situation using OpenLDAP, Kerberos, and AutoFS. In my configuration, I use LDAP to access the users and groups in AD for authentication, and use an AD group to limit SSH access. I used Kerberos to generate a ticket with AD based on my LDAP login, and that ticket allows my user to mount shares without re-entering my user/password. Lastly to prevent having to give each user SUDO privileges, AutoFS was used.