{"id":180,"date":"2016-04-16T13:12:35","date_gmt":"2016-04-16T12:12:35","guid":{"rendered":"https:\/\/tollana.d-tor.org\/notes-to-self\/?p=180"},"modified":"2016-11-27T00:41:02","modified_gmt":"2016-11-26T23:41:02","slug":"agents-systemd-and-more","status":"publish","type":"post","link":"https:\/\/tollana.d-tor.org\/notes-to-self\/?p=180","title":{"rendered":"Agents, systemd and More"},"content":{"rendered":"<h3>How to start {gpg,ssh}-agent with systemd<\/h3>\n<p>To get rid of the convoluted and error prone start_agent function in .bashrc, just start ssh-agent and gpg-agent as user service with systemd. <strong>A big, fat warning before:<\/strong> Don&#8217;t even try to use gpg-agent as a replacement for ssh-agent! It&#8217;s so buggy that it won&#8217;t work!<\/p>\n<p>To start the agents as user service, you have to create the following services in $HOME\/.config\/systemd\/user (create the directory if it doesn&#8217;t exist):<\/p>\n<p>gpg-agent.service:<\/p>\n<pre>[Unit]\r\nDescription=GnuPG private key agent\r\nIgnoreOnIsolate=true\r\n\r\n[Service]\r\nType=forking\r\nExecStart=\/usr\/bin\/gpg-agent --daemon\r\nRestart=on-abort\r\n\r\n[Install]\r\nWantedBy=default.target<\/pre>\n<p>ssh-agent.service:<\/p>\n<pre>[Unit]\r\nDescription=SSH key agent\r\n\r\n[Service]\r\nType=forking\r\nEnvironment=SSH_AUTH_SOCK=%t\/ssh-agent.socket\r\nExecStart=\/usr\/bin\/ssh-agent -a $SSH_AUTH_SOCK\r\n\r\n[Install]\r\nWantedBy=default.target<\/pre>\n<p>Then enable them:<\/p>\n<pre>$ systemctl --user enable gpg-agent.service\r\n$ systemctl --user enable ssh-agent.service<\/pre>\n<p>Now add<\/p>\n<pre>export SSH_AUTH_SOCK=\"${XDG_RUNTIME_DIR}\/ssh-agent.socket\"<\/pre>\n<p>to your .bashrc, .profile or whatever and re-login. If the agents linger (i. e. aren&#8217;t restarted), add\u00a0the following entry\u00a0in \/etc\/systemd\/logind.conf:<\/p>\n<pre>KillUserProcesses=yes<\/pre>\n<p>and restart systemd-logind.\u00a0This kills all processes started on login, including kdeinit4 and stuff. <strong>Warning: This may kill your current X-Session!<\/strong><\/p>\n<p>Now you have to ssh-add your key every time you log out, but you don&#8217;t have to kill all the KDE-cruft any more. There always is a tradeoff \ud83d\ude42<\/p>\n<h3>SDDM and keyboard layouts<\/h3>\n<p>Creating a config snippet with localectl doesn&#8217;t work, but lo and behold, there&#8217;s a workaround. Just add<\/p>\n<pre>setxkbmap de,us nodeadkeys<\/pre>\n<p>to \/usr\/share\/sddm\/scripts\/Xsetup<\/p>\n<p>To change the X-Server layout, create a xorg.conf that does it right.<\/p>\n<h3>Restore KDE-Session<\/h3>\n<p>Well, that&#8217;s a problem. Most KDE-Apps remember their position, even their screen, but chromium does not. The closest thing to get it right:<\/p>\n<ol>\n<li>Go to System Settings -&gt; Startup and Shutdown -&gt; Desktop Session and set it to &#8220;Restore manually saved session&#8221;<\/li>\n<li>Place your programs and windows<\/li>\n<li>Save session<\/li>\n<li>Go to Startup and Shutdown -&gt; Autostart and add\u00a0chromium as command. Then edit Properties&#8230; -&gt; Application and change the command to:<\/li>\n<\/ol>\n<pre> chromium --disable-session-crashed-bubble --restore-last-session<\/pre>\n<p>This restores the last session without telling you that chromium crashed. Unfortunately, all windows appear on the current desktop, so you have to move them manually. AFAICT they keep their position, so defining keyboard shortcuts to move windows to another desktop, e. g. Meta-2 for desktop 2, makes this\u00a0easy.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>How to start {gpg,ssh}-agent with systemd To get rid of the convoluted and error prone start_agent function in .bashrc, just start ssh-agent and gpg-agent as user service with systemd. A big, fat warning before: Don&#8217;t even try to use gpg-agent as a replacement for ssh-agent! It&#8217;s so buggy that it won&#8217;t work! To start the &hellip; <a href=\"https:\/\/tollana.d-tor.org\/notes-to-self\/?p=180\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Agents, systemd and More<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13,77],"tags":[52,51],"class_list":["post-180","post","type-post","status-publish","format-standard","hentry","category-desktop","category-linux","tag-sddm","tag-systemd"],"_links":{"self":[{"href":"https:\/\/tollana.d-tor.org\/notes-to-self\/index.php?rest_route=\/wp\/v2\/posts\/180","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tollana.d-tor.org\/notes-to-self\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tollana.d-tor.org\/notes-to-self\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tollana.d-tor.org\/notes-to-self\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tollana.d-tor.org\/notes-to-self\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=180"}],"version-history":[{"count":1,"href":"https:\/\/tollana.d-tor.org\/notes-to-self\/index.php?rest_route=\/wp\/v2\/posts\/180\/revisions"}],"predecessor-version":[{"id":181,"href":"https:\/\/tollana.d-tor.org\/notes-to-self\/index.php?rest_route=\/wp\/v2\/posts\/180\/revisions\/181"}],"wp:attachment":[{"href":"https:\/\/tollana.d-tor.org\/notes-to-self\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=180"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tollana.d-tor.org\/notes-to-self\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=180"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tollana.d-tor.org\/notes-to-self\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=180"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}