{"id":441,"date":"2011-03-03T06:22:37","date_gmt":"2011-03-03T12:22:37","guid":{"rendered":"http:\/\/blog.supportpro.com\/?p=441"},"modified":"2026-02-11T03:05:15","modified_gmt":"2026-02-11T09:05:15","slug":"create-ssh-key-to-access-from-one-server-to-another-remote-server-without-authentication","status":"publish","type":"post","link":"https:\/\/www.supportpro.com\/blog\/create-ssh-key-to-access-from-one-server-to-another-remote-server-without-authentication\/","title":{"rendered":"How to Set Up SSH Key Authentication Between Two Linux Servers"},"content":{"rendered":"\n<p>If you manage multiple Linux servers, logging in with a password every time can be slow and insecure. A better method is to configure <strong>SSH key-based authentication<\/strong>. This allows secure login without entering a password each time.<\/p>\n\n\n\n<p>In this guide, we will configure SSH access between two servers:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Server1<\/strong> \u2192 Your server<\/li>\n\n\n\n<li><strong>Server2<\/strong> \u2192 Remote server<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Login to Server1 as Root<\/h2>\n\n\n\n<p>First, log in to <strong>Server1<\/strong> using SSH.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ssh root@Server1<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Generate an SSH Key Pair on Server1<\/h2>\n\n\n\n<p>Instead of using DSA (which is outdated), it is recommended to use <strong>RSA or ED25519<\/strong> for better security.<\/p>\n\n\n\n<p>Run the following command on Server1:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>ssh-keygen -t rsa -b 4096<\/code><\/code><\/pre>\n\n\n\n<p>You will see:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>Generating public\/private rsa key pair. <\/code>\n<code>Enter file in which to save the key (\/root\/.ssh\/id_rsa):<\/code><\/code><\/pre>\n\n\n\n<p>Press <strong>Enter<\/strong> to accept the default location.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>Enter passphrase (empty for no passphrase):<\/code><\/code><\/pre>\n\n\n\n<p>You may:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Set a secure passphrase (recommended), or<\/li>\n\n\n\n<li>Leave it empty for passwordless automation<\/li>\n<\/ul>\n\n\n\n<p>After completion, you will see:<\/p>\n\n\n\n<p><code>Your identification has been saved in \/root\/.ssh\/id_rsa Your public key has been saved in \/root\/.ssh\/id_rsa.pub<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Create .ssh Directory on Server2<\/h2>\n\n\n\n<p>Now create the <code>.ssh<\/code> directory on <strong>Server2<\/strong>.<\/p>\n\n\n\n<p>You can do this directly from Server1:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>ssh root@Server2 \"mkdir -p \/root\/.ssh &amp;&amp; chmod 700 \/root\/.ssh\"<\/code><\/code><\/pre>\n\n\n\n<p>You will be asked for <strong>Server2\u2019s root password<\/strong>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Copy the Public Key to Server2<\/h2>\n\n\n\n<p>Now copy the public key from Server1 to Server2:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>cat \/root\/.ssh\/id_rsa.pub | ssh root@Server2 \"cat &gt;&gt; \/root\/.ssh\/authorized_keys\"<\/code><\/code><\/pre>\n\n\n\n<p>After entering Server2\u2019s password, set proper permissions:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>ssh root@Server2 \"chmod 600 \/root\/.ssh\/authorized_keys\"<\/code><\/code><\/pre>\n\n\n\n<p>This step is important. Incorrect permissions may prevent SSH login.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5: Test Passwordless SSH Login<\/h2>\n\n\n\n<p>Now try logging in from Server1 to Server2:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><code>ssh root@Server2<\/code><\/code><\/pre>\n\n\n\n<p>If everything is configured correctly, you will log in without being asked for a password.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Why Use SSH Key Authentication?<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>More secure than password login<\/li>\n\n\n\n<li>Protects against brute-force attacks<\/li>\n\n\n\n<li>Useful for automation and scripts<\/li>\n\n\n\n<li>Recommended for server-to-server communication<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Important Security Tips<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Disable password authentication after testing SSH keys<\/li>\n\n\n\n<li>Avoid using root login directly in production<\/li>\n\n\n\n<li>Use firewall rules to restrict SSH access<\/li>\n\n\n\n<li>Regularly rotate SSH keys<\/li>\n<\/ul>\n\n\n\n<p>If you need assistance configuring secure SSH access between your servers, contact <a href=\"https:\/\/www.supportpro.com\/requestquote.php\">SupportPRO Server Admin<\/a>&nbsp;for expert support and server security guidance.<\/p>\n\n\n\n<div class=\"wp-block-media-text alignwide has-media-on-the-right is-stacked-on-mobile is-vertically-aligned-center has-white-background-color has-background\"><div class=\"wp-block-media-text__content\">\n<p class=\"has-large-font-size\">Facing issues? <\/p>\n\n\n\n<p class=\"has-large-font-size\">Our technical support<br>engineers can solve it. <\/p>\n\n\n\n<!--HubSpot Call-to-Action Code --><span class=\"hs-cta-wrapper\" id=\"hs-cta-wrapper-3350a795-db50-482f-9911-301930d1b1be\"><span class=\"hs-cta-node hs-cta-3350a795-db50-482f-9911-301930d1b1be\" id=\"hs-cta-3350a795-db50-482f-9911-301930d1b1be\"><!--[if lte IE 8]><div id=\"hs-cta-ie-element\"><\/div><![endif]--><a href=\"https:\/\/cta-redirect.hubspot.com\/cta\/redirect\/2725694\/3350a795-db50-482f-9911-301930d1b1be\" ><img decoding=\"async\" class=\"hs-cta-img\" id=\"hs-cta-img-3350a795-db50-482f-9911-301930d1b1be\" style=\"border-width:0px;\" src=\"https:\/\/no-cache.hubspot.com\/cta\/default\/2725694\/3350a795-db50-482f-9911-301930d1b1be.png\"  alt=\"Contact Us today!\"\/><\/a><\/span><script charset=\"utf-8\" src=\"https:\/\/js.hscta.net\/cta\/current.js\"><\/script><script type=\"text\/javascript\"> hbspt.cta.load(2725694, '3350a795-db50-482f-9911-301930d1b1be', {\"useNewLoader\":\"true\",\"region\":\"na1\"}); <\/script><\/span><!-- end HubSpot Call-to-Action Code -->\n<\/div><figure class=\"wp-block-media-text__media\"><img fetchpriority=\"high\" decoding=\"async\" width=\"904\" height=\"931\" src=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup.png\" alt=\"guy server checkup\" class=\"wp-image-12943 size-full\" srcset=\"https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup.png 904w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-291x300.png 291w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-768x791.png 768w, https:\/\/www.supportpro.com\/blog\/wp-content\/uploads\/2022\/09\/Free-server-checkup-585x602.png 585w\" sizes=\"(max-width: 904px) 100vw, 904px\" \/><\/figure><\/div>\n","protected":false},"excerpt":{"rendered":"<p>If you manage multiple Linux servers, logging in with a password every time can be slow and insecure. A better method is to configure SSH key-based authentication. This allows secure&hellip;<\/p>\n","protected":false},"author":4,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-441","post","type-post","status-publish","format-standard","hentry","category-miscellaneous"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/441","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/comments?post=441"}],"version-history":[{"count":7,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/441\/revisions"}],"predecessor-version":[{"id":15483,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/posts\/441\/revisions\/15483"}],"wp:attachment":[{"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/media?parent=441"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/categories?post=441"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.supportpro.com\/blog\/wp-json\/wp\/v2\/tags?post=441"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}