5

My problem is to get ssh-agent instead of gnome-keyring up and running on a fresh installation of Ubuntu 16.10.

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.10
Release:    16.10
Codename:   yakkety

I have disabled the Gnome Keyring’s SSH component (X-GNOME-Autostart-enabled=false in gnome-keyring-ssh.desktop).

Ubuntu 16.10 automatically starts an instance of ssh-agent and should propagate the environment variables but instead partially fails to do so. If a terminal is started via the Unity Launcher or Nautilus, $SSH_AUTH_SOCK is set but if a terminal is launched via a keyboard shortcut (default ctrl+alt+t) the variable is empty.

Shortened pstree:

systemd─┬─accounts-daemon─┬─{gdbus}
        │                 └─{gmain}
        ├─acpid
        ├─agetty
        ├─avahi-daemon───avahi-daemon
        ├─cgmanager
        ├─colord─┬─{gdbus}
        │        └─{gmain}
        ├─cron
        ├─dbus-daemon
        ├─gnome-keyring-d─┬─{gdbus}
        │                 ├─{gmain}
        │                 └─{timer}
        ├─lightdm─┬─Xorg
        │         ├─lightdm─┬─upstart─┬─hud-service─┬─{QDBusConnection}
        │         │         │         │             ├─{gdbus}
        │         │         │         │             └─{gmain}
        │         │         │         ├─indicator-appli─┬─{gdbus}
        │         │         │         │                 └─{gmain}
        │         │         │         ├─indicator-bluet─┬─{dconf worker}
        │         │         │         │                 ├─{gdbus}
        │         │         │         │                 └─{gmain}
        │         │         │         ├─indicator-datet─┬─{dconf worker}
        │         │         │         │                 ├─{gdbus}
        │         │         │         │                 ├─{gmain}
        │         │         │         │                 ├─4*[{indicator-datet}]
        │         │         │         │                 └─{pool}
        │         │         │         ├─indicator-keybo─┬─{dconf worker}
        │         │         │         │                 ├─{gdbus}
        │         │         │         │                 └─{gmain}
        │         │         │         ├─indicator-messa─┬─{dconf worker}
        │         │         │         │                 ├─{gdbus}
        │         │         │         │                 └─{gmain}
        │         │         │         ├─indicator-power─┬─{dconf worker}
        │         │         │         │                 ├─{gdbus}
        │         │         │         │                 └─{gmain}
        │         │         │         ├─indicator-print─┬─{dconf worker}
        │         │         │         │                 ├─{gdbus}
        │         │         │         │                 └─{gmain}
        │         │         │         ├─indicator-sessi─┬─{dconf worker}
        │         │         │         │                 ├─{gdbus}
        │         │         │         │                 └─{gmain}
        │         │         │         ├─indicator-sound─┬─{dconf worker}
        │         │         │         │                 ├─{gdbus}
        │         │         │         │                 └─{gmain}
        │         │         │         ├─sh───url-dispatcher─┬─{gdbus}
        │         │         │         │                     ├─{gmain}
        │         │         │         │                     └─3*[{url-dispatcher}]
        │         │         │         ├─2*[sleep]
        │         │         │         ├─2*[upstart-dbus-br]
        │         │         │         ├─upstart-file-br
        │         │         │         ├─upstart-udev-br
        │         │         │         ├─window-stack-br───{QDBusConnection}
        │         │         │         └─xbrlapi
        │         │         ├─{gdbus}
        │         │         └─{gmain}
        │         ├─{gdbus}
        │         └─{gmain}
        ├─polkitd─┬─{gdbus}
        │         └─{gmain}
        ├─rsyslogd─┬─{in:imklog}
        │          ├─{in:imuxsock}
        │          └─{rs:main Q:Reg}
        ├─rtkit-daemon───2*[{rtkit-daemon}]
        ├─snapd───6*[{snapd}]
        ├─systemd─┬─(sd-pam)
        │         ├─at-spi-bus-laun─┬─dbus-daemon
        │         │                 ├─{dconf worker}
        │         │                 ├─{gdbus}
        │         │                 └─{gmain}
        │         ├─at-spi2-registr─┬─{gdbus}
        │         │                 └─{gmain}
        │         ├─bamfdaemon─┬─{gdbus}
        │         │            └─{gmain}
        │         ├─compiz─┬─{dconf worker}
        │         │        ├─{gdbus}
        │         │        └─{gmain}
        │         ├─dbus-daemon
        │         ├─dconf-service─┬─{gdbus}
        │         │               └─{gmain}
        │         ├─gconfd-2
        │         ├─gnome-session-b─┬─deja-dup-monito─┬─{dconf worker}
        │         │                 │                 ├─{gdbus}
        │         │                 │                 └─{gmain}
        │         │                 ├─gnome-software─┬─{dconf worker}
        │         │                 │                ├─{gdbus}
        │         │                 │                └─{gmain}
        │         │                 ├─nm-applet─┬─{dconf worker}
        │         │                 │           ├─{gdbus}
        │         │                 │           └─{gmain}
        │         │                 ├─polkit-gnome-au─┬─{dconf worker}
        │         │                 │                 ├─{gdbus}
        │         │                 │                 └─{gmain}
        │         │                 ├─unity-fallback-─┬─{dconf worker}
        │         │                 │                 ├─{gdbus}
        │         │                 │                 └─{gmain}
        │         │                 ├─update-notifier─┬─{dconf worker}
        │         │                 │                 ├─{gdbus}
        │         │                 │                 └─{gmain}
        │         │                 ├─zeitgeist-datah─┬─{gdbus}
        │         │                 │                 ├─{gmain}
        │         │                 │                 └─4*[{pool}]
        │         │                 ├─{dconf worker}
        │         │                 ├─{gdbus}
        │         │                 └─{gmain}
        │         ├─gnome-terminal-─┬─fish───pstree
        │         │                 ├─{dconf worker}
        │         │                 ├─{gdbus}
        │         │                 └─{gmain}
        │         ├─gpg-agent
        │         ├─ibus-daemon─┬─ibus-dconf─┬─{dconf worker}
        │         │             │            ├─{gdbus}
        │         │             │            └─{gmain}
        │         │             ├─ibus-engine-sim─┬─{gdbus}
        │         │             │                 └─{gmain}
        │         │             ├─ibus-ui-gtk3─┬─{dconf worker}
        │         │             │              ├─{gdbus}
        │         │             │              └─{gmain}
        │         │             ├─{gdbus}
        │         │             └─{gmain}
        │         ├─ibus-x11─┬─{gdbus}
        │         │          └─{gmain}
        │         ├─nautilus─┬─{dconf worker}
        │         │          ├─{gdbus}
        │         │          └─{gmain}
        │         └─ssh-agent
        ├─systemd-journal
        ├─systemd-logind
        ├─systemd-resolve
        ├─systemd-timesyn───{sd-resolve}
        └─systemd-udevd

