{"id":15852,"date":"2019-03-06T15:19:46","date_gmt":"2019-03-06T15:19:46","guid":{"rendered":"https:\/\/www.hostinger.com\/tutorials\/?p=15852"},"modified":"2026-03-10T09:30:44","modified_gmt":"2026-03-10T09:30:44","slug":"how-to-setup-passwordless-ssh","status":"publish","type":"post","link":"\/ca\/tutorials\/how-to-setup-passwordless-ssh\/","title":{"rendered":"How to set up passwordless SSH on Linux"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p>Due to its reliability and security, the secure socket shell (SSH) is the most common way to interact with a remote server. However, using this protocol can be tedious since it uses a username and password by default.<\/p><p>To simplify the connection process, you can set up a passwordless SSH. Instead of the traditional username and password, this system uses an encrypted key pair to authenticate remote login.<\/p><p>In this article, we will explain how to set up passwordless SSH on Linux in four simple steps so you can connect to your server hassle-free.<\/p><p>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-prerequisites\">Prerequisites<\/h2><p>Before setting up passwordless SSH, make sure you can access your <a href=\"\/ca\/vps-hosting\">Linux virtual private server<\/a> (VPS) using a username and password. This is important since we might need to add the authentication key manually.<\/p><p>Also, you must have superuser or root access to the VPS and your local machine. Since we will edit the system-level configuration, this will avoid permission errors.<\/p><p>If you can&rsquo;t access your VPS via SSH as a superuser, check whether your hosting provider can help. For Hostinger VPS users, you have full root access by default, meaning you can freely modify any aspect of your server.<\/p><p>Hostinger users can also connect to their server <a href=\"https:\/\/support.hostinger.com\/en\/articles\/7978544-how-to-use-the-browser-terminal\" target=\"_blank\" rel=\"noopener\">using the browser terminal<\/a>. This can be an alternative to passwordless SSH since you can interact with your VPS without entering credentials as long as you can access your hosting account.<\/p><figure class=\"wp-block-image size-large\"><a class=\"hgr-tutorials-cta hgr-tutorials-cta-vps-hosting\" href=\"\/ca\/vps-hosting\" target=\"_blank\" rel=\"noreferrer noopener\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"300\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2023\/02\/VPS-hosting-banner.png\/w=1024,h=1024,fit=scale-down\" alt=\"\" class=\"wp-image-77934\"  sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><h3 class=\"wp-block-heading\" id=\"h-checking-if-ssh-keys-exist\">Checking if SSH keys exist<\/h3><p>If you are working with systems other than yours, such as a client&rsquo;s computer, check whether it already has passwordless SSH set up.<\/p><p><div class=\"announcement-block announcement-block--important\">\n            <span class=\"announcement-block__heading\">\n                <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                    <path fill-rule=\"evenodd\" clip-rule=\"evenodd\"\n                          d=\"M12 22.5C17.799 22.5 22.5 17.799 22.5 12C22.5 6.20101 17.799 1.5 12 1.5C6.20101 1.5 1.5 6.20101 1.5 12C1.5 17.799 6.20101 22.5 12 22.5ZM13.637 7.65198C13.637 6.74791 12.9041 6.01501 12 6.01501C11.0959 6.01501 10.363 6.74791 10.363 7.65198C10.5335 9.53749 10.875 13.383 10.875 13.383C10.875 14.0043 11.3787 14.508 12 14.508C12.6213 14.508 13.125 14.0043 13.125 13.383V13.38L13.637 7.65198ZM11.9927 15.714C11.3714 15.714 10.8677 16.2177 10.8677 16.839C10.8677 17.4603 11.3714 17.964 11.9927 17.964H12.0073C12.6286 17.964 13.1323 17.4603 13.1323 16.839C13.1323 16.2177 12.6286 15.714 12.0073 15.714H11.9927Z\"\n                          fill=\"#FEA419\"\/>\n                <\/svg>\n                Important\n            <\/span>\n            <p class=\"announcement-block__content\">\n                <strong>Important!<\/strong> Setting up passwordless SSH on a local system that already has it will replace the existing authentication keys. This can cause connectivity issues that prevent you from accessing the previously paired server.\n            <\/p><\/div>\n\n\n\n<\/p><p>To check if your local system has passwordless SSH enabled, open Terminal and run this command:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ls -al ~\/.ssh\/id_*.pub<\/pre><p>If you see the <strong>.pub <\/strong>file listed, which contains the authorization keys, the passwordless SSH is already active.<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"6a58a5f1754fa\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a58a5f1754fa\" class=\"aligncenter size-large is-resized wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1460\" height=\"73\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/03\/ssh-key-pub-file-listed-on-terminal.png\/w=1024,h=1024,fit=scale-down\" alt=\"SSH key PUB file listed on Terminal\" class=\"wp-image-122699\" style=\"width:843px;height:auto\"  sizes=\"auto, (max-width: 1460px) 100vw, 1460px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Otherwise, this output should show up:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ls: cannot access \/users\/appsadm\/.ssh\/id_*.pub: No such file or directory<\/pre><h2 class=\"wp-block-heading\" id=\"h-setting-up-passwordless-ssh\">Setting up passwordless SSH<\/h2><p>After ensuring you meet all the prerequisites, follow these steps to set up passwordless SSH.<\/p><h3 class=\"wp-block-heading\" id=\"h-1-generate-ssh-keys\">1. Generate SSH keys<\/h3><p>To begin, let&rsquo;s <a href=\"\/ca\/tutorials\/ssh\/how-to-set-up-ssh-keys\/\">generate SSH keys<\/a> &ndash; credentials that will replace the default username and password as the authentication token. Here&rsquo;s how to do so:<\/p><ol class=\"wp-block-list\">\n<li>Open your local computer&rsquo;s Terminal.<\/li>\n\n\n\n<li>Enter the following command to generate the SSH keys. You can use either <strong>rsa<\/strong> or <strong>ed25519<\/strong> encryption:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ssh-keygen -t ed25519<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Hit <strong>Enter <\/strong>to save the SSH keys in the default location, which is <strong>~\/.ssh\/<\/strong>. Alternatively, you can specify another location and hit <strong>Enter<\/strong> to confirm.<\/li>\n\n\n\n<li>Optionally, add a passphrase to encrypt your SSH keys. Hit <strong>Enter<\/strong> if you want to skip it.<\/li>\n<\/ol><p>Your command-line application should print the SSH keys&rsquo; randomart image and token. The SSH keys are automatically saved in the path you specified during the generation process earlier into two files &ndash; <strong>id_ed25519<\/strong> and <strong>id_25519.pub<\/strong>.<\/p><p>        <div class=\"protip\">\n            <div class=\"protip__heading\">\n                <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                    <path d=\"M1.49234 23.5024C1.23229 23.5024 0.972242 23.4024 0.782206 23.2123C0.562165 22.9923 0.452144 22.6822 0.502153 22.3722C0.562165 21.9221 1.14227 17.9113 3.00262 16.351C3.63274 15.8209 4.43289 15.5509 5.26305 15.5609C6.09321 15.5909 6.87335 15.9109 7.47347 16.4911C8.6937 17.6913 8.76371 19.6717 7.6435 20.9919C6.0832 22.8523 2.08245 23.4324 1.63237 23.4924C1.59236 23.4924 1.54235 23.4924 1.50234 23.4924L1.49234 23.5024ZM5.16303 17.5613C4.84297 17.5613 4.53291 17.6713 4.29287 17.8813C3.60274 18.4614 3.07264 19.9317 2.75258 21.242C4.06282 20.9219 5.5331 20.3918 6.11321 19.7017C6.55329 19.1716 6.54329 18.3814 6.0832 17.9213C5.85316 17.7013 5.5431 17.5713 5.20304 17.5613C5.19304 17.5613 5.17303 17.5613 5.16303 17.5613ZM11.7243 21.8821C11.4942 21.8821 11.2642 21.8021 11.0841 21.652C10.8541 21.462 10.7241 21.1819 10.7241 20.8819V15.9109L8.08358 13.2705H3.11264C2.81259 13.2705 2.53254 13.1404 2.3425 12.9104C2.15246 12.6803 2.07245 12.3803 2.12246 12.0902C2.19247 11.7102 2.84259 8.36953 4.70294 7.12929C6.33325 6.04909 8.96375 6.49918 10.244 6.80923C11.5442 4.96889 13.2546 3.4286 15.2349 2.33839C17.4553 1.11816 19.9858 0.518051 22.4963 0.498047C23.0464 0.498047 23.4865 0.948132 23.4865 1.49824C23.4865 5.0389 22.3763 9.97983 17.1753 13.7605C17.4853 15.0408 17.9354 17.6613 16.8552 19.2816C15.615 21.1419 12.2744 21.7921 11.8943 21.8621C11.8343 21.8721 11.7743 21.8821 11.7143 21.8821H11.7243ZM12.7245 16.181V19.6016C13.7146 19.2916 14.7948 18.7915 15.2049 18.1814C15.675 17.4812 15.605 16.091 15.385 14.9008C14.5248 15.3808 13.6346 15.8109 12.7245 16.181ZM9.66388 12.0302L11.9643 14.3307C13.1845 13.8306 14.3648 13.2204 15.485 12.5103C19.9358 9.51974 21.2361 5.60901 21.4561 2.53843C19.6157 2.67846 17.8254 3.20856 16.2051 4.09872C14.2847 5.14892 12.6544 6.68921 11.4942 8.54956C10.7841 9.65977 10.174 10.82 9.66388 12.0302ZM4.39289 11.2701H7.81353C8.1936 10.3599 8.63368 9.46974 9.11377 8.60957C7.92355 8.38953 6.51329 8.31952 5.81315 8.78961C5.19304 9.19968 4.70294 10.3099 4.39289 11.2701Z\" fill=\"#673DE6\"\/>\n                <\/svg>\n                <p class=\"protip__title\">\n                    Pro tip                <\/p>\n            <\/div>\n            <p class=\"protip__content\">If you use Windows, you can <a href=\"\/ca\/tutorials\/how-to-generate-ssh-keys-on-putty\/\">generate the keys using an SSH client like PuTTY.<\/a><\/p>\n                    <\/div>\n        \n\n\n\n<\/p><h3 class=\"wp-block-heading\" id=\"h-2-copy-the-public-key-to-the-server\">2. Copy the public key to the server<\/h3><p>Now that you have obtained the SSH keys, copy the public one to your server.<\/p><p><strong>Method 1: Using the ssh-copy-id command<\/strong><\/p><p>The first method is the easiest and quickest one. To do so, simply enter the following command on your local machine&rsquo;s Terminal:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ssh-copy-id remote_username@remote_IP_Address<\/pre><p>Replace the<strong> remote_username<\/strong> with the user account on which you wish to enable passwordless SSH. Also, change <strong>remote_IP_Address <\/strong>to your VPS&rsquo;s actual IP address.<\/p><p>Then, enter the user password. Once the setup is complete, your server will close the remote connection.<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"6a58a5f178b37\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a58a5f178b37\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1648\" height=\"288\" data-wp-class--hide=\"state.isContentHidden\" data-wp-class--show=\"state.isContentVisible\" data-wp-init=\"callbacks.setButtonStyles\" data-wp-on--click=\"actions.showLightbox\" data-wp-on--load=\"callbacks.setButtonStyles\" data-wp-on-window--resize=\"callbacks.setButtonStyles\" src=\"https:\/\/imagedelivery.net\/LqiWLm-3MGbYHtFuUbcBtA\/wp-content\/uploads\/sites\/2\/2019\/03\/copy-id-confirmation.png\/w=1024,h=1024,fit=scale-down\" alt=\"Copy-id confirmation\n\" class=\"wp-image-122700\"  sizes=\"auto, (max-width: 1648px) 100vw, 1648px\" \/><button class=\"lightbox-trigger\" type=\"button\" aria-haspopup=\"dialog\" aria-label=\"Enlarge\" data-wp-init=\"callbacks.initTriggerButton\" data-wp-on--click=\"actions.showLightbox\" data-wp-style--right=\"state.imageButtonRight\" data-wp-style--top=\"state.imageButtonTop\">\n\t\t\t<svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"12\" height=\"12\" fill=\"none\" viewbox=\"0 0 12 12\">\n\t\t\t\t<path fill=\"#fff\" d=\"M2 0a2 2 0 0 0-2 2v2h1.5V2a.5.5 0 0 1 .5-.5h2V0H2Zm2 10.5H2a.5.5 0 0 1-.5-.5V8H0v2a2 2 0 0 0 2 2h2v-1.5ZM8 12v-1.5h2a.5.5 0 0 0 .5-.5V8H12v2a2 2 0 0 1-2 2H8Zm2-12a2 2 0 0 1 2 2v2h-1.5V2a.5.5 0 0 0-.5-.5H8V0h2Z\"><\/path>\n\t\t\t<\/svg>\n\t\t<\/button><\/figure><\/div><p>Note that passwordless SSH will only be active for the user you specify in the <strong>ssh-copy-id <\/strong>command. For example, you run the following command:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ssh-copy-id admin123@123.123.123.123<\/pre><p>This means the passwordless SSH will only work for <strong>admin123<\/strong>, but not other users. Similarly, you won&rsquo;t be able to log in from another client machine since it doesn&rsquo;t have the key pair.<\/p><p><div class=\"announcement-block announcement-block--important\">\n            <span class=\"announcement-block__heading\">\n                <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                    <path fill-rule=\"evenodd\" clip-rule=\"evenodd\"\n                          d=\"M12 22.5C17.799 22.5 22.5 17.799 22.5 12C22.5 6.20101 17.799 1.5 12 1.5C6.20101 1.5 1.5 6.20101 1.5 12C1.5 17.799 6.20101 22.5 12 22.5ZM13.637 7.65198C13.637 6.74791 12.9041 6.01501 12 6.01501C11.0959 6.01501 10.363 6.74791 10.363 7.65198C10.5335 9.53749 10.875 13.383 10.875 13.383C10.875 14.0043 11.3787 14.508 12 14.508C12.6213 14.508 13.125 14.0043 13.125 13.383V13.38L13.637 7.65198ZM11.9927 15.714C11.3714 15.714 10.8677 16.2177 10.8677 16.839C10.8677 17.4603 11.3714 17.964 11.9927 17.964H12.0073C12.6286 17.964 13.1323 17.4603 13.1323 16.839C13.1323 16.2177 12.6286 15.714 12.0073 15.714H11.9927Z\"\n                          fill=\"#FEA419\"\/>\n                <\/svg>\n                Important\n            <\/span>\n            <p class=\"announcement-block__content\">\n                <strong>Important!<\/strong> To enable passwordless SSH for multiple devices or users, you must generate new keys for each of them.\n            <\/p><\/div>\n\n\n\n<\/p><p><strong>Method 2: Copying the private key using SSH<\/strong><\/p><p>You can copy your private key via SSH using a string of commands. Remember to replace the <strong>remote_username <\/strong>and<strong> remote_ip_address<\/strong> with their actual values:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cat ~\/.ssh\/id_ed25519.pub | ssh remote_username@remote_ip_address \"mkdir -p ~\/.ssh &amp;&amp; chmod 700 ~\/.ssh &amp;&amp; cat &gt;&gt; ~\/.ssh\/authorized_keys &amp;&amp; chmod 600 ~\/.ssh\/authorized_keys\"&nbsp;<\/pre><p>Your command-line interface should ask for the user&rsquo;s password to initiate the connection.<\/p><p>This command fetches the content of your <strong>id_ed25519.pub<\/strong> file, connects to the server via SSH using the specified user, and adds the public key to the remote system&rsquo;s <strong>authorized_keys <\/strong>folder.<\/p><p><strong>Method 3: Manually copying the private key<\/strong><\/p><p>If you can&rsquo;t copy the private key using the remote command, add the credential manually. To do so, follow these steps:<\/p><ol class=\"wp-block-list\">\n<li>Open your local system&rsquo;s command-line application and run this command. Replace <strong>~\/.ssh\/id_25519.pub <\/strong>with the correct path if you are using a non-default location:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cat ~\/.ssh\/id_25519.pub&nbsp;<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>Your command-line shell will output the public key. Copy and save it in a safe location.<\/li>\n\n\n\n<li>Connect to your remote machine via SSH using the below command. You can also <a href=\"\/ca\/tutorials\/how-to-use-putty-ssh\/\">connect via SSH using PuTTY<\/a>:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ssh remote_username@remote_ip_address<\/pre><ol start=\"4\" class=\"wp-block-list\">\n<li>Once connected, create the .ssh directory using this command:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mkdir -p ~\/.ssh<\/pre><ol start=\"5\" class=\"wp-block-list\">\n<li>Open your remote system&rsquo;s<strong> .ssl\/authorized_keys<\/strong> file using this command:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">nano ~\/.ssh\/authorized_keys<\/pre><ol start=\"6\" class=\"wp-block-list\">\n<li>Paste the SSH key you copied earlier.&nbsp;<\/li>\n\n\n\n<li>Hit <strong>Ctrl + X<\/strong>, <strong>Y<\/strong>, and <strong>Enter<\/strong> to save the changes.<\/li>\n\n\n\n<li>Set the correct permissions to make sure your system can read the SSH public key while preventing unauthorized users from opening it.<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">chmod 700 ~\/.ssh &amp;&amp; chmod 600 ~\/.ssh\/authorized_keys<\/pre><p>        <div class=\"protip\">\n            <div class=\"protip__heading\">\n                <svg width=\"24\" height=\"24\" viewBox=\"0 0 24 24\" fill=\"none\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\">\n                    <path d=\"M1.49234 23.5024C1.23229 23.5024 0.972242 23.4024 0.782206 23.2123C0.562165 22.9923 0.452144 22.6822 0.502153 22.3722C0.562165 21.9221 1.14227 17.9113 3.00262 16.351C3.63274 15.8209 4.43289 15.5509 5.26305 15.5609C6.09321 15.5909 6.87335 15.9109 7.47347 16.4911C8.6937 17.6913 8.76371 19.6717 7.6435 20.9919C6.0832 22.8523 2.08245 23.4324 1.63237 23.4924C1.59236 23.4924 1.54235 23.4924 1.50234 23.4924L1.49234 23.5024ZM5.16303 17.5613C4.84297 17.5613 4.53291 17.6713 4.29287 17.8813C3.60274 18.4614 3.07264 19.9317 2.75258 21.242C4.06282 20.9219 5.5331 20.3918 6.11321 19.7017C6.55329 19.1716 6.54329 18.3814 6.0832 17.9213C5.85316 17.7013 5.5431 17.5713 5.20304 17.5613C5.19304 17.5613 5.17303 17.5613 5.16303 17.5613ZM11.7243 21.8821C11.4942 21.8821 11.2642 21.8021 11.0841 21.652C10.8541 21.462 10.7241 21.1819 10.7241 20.8819V15.9109L8.08358 13.2705H3.11264C2.81259 13.2705 2.53254 13.1404 2.3425 12.9104C2.15246 12.6803 2.07245 12.3803 2.12246 12.0902C2.19247 11.7102 2.84259 8.36953 4.70294 7.12929C6.33325 6.04909 8.96375 6.49918 10.244 6.80923C11.5442 4.96889 13.2546 3.4286 15.2349 2.33839C17.4553 1.11816 19.9858 0.518051 22.4963 0.498047C23.0464 0.498047 23.4865 0.948132 23.4865 1.49824C23.4865 5.0389 22.3763 9.97983 17.1753 13.7605C17.4853 15.0408 17.9354 17.6613 16.8552 19.2816C15.615 21.1419 12.2744 21.7921 11.8943 21.8621C11.8343 21.8721 11.7743 21.8821 11.7143 21.8821H11.7243ZM12.7245 16.181V19.6016C13.7146 19.2916 14.7948 18.7915 15.2049 18.1814C15.675 17.4812 15.605 16.091 15.385 14.9008C14.5248 15.3808 13.6346 15.8109 12.7245 16.181ZM9.66388 12.0302L11.9643 14.3307C13.1845 13.8306 14.3648 13.2204 15.485 12.5103C19.9358 9.51974 21.2361 5.60901 21.4561 2.53843C19.6157 2.67846 17.8254 3.20856 16.2051 4.09872C14.2847 5.14892 12.6544 6.68921 11.4942 8.54956C10.7841 9.65977 10.174 10.82 9.66388 12.0302ZM4.39289 11.2701H7.81353C8.1936 10.3599 8.63368 9.46974 9.11377 8.60957C7.92355 8.38953 6.51329 8.31952 5.81315 8.78961C5.19304 9.19968 4.70294 10.3099 4.39289 11.2701Z\" fill=\"#673DE6\"\/>\n                <\/svg>\n                <p class=\"protip__title\">\n                    &#128161; Pro tip                <\/p>\n            <\/div>\n            <p class=\"protip__content\">On Hostinger VPS plans, you can ask <strong>Kodee<\/strong>, our AI-powered assistant, to list all SSH public keys added to your VPS. Simply ask a question like \"What SSH public keys are added to my VPS?\" and Kodee will provide the list for you.<\/p>\n                    <\/div>\n        \n\n\n\n<\/p><h3 class=\"wp-block-heading\" id=\"h-3-verify-key-based-authentication\">3. Verify key-based authentication<\/h3><p>Let&rsquo;s check whether the SSH passwordless login works properly. To do so, simply run the following in your local system&rsquo;s command-line application:<\/p><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ssh username@ip_address<\/pre><p>You should automatically log in to the server as the specified user. If your command line asks for the password, check if you use the right account. Should the issue persist, try copying the SSH keys again.<\/p><p>If you enable a passphrase during the key generation process, you must enter it every time you log in. You can skip this process by caching the credential using an SSH agent. Here&rsquo;s how to do so:<\/p><ol class=\"wp-block-list\">\n<li>Open your local system&rsquo;s command-line application.<\/li>\n\n\n\n<li>Run the following command to start the SSH agent:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">eval `ssh-agent -s`<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Cache your SSH key using this command. Remember to use the correct path if you change the default location :<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">ssh-add ~\/.ssh\/id_ed25519&nbsp;&nbsp;<\/pre><p>Now, when accessing your server via SSH, your command-line application shouldn&rsquo;t ask for a passphrase anymore.<\/p><h3 class=\"wp-block-heading\" id=\"h-4-disable-password-based-ssh-login\">4. Disable password-based SSH login<\/h3><p>Although optional, it is advisable to disable password-based SSH login after setting up the authentication keys. This minimizes potential points of entry for cybercriminals, improving your <a href=\"\/ca\/tutorials\/vps-security\/\">VPS security<\/a>.<\/p><p>Note that after disabling password-based login, you can only access your VPS using the computer on which you set up the SSH keys. To avoid getting locked out of your account, consider the following:<\/p><ul class=\"wp-block-list\">\n<li>Make sure your passwordless SSH works properly.<\/li>\n\n\n\n<li>Store your private key file, which resides on your local machine by default, in multiple locations. We highly recommend using a cloud-based, encrypted platform like <strong>1Password<\/strong> or <strong>NordPass<\/strong>.&nbsp;<\/li>\n\n\n\n<li>Set up SSH keys on all systems that you will use to access your VPS. However, make sure these machines are secure.<\/li>\n<\/ul><p>Follow these steps to <a href=\"\/ca\/tutorials\/vps\/how-to-disable-ssh-password-authentication-on-vps\/\">disable your password-based SSH login<\/a> on your VPS:<\/p><ol class=\"wp-block-list\">\n<li>Log in to your server as root or a superuser. If you have done so, skip this step.&nbsp;<\/li>\n\n\n\n<li>Open the SSH configuration file using a text editor like Nano:<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo nano \/etc\/ssh\/sshd_config<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Find these settings and change the value according to the following example.<strong> <\/strong>If they start with a hash (<strong>#<\/strong>) sign, remove it to make sure the settings are active.&nbsp;<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">PasswordAuthentication no\n\nChallengeResponseAuthentication no\n\nPubkeyAuthentication yes\n\nPermitRootLogin prohibit-password<\/pre><ol start=\"4\" class=\"wp-block-list\">\n<li>Press <strong>Ctrl + X<\/strong>, <strong>Y<\/strong>, and<strong> Enter <\/strong>to save the changes.&nbsp;<\/li>\n\n\n\n<li>Restart the SSH service using this command.<\/li>\n<\/ol><pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">sudo systemctl restart sshd<\/pre><p>Now, you can only log in to your server using the SSH keys.<\/p><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>Configuring passwordless SSH enables you to connect to your remote server more securely and easily. In this tutorial, we have explained how to set it up on a Linux server. Here are the steps:<\/p><ol class=\"wp-block-list\">\n<li>Open your local system&rsquo;s Terminal or PuTTY and generate the SSH key pair.<\/li>\n\n\n\n<li>Copy the public key to your remote server using commands or manually via SSH.&nbsp;<\/li>\n\n\n\n<li>Verify the key-based login by connecting to your server.<\/li>\n\n\n\n<li>Disable your server&rsquo;s password-based login by editing the SSHD file.&nbsp;<\/li>\n<\/ol><p>Repeat the steps if you wish to set up the passwordless login for another user or machine. Also, store your private SSH key in a safe, encrypted platform like 1Password to prevent you from getting locked out of your server.<\/p><h2 class=\"wp-block-heading\" id=\"h-passwordless-ssh-faq\">Passwordless SSH FAQ<\/h2><div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1739478841147\"><h3 class=\"schema-faq-question\">What is the best key type for passwordless SSH?<\/h3> <p class=\"schema-faq-answer\">Two types of SSH keys &ndash; <strong>RSA<\/strong> and <strong>ED25519<\/strong> &ndash; have their own pros and cons. RSA is compatible with more operating systems, especially older ones. Meanwhile, <a href=\"https:\/\/docs.gitlab.com\/ee\/user\/ssh.html#ed25519-ssh-keys\" target=\"_blank\" rel=\"noopener\">ED25519 is more secure<\/a> and efficient because it is shorter.&nbsp;<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1739478846403\"><h3 class=\"schema-faq-question\">Can I set up passwordless SSH for multiple servers?<\/h3> <p class=\"schema-faq-answer\">Yes, you can set up passwordless SSH for multiple servers. Simply generate the authentication keys for each remote system and upload the public key to them. You can also set passwordless SSH for multiple local machines to access the same server.&nbsp;&nbsp;<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1739478854025\"><h3 class=\"schema-faq-question\">Is it safe to disable password authentication entirely?<\/h3> <p class=\"schema-faq-answer\">Yes, disabling password authentication on your VPS is generally safe since SSH keys are more difficult to crack, making them more secure. However, remember to safeguard your SSH keys and store them on a platform like 1Password to avoid getting locked out of your server.<\/p> <\/div> <\/div>\n","protected":false},"excerpt":{"rendered":"<p>Due to its reliability and security, the secure socket shell (SSH) is the most common way to interact with a remote server. However, using this protocol can be tedious since it uses a username and password by default. To simplify the connection process, you can set up a passwordless SSH. Instead of the traditional username [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ca\/tutorials\/how-to-setup-passwordless-ssh\/\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":337,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to set up passwordless SSH login","rank_math_description":"Learn how to set up passwordless SSH on Linux: 1. Generate SSH keys; 2. Copy the public key to the server; 3. Verify SSH keys + more.","rank_math_focus_keyword":"passwordless ssh","footnotes":""},"categories":[22703,22699],"tags":[],"class_list":["post-15852","post","type-post","status-publish","format-standard","hentry","category-managing-monitoring-and-security","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/how-to-setup-passwordless-ssh","default":0},{"locale":"fr-FR","link":"https:\/\/www.hostinger.com\/fr\/tutoriels\/comment-configurer-ssh-sans-mot-de-passe","default":0},{"locale":"es-ES","link":"https:\/\/www.hostinger.com\/es\/tutoriales\/configurar-ssh-sin-contrasena-linux","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/ssh-tanpa-password","default":0},{"locale":"en-GB","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/how-to-setup-passwordless-ssh","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-setup-passwordless-ssh\/","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-setup-passwordless-ssh\/","default":0},{"locale":"es-MX","link":"https:\/\/www.hostinger.com\/mx\/tutoriales\/configurar-ssh-sin-contrasena-linux","default":0},{"locale":"es-CO","link":"https:\/\/www.hostinger.com\/co\/tutoriales\/configurar-ssh-sin-contrasena-linux","default":0},{"locale":"es-AR","link":"https:\/\/www.hostinger.com\/ar\/tutoriales\/configurar-ssh-sin-contrasena-linux","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/how-to-setup-passwordless-ssh","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-setup-passwordless-ssh","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-setup-passwordless-ssh","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-setup-passwordless-ssh","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/15852","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/users\/337"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/comments?post=15852"}],"version-history":[{"count":21,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/15852\/revisions"}],"predecessor-version":[{"id":139841,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/15852\/revisions\/139841"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/media?parent=15852"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/categories?post=15852"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/tags?post=15852"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}