我一直在尝试按照本文中的步骤使用密钥环(Gnome Keyring)存储 HTTPS GIT 凭据:
http://blog.iqandreas.com/git/storing-https-authentication-in-ubuntu-and-arch-linux/
我采取了以下步骤:
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
现在,当我使用任何远程 git 命令时,都会收到错误:
** (process:19273): CRITICAL **: Error communicating with gnome-keyring-daemon
是不是根本无法在 WSL 上运行守护进程,还是我遗漏了一些简单的东西?抱歉,如果这是一个不同类型的问题,我是 Ubuntu 新手。
另一方面,为标签“ubuntu-on-windows”创建同义词“WSL”是否是个好主意?
我认为这可能成为 ubuntu-on-windows 最合乎逻辑的缩写:https://blogs.msdn.microsoft.com/wsl/
更新:
我已尝试过@LordMord 所说的:
在 ~/.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
它告诉我再安装 2 个依赖项:
sudo apt-get install dbus-x11
sudo apt-get install gnome-keyring
但现在我在启动时收到此错误:
** (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
当我尝试使用远程 GIT 命令时出现此错误:
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.
答案1
在 ~/.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
只要公钥和私钥都在 ~/.ssh 中,凭证就会自动添加到 ssh-agent。mysql-workbench(需要 Xming)等钥匙串存储应用程序也可以使用。
您可以在 bash 启动时忽略此警告
gnome-keyring-daemon: insufficient process capabilities, unsecure memory might get used
答案2
你不需要修改 .bashrc
安装 keyrings.alt
sudo pip install keyrings.alt
答案3
您可以找到有关以下主题的密钥环官方文档:在无头 Linux 系统上使用 Keyring。这将适用于 WSL、Docker 容器和所有其他无头 Linux。这里有更简洁的说明。
$ 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
如果您只需要安全服务,那么您可以使用“keyrings.alt”Python 包代替 gnome-keyring。gnome-keyring 是为 X11 GUI 制作的,因此让它与非 GUI 一起工作有点麻烦。keyrings.alt 是为非 GUI 制作的。您可以按如下方式安装 keyrings.alt。
pip3 install -U --user keyrings.alt
“keyrings.alt” 存在安全风险,不宜在生产环境中使用