{"id":437,"date":"2010-10-04T05:02:05","date_gmt":"2010-10-04T03:02:05","guid":{"rendered":"http:\/\/www.shukko.com\/x3\/?p=437"},"modified":"2010-10-04T05:04:42","modified_gmt":"2010-10-04T03:04:42","slug":"ssh-login-without-password","status":"publish","type":"post","link":"https:\/\/www.shukko.com\/x3\/2010\/10\/04\/ssh-login-without-password\/","title":{"rendered":"SSH login without password"},"content":{"rendered":"<p>Your aim<\/p>\n<p>You want to use Linux and OpenSSH to automize your tasks. Therefore you need an automatic login from host A \/ user a to Host B \/ user b. You don&#8217;t want to enter any passwords, because you want to call ssh from a within a shell script.<br \/>\nHow to do it<\/p>\n<p>First log in on A as user a and generate a pair of authentication keys. Do not enter a passphrase:<\/p>\n<blockquote><p>\n<code><\/p>\n<p>A note from one of our readers: Depending on your version of SSH you might also have to do the following changes:<\/p>\n<p>    * Put the public key in .ssh\/authorized_keys2<br \/>\n    * Change the permissions of .ssh to 700<br \/>\n    * Change the permissions of .ssh\/authorized_keys2 to 640<\/p>\n<p>a@A:~> ssh-keygen -t rsa<br \/>\nGenerating public\/private rsa key pair.<br \/>\nEnter file in which to save the key (\/home\/a\/.ssh\/id_rsa):<br \/>\nCreated directory '\/home\/a\/.ssh'.<br \/>\nEnter passphrase (empty for no passphrase):<br \/>\nEnter same passphrase again:<br \/>\nYour identification has been saved in \/home\/a\/.ssh\/id_rsa.<br \/>\nYour public key has been saved in \/home\/a\/.ssh\/id_rsa.pub.<br \/>\nThe key fingerprint is:<br \/>\n3e:4f:05:79:3a:9f:96:7c:3b:ad:e9:58:37:bc:37:e4 a@A<br \/>\n<\/code>\n<\/p><\/blockquote>\n<p>Now use ssh to create a directory ~\/.ssh as user b on B. (The directory may already exist, which is fine):<\/p>\n<blockquote><p><code><br \/>\na@A:~> ssh b@B mkdir -p .ssh<br \/>\nb@B's password:<br \/>\n<\/code><\/p><\/blockquote>\n<p>Finally append a&#8217;s new public key to b@B:.ssh\/authorized_keys and enter b&#8217;s password one last time:<\/p>\n<blockquote><p><code><br \/>\na@A:~> cat .ssh\/id_rsa.pub | ssh b@B 'cat >> .ssh\/authorized_keys'<br \/>\nb@B's password:<br \/>\n<\/code><\/p><\/blockquote>\n<p>From now on you can log into B as b from A as a without password:<\/p>\n<blockquote><p><code><br \/>\na@A:~> ssh b@B hostname<br \/>\nB<br \/>\n<\/code><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Your aim You want to use Linux and OpenSSH to automize your tasks. Therefore you need an automatic login from host A \/ user a to Host B \/ user b. You don&#8217;t want to enter any passwords, because you want to call ssh from a within a shell script. How to do it First [&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-437","post","type-post","status-publish","format-standard","hentry","category-kategerisiz"],"_links":{"self":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/437","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/comments?post=437"}],"version-history":[{"count":4,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/437\/revisions"}],"predecessor-version":[{"id":441,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/posts\/437\/revisions\/441"}],"wp:attachment":[{"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/media?parent=437"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/categories?post=437"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.shukko.com\/x3\/wp-json\/wp\/v2\/tags?post=437"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}