{"id":3960,"date":"2023-10-30T08:02:10","date_gmt":"2023-10-30T08:02:10","guid":{"rendered":"https:\/\/geekmungus.co.uk\/?p=3960"},"modified":"2023-10-30T08:02:10","modified_gmt":"2023-10-30T08:02:10","slug":"add-ssh-agent-on-login-linux","status":"publish","type":"post","link":"https:\/\/geekmungus.co.uk\/?p=3960","title":{"rendered":"Add SSH Agent on Login (Linux)"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">I&#8217;m not sure if this is best necessarily best practice (so please comment below). I had the need to be using SSH key based authentication a lot. So rather than manually running the SSH Agent and then adding my private key (which then meant entering the passphrase on each use), I added this to my BASH profile so when logging on these would start; sure i&#8217;d need to enter my SSH key passphrase, but i&#8217;d only need to do this once at logon, and not each time I wanted to use the key.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To set this up I edited the <strong>~\/.profile<\/strong> file within my home directory, and added the following lines to the bottom of the file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>eval \"$(ssh-agent -s)\"\r\nssh-add ~\/.ssh\/id_rsa<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then log off, when I logged on again I was prompted for my SSH key passphrase, then when entered I could use key authentication as many times as I needed during my session. It was handy when working with some Ansible configuration!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m not sure if this is best necessarily best practice (so please comment below). I had the need to be using SSH key based authentication a lot. So rather than manually running the SSH Agent and then adding my private key (which then meant entering the passphrase on each use), I added this to my &#8230; <a title=\"Add SSH Agent on Login (Linux)\" class=\"read-more\" href=\"https:\/\/geekmungus.co.uk\/?p=3960\" aria-label=\"Read more about Add SSH Agent on Login (Linux)\">Read more<\/a><\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[20],"tags":[],"class_list":["post-3960","post","type-post","status-publish","format-standard","hentry","category-random"],"_links":{"self":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3960","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3960"}],"version-history":[{"count":1,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3960\/revisions"}],"predecessor-version":[{"id":3961,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/3960\/revisions\/3961"}],"wp:attachment":[{"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3960"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3960"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/geekmungus.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3960"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}