{"id":926,"date":"2021-06-14T14:26:14","date_gmt":"2021-06-14T08:56:14","guid":{"rendered":"https:\/\/techieshouts.com\/?p=926"},"modified":"2022-08-09T19:04:00","modified_gmt":"2022-08-09T13:34:00","slug":"creating-passwordless-ssh-between-linux-servers","status":"publish","type":"post","link":"https:\/\/techieshouts.com\/home\/creating-passwordless-ssh-between-linux-servers\/","title":{"rendered":"Creating passwordless SSH between Linux servers"},"content":{"rendered":"\n<p>In this post, we will see how to establish a passwordless SSH connection between two Linux machines. <\/p>\n\n\n\n<p>This can be done by using the Public and Private keys. Once the keys are set up, the authentication will be done using these keys instead of the password.<\/p>\n\n\n\n<p>Let us consider there are two Linux machines\/servers ServerA and ServerB. We will establish the passwordless connection from ServerA to ServerB<\/p>\n\n\n\n<p>Here are the steps you need to follow to setup the passwordless SSH<\/p>\n\n\n\n<h4>Step 1 &#8211; Creating the key<\/h4>\n\n\n\n<p>Log in to the ServerA and get into the .ssh directory. Now run the below command and hit enters multiple times<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"classic\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ssh-keygen -t rsa<\/pre>\n\n\n\n<p>This will create two files meaning two keys. id_rsa and id_rsa.pub. The one with &#8220;.pub&#8221; extension is the public key<\/p>\n\n\n\n<h4>Step 2 &#8211; Setup public key in target server<\/h4>\n\n\n\n<p>Log in to the ServerB and check for the presence of &#8220;authorized_keys&#8221; file under the ~\/.ssh folder. If it is not there, create it. After that copy the contents of id_rsa.pub file from the ServerA and put it in the authorized_keys file of ServerB<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"classic\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">user@ServerA $ cd ~\/.ssh\nuser@ServerA $ cat id_rsa.pub\n\n.....\nuser@ServerB $ cd ~\/.ssh\nuser@ServerB $ vim authorized_keys\n\n.....<\/pre>\n\n\n\n<p>After you copied the contents of the public key from ServerA to the authorized_keys file in ServerB, you will be able to now connect ServerB from ServerA without any password. <\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"shell\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">user@ServerA $ ssh user@serverB\n#The above command will log the user into the ServerB without any password<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In this post, we will see how to establish a passwordless SSH connection between two Linux machines. This can be done by using the Public and Private keys. Once the keys are set up, the authentication will be done using these keys instead of the password. Let us consider there are two Linux machines\/servers ServerA\u2026 <span class=\"read-more\"><a href=\"https:\/\/techieshouts.com\/home\/creating-passwordless-ssh-between-linux-servers\/\">Read More &raquo;<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16,8],"tags":[134,132,133],"_links":{"self":[{"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/posts\/926"}],"collection":[{"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/comments?post=926"}],"version-history":[{"count":2,"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/posts\/926\/revisions"}],"predecessor-version":[{"id":941,"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/posts\/926\/revisions\/941"}],"wp:attachment":[{"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/media?parent=926"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/categories?post=926"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techieshouts.com\/home\/wp-json\/wp\/v2\/tags?post=926"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}