aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/%HOME%
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2018-06-05 02:22:53 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2018-06-05 02:22:53 +0300
commit77242c62757c3ed1d1289196097380f168087071 (patch)
treefd8b8ad954365b60f438a622d3484772fdeaf779 /%HOME%
parentadd comments (diff)
downloadlinux-home-77242c62757c3ed1d1289196097380f168087071.tar.gz
linux-home-77242c62757c3ed1d1289196097380f168087071.zip
add ssh-agent systemd unit
Diffstat (limited to '%HOME%')
-rw-r--r--%HOME%/.config/systemd/user/ssh-agent.service20
-rw-r--r--%HOME%/.profile8
2 files changed, 27 insertions, 1 deletions
diff --git a/%HOME%/.config/systemd/user/ssh-agent.service b/%HOME%/.config/systemd/user/ssh-agent.service
new file mode 100644
index 0000000..297ab75
--- /dev/null
+++ b/%HOME%/.config/systemd/user/ssh-agent.service
@@ -0,0 +1,20 @@
+# Enable using: systemd --user enable ssh-agent
+# Start immediately using: systemd --user start ssh-agent
+# Make sure SSH_AUTH_SOCK is set to "$XDG_RUNTIME_DIR/ssh-agent.socket".
+# You can do this by adding it to ~/.profile (the usual way) or
+# ~/.pam_environment:
+# * "SSH_AUTH_SOCK DEFAULT=${XDG_RUNTIME_DIR}/ssh-agent.socket", or, if it
+# doesn't work,
+# * "SSH_AUTH_SOCK DEFAULT=/run/user/1000/ssh-agent.socket" (replace "1000"
+# with your UID.
+
+[Unit]
+Description=OpenSSH agent
+
+[Service]
+Type=simple
+Environment=SSH_AUTH_SOCK=%t/ssh-agent.socket
+ExecStart=/usr/bin/ssh-agent -D -a "$SSH_AUTH_SOCK"
+
+[Install]
+WantedBy=default.target
diff --git a/%HOME%/.profile b/%HOME%/.profile
index 94a3201..ad04911 100644
--- a/%HOME%/.profile
+++ b/%HOME%/.profile
@@ -81,4 +81,10 @@ spawn_ssh_agent() {
&& trap kill_ssh_agent EXIT
}
-spawn_ssh_agent
+# This is a deprecated way to start ssh-agent; now it's managed by systemd (see
+# .config/systemd/user/ssh-agent.service for details).
+# Before starting ssh-agent like this, make sure to disable system ssh-agent's
+# (like those started by Gnome or X11).
+# Also, this file needs to be sourced by both your login shell and your display
+# manager.
+command -v systemctl > /dev/null 2>&1 || spawn_ssh_agent