You are not logged in.
1. Let gnome-keyring store your WPA keyphrase.
See this post
2. Let gnome-keyring store your iceweasel(firefox) passwords.
See this post
3. Let gnome-keyring store your SSH passphrase.
See this post
4. Let gnome-keyring store passwords for your scripts.
See this post
5. Let gnome keyring store your git password.
See this post
Offline
4. Let gnome-keyring store passwords for your scripts.
EDIT: There is a package libsecret-tools which provides the utility secret-tool. This is simpler to install and use. See 'man secret-tool'.
---
You need the python script gkeyring from GitHub. Download the zip file from https://github.com/kparal/gkeyring/archive/master.zip
Unpack the archive, make a symlink from your bin directory to the python file gkeyring.py, wherever you put it, make sure it's executable.
ln -s /path/to/gkeyring.py $HOME/bin/gkeyring
chmod +x /path/to/gkeyring.py
Install the packages python-gnomekeyring and seahorse.
Seahorse isn't needed for running your scripts, but it makes setting things up easier.
See the output of 'gkeyring --help' for a full list of options, but here is a simple setup:
To store a new password in your login keyring, under the name newkey, try this
gkeyring --set -n newkey --keyring login
You'll be asked to enter the password to be stored in "newkey".
You can retrieve it with
gkeyring -n newkey --keyring login
Often in scripts you'll want the password only, with no trailing newline. The option '-1' will give you that, so you might have code like:
password=$(gkeyring -n newkey --keyring login -1)
If login is your "default" keyring it can be dropped from the command.
If you make a new keyring, different from "login" it won't be opened automatically when you start your session, but the first time a script uses it a password window will come up to open the keyring - with the keyring's password. After that the keyring will be open (unless you lock it again) and scripts will be able to get newkey's password freely.
I haven't discovered a way to create a new keyring with gkeyring (xaos52?) but you can do it with seahorse. Then, to store in a new keyring called "test":
gkeyring --set -n anotherkey --keyring test
and
password=$(gkeyring -n anotherkey --keyring test -1)
There are other ways to access stored keys, but I'll leave that for you to research.
Last edited by johnraff (2018-09-17 06:48:28)
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Offline
Thx John,
Tools like gkeyring allow you to view all "secrets" in the clear, hence the advice:
******* Protect all your keyrings with a password *********
This still leaves you with some passwords to memorize - or store in a gpg encrypted file.
When using passwords from a script, remember to open the keyring before launching the script.
Offline
5. Let gnome keyring store your git password
When you install git, it comes with the source code for a C program in
/usr/share/doc/git/contrib/credential/gnome-keyring.git-credential-gnome-keyring.c
This is a helper program that can be used to make git retrieve your password from gnome keyring.
To install the program:
mkdir -p $HOME/tmp/today/git-credential
cd $_
cp /usr/share/doc/git/contrib/credential/gnome-keyring/* .
sudo apt-get install libgnome-keyring-dev
make
sudo cp git-credential-gnome-keyring /usr/local/bin/
I installed to /usr/local/bin. If you want it for your user only use $HOME/bin.
Now set up git to use the git-credential-gnome-keyring helper:
git config --global credential.helper /usr/local/bin/git-credential-gnome-keyring
The first time you push something to github you will be prompted for your git password (if your default keyring has a password - and it should! - and it is not open) and it will be stored in your default keyring. Subsequent pushes to github will not ask for your git password no more if your default keyring is open.
Offline
The git repo for gkeyring contains a nice little shell script - moz-sec-get.sh - to copy site passwords to the clipboard for 16s, and then clears the clipboard:
#!/bin/sh
# Looks up a mozilla-gnome-keyring password and copies it to a clipboard for 16s.
# Requires xclip(1) and secret-tool(1).
test -n "$1" || { echo >&2 "Usage: $0 <host_or_url> [<username>]"; exit 2; }
set -e
host=$(echo "$1" | sed -re 's,^([^:]+://[^/]+)/.*,\1,g')
pass=$( test -n "$2" \
&& secret-tool lookup hostname "$host" username "$2" \
|| secret-tool lookup hostname "$host")
if [ -z "$DISPLAY" ]; then
echo "$pass"
else
echo "$pass" | xclip -selection clipboard
{ sleep 16; echo "" | xclip -selection clipboard; } &
echo >&2 "copied to clipboard; will clear it after 16s"
fi
Needs package 'xclip' installed on your system.
Example usage:
Suppose you have
me@medion:~/tmp/today/seahorse$ gkeyring --all --keyring mozilla
3 https://forums.gentoo.org efehfeknezk
7 https://www.facebook.com ,dlsldfkjesk
18 https://webmail.telenet.be kdskfsdkk
20 https://forums.bunsenlabs.org ;ndkenrkl,em,ezlmkr,
me@medion:~/tmp/today/seahorse$
in a keyring - the script does not require your keyring to be named 'mozilla', mine just happens to be named so - you can then run the script (after installing it somewhere in your PATH).
moz-sec-get.sh https://forums.bunsenlabs.org
and you will have the password on your clipboard for 16s.
WARNING
The password will remain visible in your clipit history until you clear it.
I haven'd found a method to clear the clipit history from the command line. Any takers to add that functionality?
Offline
When using passwords from a script, remember to open the keyring before launching the script.
In fact this is not necessary. If the keyring is locked...
If you make a new keyring, different from "login" it won't be opened automatically when you start your session, but the first time a script uses it a password window will come up to open the keyring - with the keyring's password.
Probably this needs polkit-gnome-authentication-agent-1 to be running (as it is in BL by default).
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Offline
5. Let gnome keyring store your git password
Thank you for this - it works perfectly!
I haven'd found a method to clear the clipit history from the command line. Any takers to add that functionality?
Drop '-selection clipboard' from the xclip commands and the password will go into the primary selection instead, from where you can paste it with a middle-click. Make sure clipit's preference box "Use Primary (Selection)" is unchecked and it won't go in the history.
BTW that script uses secret-tool which is provided by libsecret-tools and a new discovery for me. It looks like a useful alternative to gkeyring in fact.
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Offline
Snake-charmers might be interested in this series (7) of articles on using python with gnome-keyring:
http://mindbending.org/en/bending-gnome … hon-part-1
...elevator in the Brain Hotel, broken down but just as well...
( a boring Japan blog (currently paused), now on Bluesky, there's also some GitStuff )
Offline