Status of the ssh-agent service:

$ systemctl --user status ssh-agent                                                                                                                                                            22:03:56
● ssh-agent.service - OpenSSH Agent
   Loaded: loaded (/usr/lib/systemd/user/ssh-agent.service; static; vendor preset: enabled)
   Active: active (running) since Sun 2016-11-20 21:59:06 CET; 7min ago
 Main PID: 5513 (ssh-agent)
   CGroup: /user.slice/user-1000.slice/[email protected]/ssh-agent.service
           └─5513 ssh-agent -D -a /run/user/1000/openssh_agent

Nov 20 21:59:06 Cerberus systemd[4879]: Started OpenSSH Agent.
Nov 20 21:59:06 Cerberus agent-launch[5513]: dbus-update-activation-environment: setting SSH_AUTH_SOCK=/run/user/1000/openssh_agent
Nov 20 21:59:06 Cerberus agent-launch[5513]: dbus-update-activation-environment: setting SSH_AGENT_LAUNCHER=openssh
Nov 20 21:59:06 Cerberus agent-launch[5513]: SSH_AUTH_SOCK=/run/user/1000/openssh_agent; export SSH_AUTH_SOCK;
Nov 20 21:59:06 Cerberus agent-launch[5513]: echo Agent pid 5513;

The environment of the gnome-terminal-server knows about the correct SSH_AUTH_SOCK

$ ps aux | grep /usr/lib/gnome-terminal/gnome-terminal-server
max       6408  0.3  0.1 740696 32148 ?        Ssl  22:00   0:01 /usr/lib/gnome-terminal/gnome-terminal-server
max      13129  0.0  0.0  21428  1844 pts/5    S+   22:09   0:00 grep --color=auto /usr/lib/gnome-terminal/gnome-terminal-server
$ xargs -n 1 -0 < /proc/6408/environ | grep SSH_AUTH_SOCK                                                                                                                                      22:09:35
SSH_AUTH_SOCK=/run/user/1000/openssh_agent

Every method of launching a terminal I tried led to them being children of the gnome-terminal-server which has the correct environment set.

Is there any way to fix this issue on my side or should I file a bug report?

1 Answer 1

3

I got it to work, the problem seems to be a race condition.

First I ran systemctl --user mask gnome-keyring-ssh and kept the change of gnome-keyring-ssh.desktop to completely disable Gnome Keyring’s SSH service. Just masking the service did not suffice.

Secondly I created a service file overwrite via systemctl --user edit ssh-agent containing the following settings:

[Service]
Type=forking

Lastly I edited /usr/lib/openssh/agent-launch and replaced exec ssh-agent -D -a $S with ssh-agent -a $S.

I tried setting the service type to notify, NotifyAccess to all and running systemd-notify --ready before exec’ing ssh-agent but for some reason systemd did not receive the notification and ran into a timeout of the ssh-agent.service.

1
  • Amazing work! I had the exact same problem (also in 16.10), but hadn't noticed that only Ctrl-Alt-T-started Terminal sessions lacked the SSH_... environment variables. I must say, the cure looks almost as bad as the disease though -- I've personally opted to try sticking with gnome-keyring/seahorse, now that I've discovered they behave "nicely" if you created a corresponding .pub file for each private key in ~/.ssh. Apr 13, 2017 at 16:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .