Last active
July 17, 2018 11:37
-
-
Save danielcarr/928296f5463a9ddc5abee6c3513c7334 to your computer and use it in GitHub Desktop.
Automatically mount and unmount network shares with connection to company network
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is the /etc/fstab file | |
# ... | |
# lots other entries | |
# ... | |
//SHAREADDRESS/common/directory/path /mnt/sharedserver cifs noauto,ro,uid=1000,gid=100,credentials=/home/username/.sharedserver.creds 0 0 | |
//SHAREADDRESS/users/my-directory /mnt/home cifs noauto,credentials=/home/username/.sharedserver.creds 0 0 |
The even better way is to add the mount points to /etc/fstab
and then you can just mount the mount point without specifying anything further. And it makes it easier to remount (for example to add write permissions) later on.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Rather than passing the username and password directly in the script, it's better to make a file (in a location that can only be edited or read by the user who should have access to the server), in the format of
sharedserver.creds
, and pass that as thecredentials
option to the mount command.