{"id":440,"date":"2015-10-14T11:10:37","date_gmt":"2015-10-14T11:10:37","guid":{"rendered":"http:\/\/www.scmgalaxy.com\/tutorials\/2015\/10\/14\/steps-to-perform-ssh-login-without-password-using-ssh-keygen-and-ssh-copy-id\/"},"modified":"2017-12-15T22:26:38","modified_gmt":"2017-12-15T22:26:38","slug":"steps-to-perform-ssh-login-without-password-using-ssh-keygen-and-ssh-copy-id","status":"publish","type":"post","link":"https:\/\/www.devopsschool.com\/blog\/steps-to-perform-ssh-login-without-password-using-ssh-keygen-and-ssh-copy-id\/","title":{"rendered":"Steps to Perform SSH Login Without Password Using ssh-keygen and ssh-copy-id"},"content":{"rendered":"<div><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-3069 size-full\" src=\"http:\/\/www.scmgalaxy.com\/tutorials\/wp-content\/uploads\/2015\/10\/ssh-login-without-password.png\" alt=\"SSH Login Without Password\" width=\"600\" height=\"400\" srcset=\"https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2015\/10\/ssh-login-without-password.png 600w, https:\/\/www.devopsschool.com\/blog\/wp-content\/uploads\/2015\/10\/ssh-login-without-password-300x200.png 300w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/div>\n<div><strong>Steps to Perform SSH Login Without Password Using ssh-keygen and ssh-copy-id<\/strong><\/div>\n<div><\/div>\n<div><strong>Step 1: Generate the keys<\/strong><\/div>\n<div>&gt; ssh-keygen<\/div>\n<div>or<\/div>\n<div>&gt; ssh-keygen -t rsa<\/div>\n<div><\/div>\n<div><strong>Step 2: Copy the public key to remote machine<\/strong><\/div>\n<div>&gt; ssh-copy-id -i ~\/.ssh\/id_rsa.pub remote-host<\/div>\n<div>or<\/div>\n<div>&gt; ssh-copy-id -i ~\/.ssh\/id_rsa.pub user@hostname.example.com<\/div>\n<div><\/div>\n<div>Alternatively, you can paste in the keys using SSH:<\/div>\n<div>cat ~\/.ssh\/id_rsa.pub | ssh user@123.45.56.78 &#8220;mkdir -p ~\/.ssh &amp;&amp; cat &gt;&gt; \u00a0~\/.ssh\/authorized_keys&#8221;<\/div>\n<div><\/div>\n<div><strong>Step 3: Login to remote machine<\/strong><\/div>\n<div>&gt; ssh remote-host<\/div>\n<div><\/div>\n<div>If you have loaded keys to the ssh-agent using the ssh-add, then ssh-copy-id will get the keys from the ssh-agent to copy to the remote-host. i.e, it copies the keys provided by ssh-add -L command to the remote-host, when you don\u2019t pass option -i to the ssh-copy-id.<\/div>\n<div><\/div>\n<div>&gt; ssh-add<\/div>\n<div>&gt; ssh-add \/Users\/rajesh.kumar\/.ssh\/id_rsa<\/div>\n<div><\/div>\n<div><strong>Step 4: Optional Step Four\u2014Disable the Password for Root Login<\/strong><\/div>\n<div><\/div>\n<div>&gt; sudo nano \/etc\/ssh\/sshd_config<\/div>\n<div>Put the changes into effect:<\/div>\n<div>&gt; reload ssh<\/div>\n<div><\/div>\n<div>Within that file, find the line that includes PermitRootLogin and modify it to ensure that users can only connect with their SSH key:<\/div>\n<div>&gt; PermitRootLogin without-password<\/div>\n<div><\/div>\n<div><strong>More Articles<\/strong><\/div>\n<div><a href=\"http:\/\/community.scmgalaxy.com\/blog\/view\/40844\/how-to-scp-ssh-and-rsync-without-prompting-for-password-using-openssh\" target=\"_blank\" rel=\"noopener\">http:\/\/community.scmgalaxy.com\/blog\/view\/40844\/how-to-scp-ssh-and-rsync-without-prompting-for-password-using-openssh<\/a><\/div>\n<div><a href=\"http:\/\/manpages.ubuntu.com\/manpages\/lucid\/man1\/ssh-copy-id.1.html\" target=\"_blank\" rel=\"noopener\">http:\/\/manpages.ubuntu.com\/manpages\/lucid\/man1\/ssh-copy-id.1.html<\/a><\/div>\n<div>\n<p><a href=\"Forum\/34-shell-script\/501-file-copying-and-transfer-between-two-machine.html\">http:\/\/www.scmgalaxy.com\/Forum\/34-shell-script\/501-file-copying-and-transfer-between-two-machine.html<\/a><\/p>\n<\/div>\n<div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Steps to Perform SSH Login Without Password Using ssh-keygen and ssh-copy-id Step 1: Generate the keys &gt; ssh-keygen or &gt; ssh-keygen -t rsa Step 2: Copy the public key to&#8230; <\/p>\n","protected":false},"author":1,"featured_media":3069,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_joinchat":[],"footnotes":""},"categories":[49],"tags":[545,897,534,901,896,898,902,900,899,732],"class_list":["post-440","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-general","tag-how","tag-login","tag-password","tag-remote-machine","tag-ssh","tag-ssh-login","tag-ssh-login-without-password","tag-ssh-copy-id","tag-ssh-keygen","tag-steps"],"_links":{"self":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/440","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/comments?post=440"}],"version-history":[{"count":2,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/440\/revisions"}],"predecessor-version":[{"id":3070,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/posts\/440\/revisions\/3070"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media\/3069"}],"wp:attachment":[{"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/media?parent=440"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/categories?post=440"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.devopsschool.com\/blog\/wp-json\/wp\/v2\/tags?post=440"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}