{"id":14636,"date":"2024-10-07T19:15:25","date_gmt":"2024-10-07T19:15:25","guid":{"rendered":"https:\/\/truehost.com\/support\/?post_type=docs&#038;p=14636"},"modified":"2024-10-08T09:09:55","modified_gmt":"2024-10-08T09:09:55","password":"","slug":"how-to-disable-root-ssh-completely","status":"publish","type":"docs","link":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-disable-root-ssh-completely\/","title":{"rendered":"How to disable root ssh completely"},"content":{"rendered":"\n<p>Disabling root access via SSH is a common security measure to prevent unauthorized access to your server. Instead of logging in as root, users should log in as a regular user and elevate their privileges using <code>sudo<\/code>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Prerequisites<\/strong><\/h3>\n\n\n\n<p>Before disabling root SSH access, ensure the following:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>You must have SSH access to the server, either as the <strong>root<\/strong> user or a <strong>sudo<\/strong> user.<\/li>\n\n\n\n<li>Ensure that you have a non-root user with <strong>sudo<\/strong> privileges set up on the server. Use <strong><a href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-create-a-sudo-user-on-your-server\/\" target=\"_blank\" rel=\"noreferrer noopener\">these<\/a><\/strong> steps to create one<\/li>\n<\/ul>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Step 1: Log in to Your Server. Check <a href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-access-a-server-via-ssh-terminal\/\" target=\"_blank\" rel=\"noreferrer noopener\">these steps<\/a> on how to do that.<\/strong><\/h5>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Step 2: Create or Verify a Sudo User<\/strong><\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If you do not already have a sudo user, <strong><a href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-create-a-sudo-user-on-your-server\/\" target=\"_blank\" rel=\"noreferrer noopener\">create one<\/a><\/strong> before disabling root SSH access.<\/li>\n\n\n\n<li>If you have a user already, very that the user can run <strong>sudo<\/strong> commands by running the command below.<\/li>\n\n\n\n<li>If the command returns <code>root<\/code>, the new user has sudo privileges. You may then proceed, otherwise refer to <strong><a href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-create-a-sudo-user-on-your-server\/\" target=\"_blank\" rel=\"noreferrer noopener\">this<\/a><\/strong> article.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>sudo whoami<\/strong><\/code><\/pre>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Step 3: Backup the SSH Configuration File<\/strong><\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Before making any changes, create a backup of the SSH configuration file:<\/li>\n\n\n\n<li>This allows you to restore the configuration if necessary. Use the command below.<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>cp \/etc\/ssh\/sshd_config \/etc\/ssh\/sshd_config.bak<\/strong><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"928\" height=\"135\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-165.png\" alt=\"\" class=\"wp-image-14673\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-165.png 928w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-165-300x44.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-165-768x112.png 768w\" sizes=\"auto, (max-width: 928px) 100vw, 928px\" \/><\/figure>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Step 4: Edit the SSH Configuration File<\/strong><\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Open the SSH configuration file using a text editor, such as vim or nano:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>vim \/etc\/ssh\/sshd_config<\/strong> or <strong>nano \/etc\/ssh\/sshd_config<\/strong><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"983\" height=\"233\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-166.png\" alt=\"\" class=\"wp-image-14675\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-166.png 983w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-166-300x71.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-166-768x182.png 768w\" sizes=\"auto, (max-width: 983px) 100vw, 983px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Locate the line that allows root login:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>PermitRootLogin yes<\/strong><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"535\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-167-1024x535.png\" alt=\"\" class=\"wp-image-14676\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-167-1024x535.png 1024w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-167-300x157.png 300w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-167-768x401.png 768w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-167.png 1113w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Change it to:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>PermitRootLogin no<\/strong><\/code><\/pre>\n\n\n\n<p>This disables SSH access for the root user.<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>Step 5: Reload SSH Service<\/strong><\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li>After editing the SSH configuration file, reload the SSH service to apply the changes:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code><strong>systemctl reload sshd<\/strong> OR <strong>systemctl reload sshd.service<\/strong><\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-full is-style-zoooom\"><img loading=\"lazy\" decoding=\"async\" width=\"522\" height=\"154\" src=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-168.png\" alt=\"\" class=\"wp-image-14677\" srcset=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-168.png 522w, https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-168-300x89.png 300w\" sizes=\"auto, (max-width: 522px) 100vw, 522px\" \/><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Important Links<\/strong><\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li><strong><a href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-create-a-sudo-user-on-your-server\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to create a sudo user on your server<\/a><\/strong><\/li>\n\n\n\n<li><strong><a href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-disable-root-ssh-with-password-but-enable-via-ssh-keys\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to disable root ssh with password but enable via ssh keys<\/a><\/strong><\/li>\n\n\n\n<li><strong><a href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-change-ssh-port-to-a-custom-port\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to change SSH port to a custom port<\/a><\/strong><\/li>\n\n\n\n<li><strong><a href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-prevent-password-request-when-running-sudo-commands\/\" target=\"_blank\" rel=\"noreferrer noopener\">How to prevent password request when running sudo commands<\/a><\/strong><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Disabling root access via SSH is a common security measure to prevent unauthorized access to your server. Instead of logging in as root, users should log in as a regular user and elevate their privileges using sudo. Prerequisites Before disabling root SSH access, ensure the following: Step 1: Log in to Your Server. Check these [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"closed","template":"","meta":{"_eb_attr":"","_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"doc_category":[1820,1824,1879,2128],"doc_tag":[],"class_list":["post-14636","docs","type-docs","status-publish","hentry","doc_category-cloud-servers-in-kenya","doc_category-dedicated-servers","doc_category-servers","doc_category-vps-servers"],"year_month":"2026-07","word_count":323,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"Eugene","author_nicename":"eugene","author_url":"https:\/\/truehost.com\/support\/author\/eugene\/"},"doc_category_info":[{"term_name":"Cloud servers in Kenya","term_url":"https:\/\/truehost.com\/support\/docs-category\/cloud-servers-in-kenya\/"},{"term_name":"dedicated servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/dedicated-servers\/"},{"term_name":"Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/servers\/"},{"term_name":"VPS-Servers","term_url":"https:\/\/truehost.com\/support\/docs-category\/vps-servers\/"}],"doc_tag_info":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.0 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to disable root ssh completely -<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-disable-root-ssh-completely\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to disable root ssh completely -\" \/>\n<meta property=\"og:description\" content=\"Disabling root access via SSH is a common security measure to prevent unauthorized access to your server. Instead of logging in as root, users should log in as a regular user and elevate their privileges using sudo. Prerequisites Before disabling root SSH access, ensure the following: Step 1: Log in to Your Server. Check these [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/truehost.com\/support\/knowledge-base\/how-to-disable-root-ssh-completely\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-10-08T09:09:55+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-165.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-disable-root-ssh-completely\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-disable-root-ssh-completely\\\/\",\"name\":\"How to disable root ssh completely -\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-disable-root-ssh-completely\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-disable-root-ssh-completely\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2024\\\/10\\\/image-165.png\",\"datePublished\":\"2024-10-07T19:15:25+00:00\",\"dateModified\":\"2024-10-08T09:09:55+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-disable-root-ssh-completely\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-disable-root-ssh-completely\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-disable-root-ssh-completely\\\/#primaryimage\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2024\\\/10\\\/image-165.png\",\"contentUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2024\\\/10\\\/image-165.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/knowledge-base\\\/how-to-disable-root-ssh-completely\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/truehost.com\\\/support\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to disable root ssh completely\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#website\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"name\":\"\",\"description\":\"Help In a Click\",\"publisher\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/truehost.com\\\/support\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#organization\",\"name\":\"Truehost Kenya\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"contentUrl\":\"https:\\\/\\\/truehost.com\\\/support\\\/wp-content\\\/uploads\\\/2026\\\/04\\\/cropped-image_2026-04-16_174808866.png\",\"width\":240,\"height\":48,\"caption\":\"Truehost Kenya\"},\"image\":{\"@id\":\"https:\\\/\\\/truehost.com\\\/support\\\/#\\\/schema\\\/logo\\\/image\\\/\"}}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to disable root ssh completely -","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-disable-root-ssh-completely\/","og_locale":"en_US","og_type":"article","og_title":"How to disable root ssh completely -","og_description":"Disabling root access via SSH is a common security measure to prevent unauthorized access to your server. Instead of logging in as root, users should log in as a regular user and elevate their privileges using sudo. Prerequisites Before disabling root SSH access, ensure the following: Step 1: Log in to Your Server. Check these [&hellip;]","og_url":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-disable-root-ssh-completely\/","article_modified_time":"2024-10-08T09:09:55+00:00","og_image":[{"url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-165.png","type":"","width":"","height":""}],"twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-disable-root-ssh-completely\/","url":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-disable-root-ssh-completely\/","name":"How to disable root ssh completely -","isPartOf":{"@id":"https:\/\/truehost.com\/support\/#website"},"primaryImageOfPage":{"@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-disable-root-ssh-completely\/#primaryimage"},"image":{"@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-disable-root-ssh-completely\/#primaryimage"},"thumbnailUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-165.png","datePublished":"2024-10-07T19:15:25+00:00","dateModified":"2024-10-08T09:09:55+00:00","breadcrumb":{"@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-disable-root-ssh-completely\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/truehost.com\/support\/knowledge-base\/how-to-disable-root-ssh-completely\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-disable-root-ssh-completely\/#primaryimage","url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-165.png","contentUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2024\/10\/image-165.png"},{"@type":"BreadcrumbList","@id":"https:\/\/truehost.com\/support\/knowledge-base\/how-to-disable-root-ssh-completely\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/truehost.com\/support\/"},{"@type":"ListItem","position":2,"name":"How to disable root ssh completely"}]},{"@type":"WebSite","@id":"https:\/\/truehost.com\/support\/#website","url":"https:\/\/truehost.com\/support\/","name":"","description":"Help In a Click","publisher":{"@id":"https:\/\/truehost.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/truehost.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/truehost.com\/support\/#organization","name":"Truehost Kenya","url":"https:\/\/truehost.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","contentUrl":"https:\/\/truehost.com\/support\/wp-content\/uploads\/2026\/04\/cropped-image_2026-04-16_174808866.png","width":240,"height":48,"caption":"Truehost Kenya"},"image":{"@id":"https:\/\/truehost.com\/support\/#\/schema\/logo\/image\/"}}]}},"_links":{"self":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/14636","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/comments?post=14636"}],"version-history":[{"count":7,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/14636\/revisions"}],"predecessor-version":[{"id":14681,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/docs\/14636\/revisions\/14681"}],"wp:attachment":[{"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/media?parent=14636"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_category?post=14636"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/truehost.com\/support\/wp-json\/wp\/v2\/doc_tag?post=14636"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}