{"id":705,"date":"2013-11-07T12:20:40","date_gmt":"2013-11-07T17:20:40","guid":{"rendered":"http:\/\/blog.xfloyd.net\/?p=705"},"modified":"2025-01-23T17:30:18","modified_gmt":"2025-01-23T22:30:18","slug":"steps-to-perform-ssh-login-without-password-using-ssh-keygen-ssh-copy-id","status":"publish","type":"post","link":"http:\/\/xfloyd.net\/blog\/?p=705","title":{"rendered":"Steps to Perform SSH Login Without Password Using ssh-keygen &#038; ssh-copy-id"},"content":{"rendered":"<p>You can login to a remote Linux server without entering password in 3 simple steps using ssky-keygen and ssh-copy-id as explained in this article.<br \/>\n<code> <\/code><br \/>\n<strong> ssh-keygen<\/strong> creates the public and private keys.<strong> ssh-copy-id<\/strong> copies the local-host\u2019s public key to the remote-host\u2019s authorized_keys file. ssh-copy-id also assigns proper permission to the remote-host\u2019s home, ~\/.ssh, and ~\/.ssh\/authorized_keys.<br \/>\n<code> <\/code><br \/>\nThis article also explains 3 minor annoyances of using ssh-copy-id and how to use ssh-copy-id along with ssh-agent.<\/p>\n<h3>Step 1: Create public and private keys using ssh-key-gen on local-host<\/h3>\n<pre>jsmith@local-host$ [Note: You are on local-host here]\n\nFor cygwin or php cli use \"<strong>ssh-keygen -m PEM -t rsa<\/strong>\"\n<strong>ssh-keygen \n<\/strong>Generating public\/private rsa key pair.\nEnter file in which to save the key (\/home\/jsmith\/.ssh\/id_rsa):[Enter key]\nEnter passphrase (empty for no passphrase): [Press enter key]\nEnter same passphrase again: [Pess enter key]\nYour identification has been saved in \/home\/jsmith\/.ssh\/id_rsa.\nYour public key has been saved in \/home\/jsmith\/.ssh\/id_rsa.pub.\nThe key fingerprint is:\n33:b3:fe:af:95:95:18:11:31:d5:de:96:2f:f2:35:f9 jsmith@local-host<\/pre>\n<h3>Step 2: Copy the public key to remote-host using ssh-copy-id<\/h3>\n<pre>jsmith@local-host$ <strong>ssh-copy-id -i ~\/.ssh\/id_rsa.pub remote-host<\/strong>\njsmith@remote-host's password:\nNow try logging into the machine, with \"ssh 'remote-host'\", and check in:\n\n.ssh\/authorized_keys\n\nto make sure we haven't added extra keys that you weren't expecting.<\/pre>\n<p><strong>Note:<\/strong> ssh-copy-id <strong>appends<\/strong> the keys to the remote-host\u2019s .ssh\/authorized_key.<br \/>\nUse this command to remove entries from known_hosts:<br \/>\n<code><br \/>\nssh-keygen -R hostname<br \/>\n<\/code><br \/>\nYou will also have to remove those entries from <strong>authorized_keys<\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>You can login to a remote Linux server without entering password in 3 simple steps using ssky-keygen and ssh-copy-id as explained in this article. ssh-keygen creates the public and private keys. ssh-copy-id copies the local-host\u2019s public key to the remote-host\u2019s authorized_keys file. ssh-copy-id also assigns proper permission to the remote-host\u2019s home, ~\/.ssh, and ~\/.ssh\/authorized_keys. This [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,10],"tags":[],"_links":{"self":[{"href":"http:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/705"}],"collection":[{"href":"http:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/xfloyd.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=705"}],"version-history":[{"count":4,"href":"http:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/705\/revisions"}],"predecessor-version":[{"id":1278,"href":"http:\/\/xfloyd.net\/blog\/index.php?rest_route=\/wp\/v2\/posts\/705\/revisions\/1278"}],"wp:attachment":[{"href":"http:\/\/xfloyd.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=705"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/xfloyd.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=705"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/xfloyd.net\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}