12

I've been trying to store HTTPS GIT credentials using a Keyring (Gnome Keyring) using the steps in this article:

http://blog.iqandreas.com/git/storing-https-authentication-in-ubuntu-and-arch-linux/

I took these steps:

sudp apt-get install make
sudo apt-get install-gnome-keyring-dev
sudo make --directory=/usr/share/doc/git/contrib/credential/gnome-keyring
git config --global credential.helper /usr/share/doc/git/contrib/credential/gnome-keyring/git-credential-gnome-keyring

Now when I use any remote git command, I get the error:

** (process:19273): CRITICAL **: Error communicating with gnome-keyring-daemon

Is it just not possible to run a daemon on WSL, or am I missing something simple? Sorry if this is a different type of question, I'm new on Ubuntu.

On another note, would it be a good idea to create a synonym 'WSL' for the tag 'ubuntu-on-windows'?

I think this might become the most logical acronym for ubuntu-on-windows: https://blogs.msdn.microsoft.com/wsl/

UPDATE:

I've tried what @LordMord said:

add at the end of ~/.bashrc

ssh-add -l &>/dev/null
if [ "$?" == 2 ]; then
  test -r ~/.gnome-keyring && \
    source ~/.gnome-keyring && \
    export DBUS_SESSION_BUS_ADDRESS GNOME_KEYRING_CONTROL SSH_AUTH_SOCK GPG_AGENT_INFO GNOME_KEYRING_PID

  ssh-add -l &>/dev/null
  if [ "$?" == 2 ]; then
    (umask 066; echo `dbus-launch --sh-syntax` > ~/.gnome-keyring; gnome-keyring-daemon >> ~/.gnome-keyring)
    source ~/.gnome-keyring && \
    export DBUS_SESSION_BUS_ADDRESS GNOME_KEYRING_CONTROL SSH_AUTH_SOCK GPG_AGENT_INFO GNOME_KEYRING_PID
  fi
fi

And it told me to install 2 more dependencies:

sudo apt-get install dbus-x11
sudo apt-get install gnome-keyring

but now I get this error on startup:

** (gnome-keyring-daemon:23): WARNING **: couldn't create socket directory: No such file or directory

** (gnome-keyring-daemon:23): WARNING **: couldn't bind to control socket: /home/wtijsma/.cache/keyring-3mToEe/control: No such file or directory

And this error when I try to use a remote GIT command:

Gkr-Message: couldn't connect to dbus session bus: Did not receive a reply. Possible causes include: the remote application did not send a reply, the message bus security policy blocked the reply, the reply timeout expired, or the network connection was broken.
2
  • I ended up just following his security conscious recommendation of using a long credential timeout so at least I only need to type it once a day. Jan 26, 2017 at 1:50
  • You might have an advice here? askubuntu.com/questions/905658/…
    – user423047
    Apr 17, 2017 at 5:32

3 Answers 3

2

add at the end of ~/.bashrc

ssh-add -l &>/dev/null
if [ "$?" == 2 ]; then
  test -r ~/.gnome-keyring && \
    source ~/.gnome-keyring && \
    export DBUS_SESSION_BUS_ADDRESS GNOME_KEYRING_CONTROL SSH_AUTH_SOCK GPG_AGENT_INFO GNOME_KEYRING_PID

  ssh-add -l &>/dev/null
  if [ "$?" == 2 ]; then
    (umask 066; echo `dbus-launch --sh-syntax` > ~/.gnome-keyring; gnome-keyring-daemon >> ~/.gnome-keyring)
    source ~/.gnome-keyring && \
    export DBUS_SESSION_BUS_ADDRESS GNOME_KEYRING_CONTROL SSH_AUTH_SOCK GPG_AGENT_INFO GNOME_KEYRING_PID
  fi
fi

Credentials are automatically added to ssh-agent provided that both the public and private keys are inside ~/.ssh. Keychain storing applications such as mysql-workbench(requires Xming) also work.

You can ignore this warning on bash startup

gnome-keyring-daemon: insufficient process capabilities, unsecure memory might get used

source: https://www.reddit.com/r/bashonubuntuonwindows/comments/4yhch4/using_gnomekeyringdaemon_for_ssh_keys/

2
2

You don't need the modifications in your .bashrc

Install keyrings.alt

sudo pip install keyrings.alt

2
  • Some more details about how to set this up would be appreciated. Does gnome-keyring use this or does this take the place of gnome-keyring? Do I need to do anything with git config to use it? Nov 20, 2017 at 18:04
  • 1
    This is wrong on so many levels: 1. sudo pip install to break your system python installation (keyrings.alt is packaged in Debian & Ubuntu, so installing the package python-keyrings.alt or python3-keyrings.alt is enough. 2. This will only help if the tool you are using is using the Python keyring package, otherwise this is no fix at all
    – TobiX
    Apr 3, 2019 at 15:29
0

You can find the keyring official document about Using Keyring on headless Linux systems. This would work on WSL, Docker containers and all other headless Linux. Here is more concise instructions.

$ sudo apt-get update
$ sudo apt install -y gnome-keyring python3-pip
$ pip3 install -U --user pip keyring
$ dbus-run-session -- sh # this will drop you into a new D-bus shell
$ echo 'any_password' | gnome-keyring-daemon --unlock # unlock the system's keyring
$ keyring set system user # enter any thing
$ keyring get system user

If you just need a security service, then you can use "keyrings.alt" Python package instead of gnome-keyring. gnome-keyring was made for X11 GUI, so it is a bit painful to make it work with non-GUI. keyrings.alt is made for non-GUI. You can install keyrings.alt as follows.

pip3 install -U --user keyrings.alt

"keyrings.alt" has security risks. It shouldn't be used in production environment

1
  • Your link is invalid
    – Nmath
    Sep 10, 2021 at 4:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.