20100625 mounting cifs shares - plembo/onemoretech GitHub Wiki

title: Mounting CIFS Shares link: https://onemoretech.wordpress.com/2010/06/25/mounting-cifs-shares/ author: lembobro description: post_id: 151 created: 2010/06/25 00:45:15 created_gmt: 2010/06/25 00:45:15 comment_status: open post_name: mounting-cifs-shares status: publish post_type: post

Mounting CIFS Shares

Had this idea that being able to publish CIFS (”Common Internet File System”, a/k/a Windows SMB) shares off a NAS device through a Linux web server might be useful. Since I haven’t worked with the samba client for awhile, I wasn’t aware that smbmount has gone the way of the dodo. The new, improved, way is to use a “mount -f cifs” command. For example:

mount -t cifs //10.0.1.10/shared -o username='DOMAINplembo',password=mypass /var/www/html/docshare

Note that I enclosed the username with its domain component in single quotes. The quotes are necessary to avoid confusing the mount command, which doesn’t know anything about Windows syntax (and hopefully never will).

This worked as expected, allowing me to publish docshare at http://myhost.example.com/docshare.

Of course there’s one small security hole with this arrangement: anything the mounting user can see can now be accessed by a casual visitor to the web server. One way to deal with this is to leverage the Apache authnzldap module by placing an .htaccess file with the appropriate directives in the share root. This will trigger authentication to the LDAP server of your choice — which could be either a standard LDAP directory or even Microsoft’s Active Directory.

There are ways to make these kinds of mounts automatic, to mount on boot or remount if the connection is interrupted using the automount daemon.

For more on that see How to mount remote Windows shares.

Copyright 2004-2019 Phil Lembo