Difference between revisions of "File shares"

From LUG
Jump to navigation Jump to search
(Services no longer exist.)
(14 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Using the department fileserver ==
+
=== Mounting Home Directories - CIFS ===
 +
As WUR has moved to a new home directory storage method, the path to finding it is much simpler:
  
=== Finding the location of a share ===
+
Write yourself an /etc/fstab entry that looks like this:
  
In order to use the guides below, you'll have to know on which servers the windows shares reside.
+
<pre style="white-space: pre;">//fs01mixedsmb.wurnet.nl/DBL-STANDARD_HOMEDIR$/myuser /mnt/mdrive cifs noauto,user,username=myuser,domain=wur,uid=mylocaluser,gid=mylocalgroup 0 0</pre>
The easiest way is to use a Windows PC, start up Explorer, got to the share and look at the Properties.
 
  
Alternatively, you can use smbclient to find all shares on a server:
+
(Replace myuser with your own WUR account name, and mylocaluser/mylocalgroup with the account/group you have locally)
  
* smbclient -I <server>.wurnet.nl -W wurnet.nl -U yourname001 -L <server>
+
Now you can simply:
  
Where <server> is scomp0300 for PSG and scomp0291 for ESG.
+
<code>mount /mnt/mdrive</code>
  
 +
And after entering your password, you have access to your M drive share.
  
=== Using smbmount (normal user) ===
+
==== Caveats ====
  
Suppose the server your personal share is located on is called sdep001 and your username is annie001, your password is annie, and you want to mount this share on ~/mnt If you do not know this information you can get it out of the ActiveDirectoryServer or from the "My Computer" screen of a windows machine.
+
This may occasionally not work on the first try, as the hostname WURNET.NL points to multiple machines. You may need to do this repeatedly to get a stable connection.
  
* smbmount '//sdep001/annie001$' ~/mnt/ -o username=annie001,password=annie,workgroup=WUR
+
=== Other Shares ===
  
if you leave out the password, the program will ask you for your password during the mounting:
+
The easiest way to gather information about available CIFS shares is using smbclient. On Ubuntu, you need the pacakge 'smbclient' to provide this.
  
* smbmount '//sdep001/annie001$' ~/mnt/ -o username=annie001,workgroup=WUR
+
Usage:
  
=== Using mount (as root) ====
+
<code>smbclient -L <server> -U username</code>
  
you can also do this using regular mount, as Stephan Verrips writes:
+
This will show you all the mounts available to you on that machine.
 +
 +
To test the mount:
  
* mount -t smbfs -o username=verri001,workgroup=wurnet.nl //sdpw0001.wurnet.nl/verri001$ ~/mnt
+
<code>sudo mount //server/share -ousername=username,domain=wur /tmp/smb</code>
  
Alternatively, the (newer) CIFS protocol can be used instead of SMB. The following example connects to the 'webdocs' share where web related files can be stored.
+
This will hold until you unmount it.  
  
* mkdir /mnt/webdocs
+
=== Automatically mounting at boot (/etc/fstab) ===
* mount -t cifs -o username=annie001,workgroup=wurnet.nl //skgr0004.wurnet.nl/webdocs$ /mnt/webdocs
+
 
 +
The above example will only mount when called. You want it to mount on boot. However, a simple issue is present - you must authenticate to mount. Thus, you need to have some credential stash. Modify the options to this:
  
=== Automatically mounting at boot (/etc/fstab) ===
+
<pre style="white-space: pre;">//fs01mixedsmb.wurnet.nl/Homes/username /mnt/mdrive cifs credentials=/home/localuser/.smbpassword,user,username=username,domain=wur,uid=localuser,gid=localuser 0 0</pre>
  
Add the following line to the file <b>/etc/fstab</b>
+
Then you can make the credential file. Set it 600 so that only you or root may read or write.
  
  //sdep001/annie001$ /mnt/wur smbfs username=annie001,password=annie,workgroup=WUR,uid=502 0 0
+
<code>echo username=username > ~/.smbpassword</code>
  
or a really working example for a shared network drive (for DPW - note the odd spaces in the name using \040):
+
<code>echo password=mypassword >> ~/.smbpassword</code>
  
//scomp0300/PSG~DPW\040Laboratory\040of\040Nematology$ /mnt/wur smbfs username=annie001,password=annie,workgroup=WUR,uid=501 0 0
+
<code>chmod 600 ~/.smbpassword</code>
  
or try
 
  
//scomp0300/PSG~DPW\040Laboratory\040of\040Nematology$ /mnt/wur smbfs //username=annie001,password=annie,workgroup=WUR,uid=501 0 0
+
=== Automatically mounting when users login (pam_mount) ===
  
The uid represents the user id you use - check your id with the id command:
+
<code>apt-get install libpam-mount cifs-utils</code>
  
  id
+
Create or edit pam_mount.conf.xml in /etc/security
 +
<pre>
 +
<nowiki>
 +
<?xml version="1.0" encoding="utf-8" ?>
 +
<!DOCTYPE pam_mount SYSTEM "pam_mount.conf.xml.dtd">
 +
<!--
 +
See pam_mount.conf(5) for a description.
 +
-->
  
it is also possible to use a gid (group id) to share the mounted drive with multiple users on one system.
+
<pam_mount>
  
Note: since it contains your password this option is not so secure!
+
<!-- debug should come before everything else,
 +
since this file is still processed in a single pass
 +
from top-to-bottom -->
  
  Safer is to use a separate password file:
+
<debug enable="0" />
 
 
* cd ~
 
* echo username=annie001 > .smbpassword 
 
* echo password=annie >> .smbpassword 
 
* chmod 600 .smbpassword
 
  
  This created a hidden password file that can only be read by you or the root
+
<!-- Volume definitions -->
  
Change the line in the <b>/etc/fstab</b> into
 
  
* //sdep001/annie001$ /mnt/wur smbfs credentials=/home/annie/.smbpassword,workgroup=WUR,uid=502 0 0
+
<!-- pam_mount parameters: General tunables -->
  
Note: you set the uid to your user id (see 'man id') so you can write/read from your normal account.
+
<luserconf name=".pam_mount.conf.xml" />
  
Another example, again using the CIFS protocol instead of SMB, to automatically connect to the 'webdocs' share:
+
<!-- Note that commenting out mntoptions will give you the defaults.
 +
    You will need to explicitly initialize it with the empty string
 +
    to reset the defaults to nothing. -->
 +
<mntoptions allow="*" />
 +
<!--
 +
<mntoptions allow="nosuid,nodev,loop,encryption,fsck,nonempty,allow_root,allow_other" />
 +
<mntoptions deny="suid,dev" />
 +
<mntoptions allow="*" />
 +
<mntoptions deny="*" />
 +
-->
 +
<mntoptions require="nosuid,nodev" />
  
* //skgr0004.wurnet.nl/webdocs$ /mnt/webdocs cifs credentials=/home/annie/.smbpassword,workgroup=wurnet.nl,uid=502 0 0
+
<logout wait="0" hup="0" term="0" kill="0" />
  
=== Using Konqueror ===
+
<!-- pam_mount parameters: Volume-related -->
  
Windows shares can also be accessed, without any mounting, with the SMB kio slave (KDE).
+
<mkmountpoint enable="1" remove="true" />
The SMB kio slave can be used in Konqueror but also in other KDE applications.
 
  
The format of the url is:
+
</pam_mount>
 +
</nowiki>
 +
</pre>
  
  smb://<username>@<hostname>/<sharename>
+
Create a .pam_mount.conf.xml file in each users home directory.
  
where e.g.:
+
<pre>
 +
<nowiki>
 +
<pam_mount>
 +
<volume options="domain=WUR,nodev,nosuid" user="*" mountpoint="~/M" path="Homes/%(USER)" server="WURNET.NL" fstype="cifs" />
 +
<volume options="domain=WUR,nodev,nosuid" user="*" mountpoint="~/W" path="DFS-Root" server="WURNET.NL" fstype="cifs" />
 +
</pam_mount>
 +
</nowiki>
 +
</pre>
  
* username: wur\annie001
+
And then create the directories in the users homedir.
* hostname: sdep001.wur.nl
 
* sharename: annie001$
 
  
=== Troubleshooting ===
+
<code>mkdir ~/M</code>
  
If you get the error "Connection to .... failed" and you are sure you typed the server name correctly, you have to manually set the wins server in /etc/samba/smb.conf. Find the line that reads like:
+
<code>mkdir ~/W</code>
* ; wins server = <something>
 
Remove the ; and change the <something>:
 
* wins server = 10.110.10.3
 
  
== Accessing files on the DFS-Root ==
+
You can use skel to automatically put it in users home dir when creating a new user. If you want this then place the .pam_mount.conf.xml file in /etc/skel/ and create the M and W directory in /etc/skel
  
 
=== What is the DFS-Root ===
 
=== What is the DFS-Root ===
Line 103: Line 122:
 
DFS is Microsoft's Distributed File System. The purpose of a distributed file system is that the user can access files without knowing on which server the files are locates. The root of a distributed files system is called the DFS-Root. In the DFS-Root are virtual directories which are actual 'links' to shares on some servers.
 
DFS is Microsoft's Distributed File System. The purpose of a distributed file system is that the user can access files without knowing on which server the files are locates. The root of a distributed files system is called the DFS-Root. In the DFS-Root are virtual directories which are actual 'links' to shares on some servers.
  
In WURNET there is one wur-wide DFS-Root \\wur\dfs-root usually mapped to the W:-drive in windows.
+
Most modern CIFS implementations are able to handle DFS properly, thus a config like:
 
 
The samba client is unable to directly access files in the DFS-Root, instead you have to connect to the actual underlying shares.
 
 
 
=== DFS-Root directory mappings ===
 
 
 
If you have access a file or directory in the format:
 
 
 
\\wur\dfs-root\dir\rest\of\path or W:\dir\rest\of\path
 
  
then you must substitute \\wur\dfs-root\dir or W:\dir according the following table
+
<nowiki>//WURNET.NL/DFS-Root /mnt/wdrive cifs noauto,user,username=username,domain=wur 0 0</nowiki>
(Dir -> share):
 
  
 +
Should work.
  
* AFSG  =  //ATO0001C/AFSG$
+
With newer versions of smbclient it could happen that it needs a version specified in the mount options because the default version is not working. Then try it with version 1.0
* APPS  =  //SCOMP0025/apps
 
* ASG  =  //LD010s/ASG$
 
* ATV  =  //SATVF0001/shares
 
* BC    =  //SCOMP0064/BC
 
* DPT-DIER  =    //SCOMP0064/DIER
 
* DPT-MAATSCHAPPIJ    =    //SCOMP0063/MAATSCHAPPIJ
 
* FB    =  //SCOMP0064/FB
 
* LEI  =  //LEIDH017S/SHARES
 
* PLANT PROJECTS = //SPRI0010/PLANTPROJECTS$
 
* RIKILT = //SCOMP0063/RIKILT
 
* STUDENT = //SCOMP0064/STUDENT
 
  
The spaces in the names have to be escaped, using \040.
+
<nowiki>//WURNET.NL/DFS-Root /mnt/wdrive cifs noauto,user,username=username,domain=wur,vers=1.0 0 0</nowiki>

Revision as of 15:39, 7 January 2019

Mounting Home Directories - CIFS

As WUR has moved to a new home directory storage method, the path to finding it is much simpler:

Write yourself an /etc/fstab entry that looks like this:

//fs01mixedsmb.wurnet.nl/DBL-STANDARD_HOMEDIR$/myuser	/mnt/mdrive	cifs	noauto,user,username=myuser,domain=wur,uid=mylocaluser,gid=mylocalgroup	0	0

(Replace myuser with your own WUR account name, and mylocaluser/mylocalgroup with the account/group you have locally)

Now you can simply:

mount /mnt/mdrive

And after entering your password, you have access to your M drive share.

Caveats

This may occasionally not work on the first try, as the hostname WURNET.NL points to multiple machines. You may need to do this repeatedly to get a stable connection.

Other Shares

The easiest way to gather information about available CIFS shares is using smbclient. On Ubuntu, you need the pacakge 'smbclient' to provide this.

Usage:

smbclient -L <server> -U username

This will show you all the mounts available to you on that machine.

To test the mount:

sudo mount //server/share -ousername=username,domain=wur /tmp/smb

This will hold until you unmount it.

Automatically mounting at boot (/etc/fstab)

The above example will only mount when called. You want it to mount on boot. However, a simple issue is present - you must authenticate to mount. Thus, you need to have some credential stash. Modify the options to this:

//fs01mixedsmb.wurnet.nl/Homes/username	/mnt/mdrive	cifs	credentials=/home/localuser/.smbpassword,user,username=username,domain=wur,uid=localuser,gid=localuser	0	0

Then you can make the credential file. Set it 600 so that only you or root may read or write.

echo username=username > ~/.smbpassword

echo password=mypassword >> ~/.smbpassword

chmod 600 ~/.smbpassword


Automatically mounting when users login (pam_mount)

apt-get install libpam-mount cifs-utils

Create or edit pam_mount.conf.xml in /etc/security


<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE pam_mount SYSTEM "pam_mount.conf.xml.dtd">
<!--
	See pam_mount.conf(5) for a description.
-->

<pam_mount>

		<!-- debug should come before everything else,
		since this file is still processed in a single pass
		from top-to-bottom -->

<debug enable="0" />

		<!-- Volume definitions -->


		<!-- pam_mount parameters: General tunables -->

<luserconf name=".pam_mount.conf.xml" />

<!-- Note that commenting out mntoptions will give you the defaults.
     You will need to explicitly initialize it with the empty string
     to reset the defaults to nothing. -->
<mntoptions allow="*" />
<!--
<mntoptions allow="nosuid,nodev,loop,encryption,fsck,nonempty,allow_root,allow_other" />
<mntoptions deny="suid,dev" />
<mntoptions allow="*" />
<mntoptions deny="*" />
-->
<mntoptions require="nosuid,nodev" />

<logout wait="0" hup="0" term="0" kill="0" />

<!-- pam_mount parameters: Volume-related -->

<mkmountpoint enable="1" remove="true" />

</pam_mount>

Create a .pam_mount.conf.xml file in each users home directory.

 
<pam_mount>
	<volume options="domain=WUR,nodev,nosuid" user="*" mountpoint="~/M" path="Homes/%(USER)" server="WURNET.NL" fstype="cifs" />
	<volume options="domain=WUR,nodev,nosuid" user="*" mountpoint="~/W" path="DFS-Root" server="WURNET.NL" fstype="cifs" />
</pam_mount>

And then create the directories in the users homedir.

mkdir ~/M

mkdir ~/W

You can use skel to automatically put it in users home dir when creating a new user. If you want this then place the .pam_mount.conf.xml file in /etc/skel/ and create the M and W directory in /etc/skel

What is the DFS-Root

DFS is Microsoft's Distributed File System. The purpose of a distributed file system is that the user can access files without knowing on which server the files are locates. The root of a distributed files system is called the DFS-Root. In the DFS-Root are virtual directories which are actual 'links' to shares on some servers.

Most modern CIFS implementations are able to handle DFS properly, thus a config like:

//WURNET.NL/DFS-Root	/mnt/wdrive	cifs	noauto,user,username=username,domain=wur	0	0

Should work.

With newer versions of smbclient it could happen that it needs a version specified in the mount options because the default version is not working. Then try it with version 1.0

//WURNET.NL/DFS-Root	/mnt/wdrive	cifs	noauto,user,username=username,domain=wur,vers=1.0	0	0