Quantcast
Channel: Active questions tagged mount+fstab - Ask Ubuntu
Viewing all articles
Browse latest Browse all 699

Pipe password argument to mount shell command

$
0
0

Status quo

Given are following /etc/fstab mount points:

//server/app /home/user/server/app cifs noauto,user,vers=3.11  0 0//server/code /home/user/server/code cifs noauto,user,vers=3.11  0 0

These are to be mounted with user priviledge (without sudo). Given user is logged in, password currently is interactively prompted - no credentials file and no hardcoded password in /etc/fstab.

In addition: all shares have the same credentials user with same password.

What is the problem?

Let's say, we want to mount all shares at startup. For share app:

mount ~/server/app # `user` is active# password interactively requestedPassword for user@//server/app:  (press TAB for no echo)

The problem is, I would have to type the same password for all shares, since it won't be cached.

What I tried

# type password once and store it in process memoryecho "Enter password for mounts:"read -s mount_pass[[ -z "mount_pass" ]] && echo "Password empty, exiting" && exit# mount all shares - how to feed every mount command with given password?mount ~/server/appmount ~/server/code# My attemptsecho $mount_pass | mount ~/server/appmount ~/server/app < <(echo $mount_pass)

(Excuse my superficial shell knowledge)

Is there a way to pass the password stored in $mount_pass to mount command, so that it can be automatically read by its standard input and no interactive prompt is opened?


Viewing all articles
Browse latest Browse all 699

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>