{"id":235,"date":"2016-12-14T09:46:17","date_gmt":"2016-12-14T15:46:17","guid":{"rendered":"https:\/\/adamkuj.net\/blog\/?p=235"},"modified":"2021-05-11T08:59:24","modified_gmt":"2021-05-11T13:59:24","slug":"ssh-keyagent","status":"publish","type":"post","link":"https:\/\/adamkuj.net\/blog\/2016\/12\/14\/ssh-keyagent\/","title":{"rendered":"SSH Keyagent"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignright size-full wp-image-261\" src=\"https:\/\/adamkuj.net\/blog\/wp-content\/uploads\/2016\/12\/openssh.gif\" alt=\"\" width=\"249\" height=\"210\"\/>While most desktop Linux OS&#8217;s have decent support for ssh-agent, it may be something you have to add to certain Linux or *BSD disto&#8217;s. I&#8217;ve been using the following to load my private key(s) the first time I login, and hold them in memory for subsequent sessions.<\/p>\n<p>[shell title=&#8221;~\/.bashrc&#8221; language=&#8221;true&#8221;]<br \/>\nSSH_ENV=&#8221;$HOME\/.ssh\/environment&#8221;<\/p>\n<p>function start_agent {<br \/>\necho &#8220;Initialising new SSH agent&#8230;&#8221;<br \/>\n(umask 066; \/usr\/bin\/ssh-agent &gt; &#8220;${SSH_ENV}&#8221;)<br \/>\n. &#8220;${SSH_ENV}&#8221; &gt; \/dev\/null<br \/>\n\/usr\/bin\/ssh-add;<br \/>\n}<\/p>\n<p># Source SSH settings, if applicable<\/p>\n<p>if [ -f &#8220;${SSH_ENV}&#8221; ]; then<br \/>\n. &#8220;${SSH_ENV}&#8221; &gt; \/dev\/null<br \/>\nps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ &gt; \/dev\/null || {<br \/>\nstart_agent;<br \/>\n}<br \/>\nelse<br \/>\nstart_agent;<br \/>\nfi<\/p>\n<p>if [ -z &#8220;$SSH_AUTH_SOCK&#8221; ]; then<br \/>\neval ssh-agent -s ssh-add<br \/>\nfi<br \/>\n[\/shell]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>While most desktop Linux OS&#8217;s have decent support for ssh-agent, it may be something you have to add to certain Linux or *BSD disto&#8217;s. I&#8217;ve been using the following to load my private key(s) the first time I login, and hold them in memory for subsequent sessions. [shell title=&#8221;~\/.bashrc&#8221; language=&#8221;true&#8221;] SSH_ENV=&#8221;$HOME\/.ssh\/environment&#8221; function start_agent { echo [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-235","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/adamkuj.net\/blog\/wp-json\/wp\/v2\/posts\/235","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/adamkuj.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/adamkuj.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/adamkuj.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/adamkuj.net\/blog\/wp-json\/wp\/v2\/comments?post=235"}],"version-history":[{"count":4,"href":"https:\/\/adamkuj.net\/blog\/wp-json\/wp\/v2\/posts\/235\/revisions"}],"predecessor-version":[{"id":311,"href":"https:\/\/adamkuj.net\/blog\/wp-json\/wp\/v2\/posts\/235\/revisions\/311"}],"wp:attachment":[{"href":"https:\/\/adamkuj.net\/blog\/wp-json\/wp\/v2\/media?parent=235"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/adamkuj.net\/blog\/wp-json\/wp\/v2\/categories?post=235"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/adamkuj.net\/blog\/wp-json\/wp\/v2\/tags?post=235"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}