{"id":1091,"date":"2012-05-26T21:56:48","date_gmt":"2012-05-26T21:56:48","guid":{"rendered":"http:\/\/blog.designed79.co.uk\/?p=1091"},"modified":"2014-05-13T10:03:12","modified_gmt":"2014-05-13T10:03:12","slug":"simple-ssh-connect-without-password","status":"publish","type":"post","link":"https:\/\/blog.designed79.co.uk\/?p=1091","title":{"rendered":"Simple SSH connect without password"},"content":{"rendered":"<p>&nbsp;<\/p>\n<p style=\"padding: 0px; margin: 0px 0px 10px 0px;\">Setting up passwordless SSH logins is a great way to speed up connections to regularly accessed<a style=\"background-color: inherit; color: #2266bb; font-weight: bold; text-decoration: underline;\" href=\"http:\/\/osxdaily.com\/2011\/09\/30\/remote-login-ssh-server-mac-os-x\/\">remote Macs<\/a>\u00a0and unix boxes. Because OS X doesn\u2019t include the ssh-copy-id command, you will have to use cat or scp to copy over your ssh key. This is how to set everything up, it only takes a minute or so.<\/p>\n<p style=\"padding: 0px; margin: 0px 0px 10px 0px;\">First, on the local machine you will want to generate a secure SSH key:<\/p>\n<p style=\"padding: 0px; margin: 0px 0px 10px 0px;\">\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">ssh-keygen<\/div><\/div>\n<\/p>\n<p style=\"padding: 0px; margin: 0px 0px 10px 0px;\">Walk through the key generator and set a password, the key file by default goes into ~\/.ssh\/id_rsa<\/p>\n<p style=\"padding: 0px; margin: 0px 0px 10px 0px;\">Next, you need to copy the generated key to the remote server you want to setup passwordless logins with, this is easily done with the following command string but you can use scp if you\u2019d prefer:<\/p>\n<p style=\"padding: 0px; margin: 0px 0px 10px 0px;\">\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">cat ~\/.ssh\/id_dsa.pub | ssh user@remotehost 'cat &amp;gt;&amp;gt; ~\/.ssh\/authorized_keys'<\/div><\/div>\n<\/p>\n<p style=\"padding: 0px; margin: 0px 0px 10px 0px;\">This command takes the generated SSH key from the local machine, connects to the remote host via SSH, and then uses cat to append the key file to the remote users authorized key list. Because this connects with SSH to the remote machine you will need to enter the password to use this command.<\/p>\n<p style=\"padding: 0px; margin: 0px 0px 10px 0px;\">Finally, confirm that you can now login to the remote SSH server without a password:<\/p>\n<p style=\"padding: 0px; margin: 0px 0px 10px 0px;\">\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">ssh user@remotehost.com<\/div><\/div>\n<\/p>\n<p style=\"padding: 0px; margin: 0px 0px 10px 0px;\">Assuming initial setup went as intended, you will connect to the remote machine without having to log in. You can shorten the connection steps even further by\u00a0<a style=\"background-color: inherit; color: #2266bb; font-weight: bold; text-decoration: underline;\" href=\"http:\/\/osxdaily.com\/2011\/04\/11\/use-aliases-to-create-ssh-shortcuts\/\">creating an alias in bash_profile<\/a>\u00a0so that you are only required to type a short command to immediately connect to the specified remote server.<\/p>\n<p style=\"padding: 0px; margin: 0px 0px 10px 0px;\">\n<p style=\"padding: 0px; margin: 0px 0px 10px 0px;\">Also make sure that the keys on the remote machine have the right permissions other wise the keyless login will fail<\/p>\n<p style=\"padding: 0px; margin: 0px 0px 10px 0px;\">\n<p style=\"color: #000000;\">You need to verify the permissions of the\u00a0<\/p>\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">authorized_keys<\/div><\/div>\n<p>\u00a0file and the folder \/ parent folders in which it is located.<\/p>\n<pre style=\"color: #000000;\">\n\n<div class=\"codecolorer-container text default\" style=\"overflow:auto;white-space:nowrap;\"><div class=\"text codecolorer\">chmod 700 ~\/.ssh<br \/>\nchmod 600 ~\/.ssh\/authorized_keys<\/div><\/div>\n\n<\/pre>\n<div><\/div>\n","protected":false},"excerpt":{"rendered":"<p>&nbsp; Setting up passwordless SSH logins is a great way to speed up connections to regularly accessedremote Macs\u00a0and unix boxes. Because OS [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1091","post","type-post","status-publish","format-standard","hentry","category-info-on-tech"],"_links":{"self":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1091","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1091"}],"version-history":[{"count":0,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=\/wp\/v2\/posts\/1091\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1091"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1091"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.designed79.co.uk\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1091"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}