I generally use the automount
service for shares like this that I'll periodically want to mount and use. Setting this up, once you understand how, is fairly trivial.
Step #1 - setup automounting
You'll need to make sure that packages are installed. On CentOS 6 that would be autofs
. Most likely other distros will use a similar name. You'll then need to create the following files:
# /etc/auto.master
/mymountpt /etc/auto.mymountpt --timeout=600 --ghost
# /etc/auto.mymountpt
someshare -fstype=cifs,rw,noperm,netbiosname=${HOST},credentials=/etc/credentials.txt ://cifsserver/sharename
# /etc/credentials.txt
username=mydom\myuser
password=somepassword
You'll need to make the permissions on this last file like so:
$ sudo chmod 600 /etc/credentials.txt
You'll also need to make sure that NSS (Name Service Switch) is aware of this setup:
# /etc/nsswitch.conf
automount: files nisplus
With these files in place you should now be able to start the autofs
service.
$ sudo service autofs start
Step #2 - testing it out
Once the service has been started, you'll be able to access this path at will:
$ cd /mymountpt/someshare
The mounting of this share is now governed by autofs
which will watch for 600 seconds of inactivity, at which point it will unmount the share.
This approach may seem a bit heavy handed but by doing things this way, you've alleviated your system from having to be dependent on a particular CIFS share as being available at boot. You've moved it so that it's now on demand when it's actually being used.
What to do if you don't have root login?
If you find you don't have these packages installed and aren't able to install them then your options become far fewer.
I would take a look at the Samba article in the ArchLinux Wiki, it covers other methods as well. You could also make use of FUSE to mount a variety of types of media as local directories, including SMB/CIFS. This is covered in the FUSESmb article on the Ubuntu Wiki.
References
You can do this if you are running gpg-agent (and your passphrase is loaded), by looping through the files in your password store and writing them to a separate file.
You do have to strip the leading directories from the path ($PASSWORD_STORE_DIR
) and the .gpg
extension from each of the files in the subdirectories, but otherwise it is straightforward enough:
#!/usr/bin/env bash
# export passwords to external file
shopt -s nullglob globstar
prefix=${PASSWORD_STORE_DIR:-$HOME/.password-store}
for file in "$prefix"/**/*.gpg; do
file="${file/$prefix//}"
printf "%s\n" "Name: ${file%.*}" >> exported_passes
pass "${file%.*}" >> exported_passes
printf "\n\n" >> exported_passes
done
Best Answer
The Arch Wiki contains a lot of information about how to configure and use gpg-agent, but the most important one is probably the following entry in
~/.gnupg/gpg-agent.conf
:This allows adjusting the time (in seconds) that gpg-agent will remember your passphrase. The default is 60.
2. You can also use gpg-agent to cache ssh keys. Unfortunately I've never managed to set this up reliably, so I can't give you any hints here.
Also, unrelated to your questions, but auth-password-store integrates pass with Emacs' auth-source mechanism.