(Unix) Store & use credentials for fstab
This is useful when auto-mounting by /etc/fstab is disabled due to the mount
requiring login credentials every time.
- Create a credentials file under
/rootAS ROOT usingsudoedit, e.g.:sudoedit /root/<CREDENTIALS_FILENAME>` - In the editor, write the login credentials for a given mount:
username=<MOUNT_USERNAME> password=<MOUNT_PASSWORD> - Confirm that the user of the new file is
root:sudo ls -al /root | grep <CREDENTIALS_FILENAME> - Change permissions of the file so that the file can be read/written only as root:
sudo chmod 600 /root/<CREDENTIALS_FILENAME> - In
/etc/fstab, specifycredentials=option under-oflag of the mount of interest:... -o ...,credentials=/root/<CREDENTIALS_FILENAME>,... ... - Test that the credentials work:
sudo mount -av
References:
Written on May 2, 2022
