You can write a script which takes input for the username and password and applies it to each mount required. The script will need to be run with root level privileges. This also assumes that the mounts are all Samba shares. You'd need to tweak the script to include each of your mount points. With this script you will have to define all of your mount options rather than rely on those in fstab
:
#!/bin/bash
echo "Enter username for mounts:"
read mount_user
[[ -z "mount_user" ]] && echo "Username empty, exiting" && exit
echo "Enter password for mounts:"
read -s mount_pass
[[ -z "mount_pass" ]] && echo "Password empty, exiting" && exit
# Mount first share
mount -t cifs //server1/share1 /mnt/share1 -o username="$mount_user",password="$mount_pass"
# Mount second share
mount ...
Save this script as something like /home/user/mountall
, and execute it with sudo /home/user/mountall
.
This does load your password into memory in plain, and into a variable in the script's running process. Whether that is considered insecure in your environment is a question for your security team.
ssh
).sudo mount -a
will mount all not-mounted mountpoints in /etc/fstab, would that do it for you ?