{"id":44,"date":"2009-07-16T22:39:23","date_gmt":"2009-07-17T03:39:23","guid":{"rendered":"http:\/\/blog.alanporter.com\/2009-07-16\/plant-my-key"},"modified":"2009-07-16T22:39:23","modified_gmt":"2009-07-17T03:39:23","slug":"plant-my-key","status":"publish","type":"post","link":"https:\/\/alanporter.com\/blog\/2009\/07\/16\/plant-my-key\/","title":{"rendered":"Plant my key"},"content":{"rendered":"<p>Here&#8217;s a neat little script that I developed at &#8220;the oven place&#8221;.  It &#8220;plants&#8221; my SSH key on a remote machine, so I can get in later without entering a password.<\/p>\n<pre>#!\/bin\/sh\nuser_at_machine=$1\n# plant my SSH key on the target machine\ncat $HOME\/.ssh\/id_rsa.pub | \\\n   ssh $user_at_machine \\\n      \"if [ ! -d .ssh ] ; then mkdir -m 700 .ssh ; fi ; \\\n      cat &gt;&gt; .ssh\/authorized_keys\"<\/pre>\n<p>All of the action takes place in one single line (which I broke up here so it would wrap OK).  It takes your public key from the machine you&#8217;re on, and it pipes it into an SSH session, which you&#8217;ll have to type your password into.  On the remote machine, it creates a <code>.ssh<\/code> directory if it needs to, and then it appends your public key to an <code>authorized_keys<\/code> file.<\/p>\n<p>The next time you log in to that remote machine, you will not need to enter your password.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s a neat little script that I developed at &#8220;the oven place&#8221;. It &#8220;plants&#8221; my SSH key on a remote machine, so I can get in later without entering a password. #!\/bin\/sh user_at_machine=$1 # plant my SSH key on the target machine cat $HOME\/.ssh\/id_rsa.pub | \\ ssh $user_at_machine \\ &#8220;if [ ! -d .ssh ] [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,15],"tags":[],"class_list":["post-44","post","type-post","status-publish","format-standard","hentry","category-software","category-tips-tricks","count-0","even alt","author-alan","last"],"_links":{"self":[{"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/posts\/44","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/comments?post=44"}],"version-history":[{"count":0,"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/posts\/44\/revisions"}],"wp:attachment":[{"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/media?parent=44"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/categories?post=44"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alanporter.com\/blog\/wp-json\/wp\/v2\/tags?post=44"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}