{"id":3836,"date":"2023-11-22T16:22:10","date_gmt":"2023-11-22T08:22:10","guid":{"rendered":"https:\/\/www.servergigabit.com\/guide\/?post_type=kb&#038;p=3836"},"modified":"2025-12-26T15:31:26","modified_gmt":"2025-12-26T07:31:26","slug":"how-to-use-ssh-keys-with-your-server-gigabits-server","status":"publish","type":"kb","link":"https:\/\/www.servergigabit.com\/guide\/kb\/how-to-use-ssh-keys-with-your-server-gigabits-server","title":{"rendered":"How to Use SSH Keys with Your Server Gigabit&#8217;s Server?"},"content":{"rendered":"<p><img fetchpriority=\"high\" decoding=\"async\" class=\"alignnone wp-image-3837\" src=\"https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/aaaaaaaa-300x169.jpeg\" alt=\"\" width=\"692\" height=\"390\" srcset=\"https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/aaaaaaaa-300x169.jpeg 300w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/aaaaaaaa-1024x576.jpeg 1024w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/aaaaaaaa-768x432.jpeg 768w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/aaaaaaaa-1536x864.jpeg 1536w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/aaaaaaaa-2048x1152.jpeg 2048w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/aaaaaaaa-370x208.jpeg 370w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/aaaaaaaa-1230x692.jpeg 1230w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/aaaaaaaa-800x450.jpeg 800w, https:\/\/www.servergigabit.com\/guide\/wp-content\/uploads\/2023\/11\/aaaaaaaa-390x219.jpeg 390w\" sizes=\"(max-width: 692px) 100vw, 692px\" \/><\/p>\n<div class=\"markdown markdown-main-panel\" dir=\"ltr\">\n<p data-sourcepos=\"7:1-7:276\">In today&#8217;s world of cybersecurity, simply using passwords to protect your <a href=\"https:\/\/servergigabit.com\/\">Server Gigabit&#8217;s<\/a> server is no longer enough. Hackers can easily crack passwords using brute force attacks or other methods, putting your server at risk. A more secure method of authentication is to use SSH keys.<\/p>\n<h2 data-sourcepos=\"9:1-9:22\"><strong>What are SSH Keys?<\/strong><\/h2>\n<p data-sourcepos=\"11:1-11:512\">SSH keys are a cryptographic key pair that consists of a public key and a private key. The public key is shared with the server, while the private key is kept secret on your local computer. When you log in to your server using SSH keys, the server encrypts a challenge message using your public key. You then decrypt the challenge message using your private key, and the server verifies that the decrypted message matches the original challenge message. This process ensures that only you can access your server.<\/p>\n<h2 data-sourcepos=\"13:1-13:30\"><strong>Benefits of Using SSH Keys<\/strong><\/h2>\n<p data-sourcepos=\"15:1-15:86\">There are several benefits to using SSH keys to authenticate with your <a href=\"https:\/\/servergigabit.com\/\">Server Gigabit&#8217;s<\/a> server:<\/p>\n<ul data-sourcepos=\"17:1-20:0\">\n<li data-sourcepos=\"17:1-17:118\">Increased security: SSH keys are much more secure than passwords because they cannot be brute-forced or guessed.<\/li>\n<li data-sourcepos=\"18:1-18:128\">Convenience: Once you have set up SSH keys, you will not need to enter your password every time you log in to your server.<\/li>\n<li data-sourcepos=\"19:1-20:0\">Flexibility: SSH keys can be used to authenticate with any server that supports SSH key-based authentication.<\/li>\n<\/ul>\n<h2 data-sourcepos=\"21:1-21:28\"><strong>How to Generate SSH Keys<\/strong><\/h2>\n<h4>Linux<\/h4>\n<ol data-sourcepos=\"23:1-25:0\">\n<li data-sourcepos=\"23:1-23:49\">Open a terminal window on your local computer.<\/li>\n<li data-sourcepos=\"24:1-25:0\">Enter the following command:<\/li>\n<\/ol>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">ssh-keygen -t rsa\r\n<\/code><\/pre>\n<\/div>\n<p data-sourcepos=\"30:1-30:189\">This command will generate a pair of SSH keys: a public key and a private key. The private key will be saved to the file <code>id_rsa<\/code>, and the public key will be saved to the file <code>id_rsa.pub<\/code>.<\/p>\n<h4>Windows<\/h4>\n<ol data-sourcepos=\"23:1-25:0\">\n<li data-sourcepos=\"23:1-23:49\">Install <a href=\"https:\/\/www.putty.org\/\" target=\"_blank\" rel=\"noopener\">PuTTY<\/a>.<\/li>\n<li data-sourcepos=\"23:1-23:49\">Open the Windows search bar and search for &#8220;PuTTYgen&#8221;.<\/li>\n<li data-sourcepos=\"23:1-23:49\">Open it.<br \/>\n<img decoding=\"async\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/02\/Puttygenerator.png\" alt=\"Use the PuTTY Key Generator to generate SSH keys for Windows.\" \/><\/li>\n<li data-sourcepos=\"23:1-23:49\">Just click on \u201cGenerate\u201d and move your mouse over the blank field.<br \/>\n<img decoding=\"async\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/02\/PuTTY-generator-II.png\" alt=\"PuTTY key generator for Windows can create SSH keys using the RSA, DSA, ECDSA, ED25519, and SSH-1 (RSA) algorithms.\" \/><\/li>\n<\/ol>\n<h2 data-sourcepos=\"32:1-32:56\"><strong>How to Upload Your Public Key to Your Server Gigabit<\/strong><\/h2>\n<p data-sourcepos=\"34:1-34:116\">You can upload your public key to your Server Gigabit using a variety of methods, such as FTP or the server console.<\/p>\n<h4 data-sourcepos=\"36:1-36:37\"><strong>Uploading Your Public Key via FTP<\/strong><\/h4>\n<ol data-sourcepos=\"38:1-43:0\">\n<li data-sourcepos=\"38:1-38:61\">Start your FTP program and connect to your server as root.<\/li>\n<li data-sourcepos=\"39:1-39:58\">Create a directory in the root directory called <code>.ssh<\/code>.<\/li>\n<li data-sourcepos=\"40:1-40:66\">Create a file called <code>authorized_keys<\/code> in the <code>.ssh<\/code> directory.<\/li>\n<li data-sourcepos=\"41:1-41:64\">Paste your entire public key into the <code>authorized_keys<\/code> file.<\/li>\n<li data-sourcepos=\"42:1-43:0\">Save the <code>authorized_keys<\/code> file.<\/li>\n<\/ol>\n<h4 data-sourcepos=\"44:1-44:41\"><strong>Uploading Your Public Key via Console<\/strong><\/h4>\n<ol data-sourcepos=\"46:1-48:0\">\n<li data-sourcepos=\"46:1-46:41\">Log in to your server as root via SSH.<\/li>\n<li data-sourcepos=\"47:1-48:0\">Create the <code>.ssh<\/code> directory and switch to it using the following command:<\/li>\n<\/ol>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">mkdir \/root\/.ssh &amp;&amp; cd \/root\/.ssh\r\n<\/code><\/pre>\n<\/div>\n<ol start=\"3\" data-sourcepos=\"53:1-54:0\">\n<li data-sourcepos=\"53:1-54:0\">Create and open the <code>authorized_keys<\/code> file using the following command:<\/li>\n<\/ol>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">nano authorized_keys\r\n<\/code><\/pre>\n<\/div>\n<ol start=\"4\" data-sourcepos=\"59:1-61:0\">\n<li data-sourcepos=\"59:1-59:79\">Paste your entire public key into the file and save it by pressing [CTRL+O].<\/li>\n<li data-sourcepos=\"60:1-61:0\">Exit the editor by pressing [CTRL+X].<\/li>\n<\/ol>\n<h2 data-sourcepos=\"62:1-62:35\"><strong>How to Use Your SSH Private Key<\/strong><\/h2>\n<p data-sourcepos=\"64:1-64:111\">To use your SSH private key to log in to your Server Gigabit&#8217;s server, you will need to use an SSH client such as PuTTY.<\/p>\n<h4 data-sourcepos=\"66:1-66:41\"><strong>Using Your SSH Private Key with PuTTY<\/strong><\/h4>\n<ol data-sourcepos=\"68:1-76:0\">\n<li data-sourcepos=\"68:1-68:14\">Open PuTTY.<\/li>\n<li data-sourcepos=\"69:1-69:63\">Under &#8220;Category&#8221; on the left-hand side, select &#8220;Connection&#8221;.<\/li>\n<li data-sourcepos=\"70:1-70:43\">Select &#8220;SSH&#8221; from the list of protocols.<\/li>\n<li data-sourcepos=\"71:1-71:55\">Click on &#8220;Auth&#8221; to open the authentication settings.<\/li>\n<li data-sourcepos=\"72:1-72:54\">Click on &#8220;Browse&#8221; and select your private key file.<br \/>\n<img decoding=\"async\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/02\/PuTTY-settings.png\" alt=\"Follow these four steps to select your private key via the PuTTY key generator.\" \/><\/li>\n<li data-sourcepos=\"73:1-73:64\">Enter the IP address of your server in the &#8220;Host Name&#8221; field.<\/li>\n<li data-sourcepos=\"74:1-74:55\">Choose a profile name in the &#8220;Saved Sessions&#8221; field.<\/li>\n<li data-sourcepos=\"75:1-76:0\">Click on &#8220;Save&#8221; to save your profile.<br \/>\n<img decoding=\"async\" src=\"https:\/\/contabo.com\/blog\/wp-content\/uploads\/2022\/02\/PuTTY-settings-II.png\" alt=\"PuTTY settings 2\" \/><\/li>\n<\/ol>\n<p data-sourcepos=\"77:1-77:170\">Now you can double-click on your saved profile to log in to your server. You will be prompted to enter your username, but you will not be prompted to enter your password.<\/p>\n<h4 data-sourcepos=\"79:1-79:34\"><strong>Testing SSH Key Authentication<\/strong><\/h4>\n<p data-sourcepos=\"81:1-81:258\">Once you have set up SSH keys, you can test to make sure that they are working by trying to log in to your server using your SSH client. If you are able to log in without being prompted to enter your password, then SSH key authentication is working properly.<\/p>\n<h4 data-sourcepos=\"83:1-83:37\"><strong>Disabling Password Authentication<\/strong><\/h4>\n<p data-sourcepos=\"85:1-85:203\">It is a good security practice to disable password authentication once you have set up SSH keys. This will prevent anyone from logging in to your server using a password, even if they know your password.<\/p>\n<p data-sourcepos=\"87:1-87:155\">To disable password authentication, you will need to edit the <code>\/etc\/ssh\/sshd_config<\/code> file on your server. Find the following lines and change them to &#8220;no&#8221;:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">ChallengeResponseAuthentication no\r\nPasswordAuthentication no\r\n<\/code><\/pre>\n<\/div>\n<p data-sourcepos=\"1:1-1:104\">Once you have made these changes, save the file and restart the SSH service using the following command:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">systemctl restart ssh\r\n<\/code><\/pre>\n<\/div>\n<p data-sourcepos=\"6:1-6:135\">Now, when you try to log in to your server using a password, you will be denied access. You will only be able to log in using SSH keys.<\/p>\n<h4 data-sourcepos=\"8:1-8:35\"><strong>Removing SSH Key Authentication<\/strong><\/h4>\n<p data-sourcepos=\"10:1-10:190\">If you ever decide to remove SSH key authentication and re-enable password authentication, you will need to edit the <code>\/etc\/ssh\/sshd_config<\/code> file and change the following lines back to &#8220;yes&#8221;:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">ChallengeResponseAuthentication yes\r\nPasswordAuthentication yes\r\n<\/code><\/pre>\n<\/div>\n<p data-sourcepos=\"17:1-17:93\">You will also need to delete the <code>.ssh<\/code> directory on your server using the following command:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">rm -rf \/root\/.ssh\r\n<\/code><\/pre>\n<\/div>\n<p data-sourcepos=\"23:1-23:86\">Once you have made these changes, restart the SSH service using the following command:<\/p>\n<div class=\"code-block ng-star-inserted\">\n<pre><code class=\"code-container no-decoration-radius\" role=\"text\">systemctl restart ssh\r\n<\/code><\/pre>\n<\/div>\n<p data-sourcepos=\"29:1-29:83\">Now, you will be able to log in to your server using either SSH keys or a password.<\/p>\n<h2 data-sourcepos=\"31:1-31:14\"><strong>Conclusion<\/strong><\/h2>\n<p data-sourcepos=\"33:1-33:327\">Using SSH keys to authenticate with your Server Gigabit is a much more secure way to protect your server than using passwords. SSH keys are much more difficult to crack, and they provide a more convenient and flexible way to log in to your server. If you are not already using SSH keys, I highly recommend that you set them up.<\/p>\n<\/div>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In today&#8217;s world of cybersecurity, simply using passwords to protect your Server Gigabit&#8217;s server is no longer enough. Hackers can easily crack passwords using brute force attacks or other methods, putting your server at risk. A more secure method of authentication is to use SSH keys. What are SSH Keys? SSH keys are a cryptographic key pair that consists of&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"kbtopic":[1099],"kbtag":[1112],"class_list":["post-3836","kb","type-kb","status-publish","hentry","kbtopic-tutorials","kbtag-ssh-keys"],"_links":{"self":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/3836","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/comments?post=3836"}],"version-history":[{"count":1,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/3836\/revisions"}],"predecessor-version":[{"id":3838,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kb\/3836\/revisions\/3838"}],"wp:attachment":[{"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/media?parent=3836"}],"wp:term":[{"taxonomy":"kbtopic","embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kbtopic?post=3836"},{"taxonomy":"kbtag","embeddable":true,"href":"https:\/\/www.servergigabit.com\/guide\/wp-json\/wp\/v2\/kbtag?post=3836"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}