{"id":471,"date":"2012-05-18T17:25:42","date_gmt":"2012-05-18T17:25:42","guid":{"rendered":"http:\/\/shivdev.com\/blog\/?p=471"},"modified":"2013-02-20T21:54:45","modified_gmt":"2013-02-20T21:54:45","slug":"ssh-keygen-to-ssh-without-using-passwords","status":"publish","type":"post","link":"http:\/\/shivdev.com\/blog\/2012\/05\/18\/ssh-keygen-to-ssh-without-using-passwords\/","title":{"rendered":"ssh-keygen to SSH without using passwords"},"content":{"rendered":"<p>The below example will demonstrate how <strong><em>shivdev<\/em>@sk-optiplex<\/strong> can SSH to <strong><em>shivdev<\/em>@sk-redhat<\/strong> without a password. The idea is to create SSH (public\/private) keys on <strong>sk-optiplex<\/strong> and then copy the public key <strong>\/home\/shivdev\/.ssh\/<em>id_dsa.pub<\/em><\/strong> from <strong>sk-optiplex<\/strong> over to <strong>sk-redhat<\/strong> as <strong>.\/ssh\/<em>authorized_keys2<\/em><\/strong>.<\/p>\n<p><em>I&#8217;m using SSH 2 with DSA encryption, because I just couldn&#8217;t get SSH with RSA encryption to work.<\/em><\/p>\n<blockquote><p><strong>shivdev@sk-optiplex:~$<em> ssh-keygen -t dsa<\/em><\/strong><br \/>\nGenerating public\/private dsa key pair.<br \/>\nEnter file in which to save the key (\/home\/shivdev\/.ssh\/id_dsa):<br \/>\nEnter passphrase (empty for no passphrase):<br \/>\nEnter same passphrase again:<br \/>\nYour identification has been saved in \/home\/shivdev\/.ssh\/id_dsa.<br \/>\nYour public key has been saved in \/home\/shivdev\/.ssh\/id_dsa.pub.<br \/>\nThe key fingerprint is:<br \/>\n73:4a:b1:d3:d6:3c:fc:ed:c7:c6:61:18:0f:fb:06:6b shivdev@sk-optiplex<br \/>\nThe key&#8217;s randomart image is:<br \/>\n+&#8211;[ DSA 1024]&#8212;-+<br \/>\n| |<br \/>\n| |<br \/>\n| . |<br \/>\n| + + o |<br \/>\n| S + = * |<br \/>\n| . * * = |<br \/>\n| . *oo|<br \/>\n| E +=|<br \/>\n| . ..o|<br \/>\n+&#8212;&#8212;&#8212;&#8212;&#8212;&#8211;+<br \/>\n<strong>shivdev@sk-optiplex:~$ <em>scp \/home\/shivdev\/.ssh\/id_dsa.pub shivdev@sk-redhat:.ssh\/authorized_keys2<\/em><\/strong><br \/>\nThe authenticity of host &#8216;sk-redhat (sk-redhat)&#8217; can&#8217;t be established.<br \/>\nRSA key fingerprint is b4:3a:15:5d:cb:5d:7e:05:39:35:0d:9c:1f:d4:84:08.<br \/>\nAre you sure you want to continue connecting (yes\/no)? yes<br \/>\nFailed to add the host to the list of known hosts (\/home\/shivdev\/.ssh\/known_hosts).<br \/>\n<strong>shivdev@sk-redhat&#8217;s password: <\/strong><br \/>\nid_dsa.pub 100% 610 0.6KB\/s 00:00<br \/>\n<strong>shivdev@sk-optiplex:~$ <em>ssh shivdev@sk-redhat<\/em><\/strong><br \/>\nThe authenticity of host &#8216;sk-redhat (sk-redhat)&#8217; can&#8217;t be established.<br \/>\nRSA key fingerprint is b4:3a:15:5d:cb:5d:7e:05:39:35:0d:9c:1f:d4:84:08.<br \/>\nAre you sure you want to continue connecting (yes\/no)? yes<br \/>\nFailed to add the host to the list of known hosts (\/home\/shivdev\/.ssh\/known_hosts).<br \/>\nLast login: Thu May 17 14:48:01 2012 from 10.4.21.184<br \/>\n<strong>[shivdev@sk-redhat ~]$ <\/strong><\/p><\/blockquote>\n<p>As you can see after copying over the public key from <strong><em>shivdev<\/em>@sk-optiplex:.ssh\/id_dsa.pub<\/strong> over to <strong><em>shivdev<\/em>@sk-redhat:.ssh\/authorized_keys2<\/strong>, <strong><em>shivdev<\/em>@sk-optiplex<\/strong> is able to SSH into <strong><em>shivdev<\/em>@sk-redhat<\/strong> without a password.<\/p>\n<p>If you do get this error &#8220;Agent admitted failure to sign using the key.&#8221;, then you might need to run <strong>ssh-add<\/strong> or logout of the terminal and try to login again.<\/p>\n<blockquote><p>\nshivdev@sk-optiplex:~$ ssh shivdev@sk-redhat<br \/>\n<strong>Agent admitted failure to sign using the key.<\/strong><br \/>\nshivdev@sk_redhat&#8217;s password:<\/p>\n<p><strong>shivdev@sk-optiplex:~$ <em>ssh-add<\/em><\/strong><\/p>\n<p>shivdev@sk-optiplex:~$ ssh shivdev@sk-redhat<br \/>\nLast login: Thu May 17 14:51:01 2012 from 10.4.21.184<br \/>\n<strong>[shivdev@sk-redhat ~]$ <\/strong><\/p><\/blockquote>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>The below example will demonstrate how shivdev@sk-optiplex can SSH to shivdev@sk-redhat without a password. The idea is to create SSH (public\/private) keys on sk-optiplex and then copy the public key \/home\/shivdev\/.ssh\/id_dsa.pub from sk-optiplex over to sk-redhat as .\/ssh\/authorized_keys2. I&#8217;m using SSH 2 with DSA encryption, because I just couldn&#8217;t get SSH with RSA encryption to [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[13,12],"tags":[],"_links":{"self":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/471"}],"collection":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/comments?post=471"}],"version-history":[{"count":8,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/471\/revisions"}],"predecessor-version":[{"id":628,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/posts\/471\/revisions\/628"}],"wp:attachment":[{"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/media?parent=471"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/categories?post=471"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/shivdev.com\/blog\/wp-json\/wp\/v2\/tags?post=471"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}