{"id":2449,"date":"2023-12-15T19:58:07","date_gmt":"2023-12-15T19:58:07","guid":{"rendered":"https:\/\/www.clientvps.com\/docs\/?p=2449"},"modified":"2024-03-12T21:03:26","modified_gmt":"2024-03-12T21:03:26","slug":"securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port","status":"publish","type":"post","link":"https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/","title":{"rendered":"Securing Your Ubuntu Server Guide to Changing the SSH Port"},"content":{"rendered":"\n<h3 class=\"wp-block-heading\">1. Connect to Your Server<\/h3>\n\n\n\n<p>Use your current SSH connection to access your server. If you&#8217;re not connected, you might need physical or console access to the server.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Edit the SSH Configuration File<\/h3>\n\n\n\n<p>Open the SSH configuration file in a text editor. The default location for the SSH configuration file is usually <code>\/etc\/ssh\/sshd_config<\/code>.<\/p>\n\n\n\n<p>bashCopy code<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Change the Port Number<\/h3>\n\n\n\n<p><code>sudo nano \/etc\/ssh\/sshd_config<\/code><\/p>\n\n\n\n<p>Find the line that specifies the port (it&#8217;s usually commented out with a <code>#<\/code> at the beginning). Change the port number to your desired value. Choose a port number that is not already in use and is not reserved for other services.<\/p>\n\n\n\n<p>bashCopy code<\/p>\n\n\n\n<p><code># Port 22 Port 2222 # Change this to your desired port number<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. Save and Close the File<\/h3>\n\n\n\n<p>Save the changes and close the text editor.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. Restart the SSH Service<\/h3>\n\n\n\n<p>To apply the changes, restart the SSH service:<\/p>\n\n\n\n<p>bashCopy code<\/p>\n\n\n\n<p><code>sudo service ssh restart<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">6. Adjust Firewall Settings<\/h3>\n\n\n\n<p>If you&#8217;re using a firewall, update its settings to allow traffic on the new SSH port. If you&#8217;re using UFW, you can do this with the following commands:<\/p>\n\n\n\n<p>bashCopy code<\/p>\n\n\n\n<p><code>sudo ufw allow 2222 # Replace with your new port number sudo ufw reload<\/code><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">7. Test the New SSH Port<\/h3>\n\n\n\n<p>Open a new terminal window and try to SSH into your server using the new port:<\/p>\n\n\n\n<p>bashCopy code<\/p>\n\n\n\n<p><code>ssh -p 2222 username@your_server_ip<\/code><\/p>\n\n\n\n<p>Replace <code>2222<\/code> with the port number you&#8217;ve chosen, <code>username<\/code> with your actual username, and <code>your_server_ip<\/code> with the actual IP address or domain name of your server.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Important Notes:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Always choose a secure port that is not commonly used for other services.<\/li>\n\n\n\n<li>After changing the SSH port, make sure you remember the new port number. Otherwise, you might lock yourself out of your server.<\/li>\n\n\n\n<li>Updating the SSH port alone is just one security measure. Consider other security practices like disabling root login, using key-based authentication, and keeping your system and SSH software up-to-date.<\/li>\n<\/ul>\n\n\n\n<p>After making these changes, your SSH server should be running on the new port. Ensure that you can still connect before closing your current SSH session. If you encounter any issues, you may need to troubleshoot and double-check your configuration.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Connect to Your Server Use your current SSH connection to access your server. If you&#8217;re not connected, you might need physical or console access to the server. 2. Edit the SSH Configuration File Open the SSH configuration file in a text editor. The default location for the SSH configuration file is usually \/etc\/ssh\/sshd_config. bashCopy [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":2522,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-2449","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux-servers"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Securing Your Ubuntu Server Guide to Changing the SSH Port<\/title>\n<meta name=\"description\" content=\"Secure your Ubuntu server: Quick guide on changing the SSH port to prevent attacks. Easy steps for improved protection.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Securing Your Ubuntu Server Guide to Changing the SSH Port\" \/>\n<meta property=\"og:description\" content=\"Secure your Ubuntu server: Quick guide on changing the SSH port to prevent attacks. Easy steps for improved protection.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/\" \/>\n<meta property=\"og:site_name\" content=\"ClientVPS Hosting Documentation Blog\" \/>\n<meta property=\"article:published_time\" content=\"2023-12-15T19:58:07+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-12T21:03:26+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.clientvps.com\/docs\/wp-content\/uploads\/2023\/12\/The-image-shows-a-secure-and-modern-server-room-with-racks-of-servers-run.png\" \/>\n\t<meta property=\"og:image:width\" content=\"500\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Edna Deleon\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Edna Deleon\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":[\"Article\",\"BlogPosting\"],\"@id\":\"https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/\"},\"author\":{\"name\":\"Edna Deleon\",\"@id\":\"https:\/\/www.clientvps.com\/docs\/#\/schema\/person\/2bcacf1f391ca24e8f469abdbaf1ccc7\"},\"headline\":\"Securing Your Ubuntu Server Guide to Changing the SSH Port\",\"datePublished\":\"2023-12-15T19:58:07+00:00\",\"dateModified\":\"2024-03-12T21:03:26+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/\"},\"wordCount\":322,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.clientvps.com\/docs\/#organization\"},\"articleSection\":[\"Linux Server\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/\",\"url\":\"https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/\",\"name\":\"Securing Your Ubuntu Server Guide to Changing the SSH Port\",\"isPartOf\":{\"@id\":\"https:\/\/www.clientvps.com\/docs\/#website\"},\"datePublished\":\"2023-12-15T19:58:07+00:00\",\"dateModified\":\"2024-03-12T21:03:26+00:00\",\"description\":\"Secure your Ubuntu server: Quick guide on changing the SSH port to prevent attacks. Easy steps for improved protection.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.clientvps.com\/docs\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Securing Your Ubuntu Server Guide to Changing the SSH Port\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.clientvps.com\/docs\/#website\",\"url\":\"https:\/\/www.clientvps.com\/docs\/\",\"name\":\"ClientVPS Documentation\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.clientvps.com\/docs\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.clientvps.com\/docs\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.clientvps.com\/docs\/#organization\",\"name\":\"ClientVPS Documentation\",\"url\":\"https:\/\/www.clientvps.com\/docs\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.clientvps.com\/docs\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.clientvps.com\/docs\/wp-content\/uploads\/2023\/12\/cropped-footer-logo.webp\",\"contentUrl\":\"https:\/\/www.clientvps.com\/docs\/wp-content\/uploads\/2023\/12\/cropped-footer-logo.webp\",\"width\":328,\"height\":127,\"caption\":\"ClientVPS Documentation\"},\"image\":{\"@id\":\"https:\/\/www.clientvps.com\/docs\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.clientvps.com\/docs\/#\/schema\/person\/2bcacf1f391ca24e8f469abdbaf1ccc7\",\"name\":\"Edna Deleon\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.clientvps.com\/docs\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/87e4d7f8bc1ce983b427e235829628aec7ca0659559209e6e9b3dc9966a5b42c?s=96&d=robohash&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/87e4d7f8bc1ce983b427e235829628aec7ca0659559209e6e9b3dc9966a5b42c?s=96&d=robohash&r=g\",\"caption\":\"Edna Deleon\"},\"sameAs\":[\"https:\/\/www.clientvps.com\/docs\"],\"url\":\"https:\/\/www.clientvps.com\/docs\/author\/admin2\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Securing Your Ubuntu Server Guide to Changing the SSH Port","description":"Secure your Ubuntu server: Quick guide on changing the SSH port to prevent attacks. Easy steps for improved protection.","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:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/","og_locale":"en_US","og_type":"article","og_title":"Securing Your Ubuntu Server Guide to Changing the SSH Port","og_description":"Secure your Ubuntu server: Quick guide on changing the SSH port to prevent attacks. Easy steps for improved protection.","og_url":"https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/","og_site_name":"ClientVPS Hosting Documentation Blog","article_published_time":"2023-12-15T19:58:07+00:00","article_modified_time":"2024-03-12T21:03:26+00:00","og_image":[{"width":500,"height":400,"url":"https:\/\/www.clientvps.com\/docs\/wp-content\/uploads\/2023\/12\/The-image-shows-a-secure-and-modern-server-room-with-racks-of-servers-run.png","type":"image\/png"}],"author":"Edna Deleon","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Edna Deleon","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["Article","BlogPosting"],"@id":"https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/#article","isPartOf":{"@id":"https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/"},"author":{"name":"Edna Deleon","@id":"https:\/\/www.clientvps.com\/docs\/#\/schema\/person\/2bcacf1f391ca24e8f469abdbaf1ccc7"},"headline":"Securing Your Ubuntu Server Guide to Changing the SSH Port","datePublished":"2023-12-15T19:58:07+00:00","dateModified":"2024-03-12T21:03:26+00:00","mainEntityOfPage":{"@id":"https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/"},"wordCount":322,"commentCount":0,"publisher":{"@id":"https:\/\/www.clientvps.com\/docs\/#organization"},"articleSection":["Linux Server"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/","url":"https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/","name":"Securing Your Ubuntu Server Guide to Changing the SSH Port","isPartOf":{"@id":"https:\/\/www.clientvps.com\/docs\/#website"},"datePublished":"2023-12-15T19:58:07+00:00","dateModified":"2024-03-12T21:03:26+00:00","description":"Secure your Ubuntu server: Quick guide on changing the SSH port to prevent attacks. Easy steps for improved protection.","breadcrumb":{"@id":"https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.clientvps.com\/docs\/securing-your-ubuntu-server-a-step-by-step-guide-to-changing-the-ssh-port\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.clientvps.com\/docs\/"},{"@type":"ListItem","position":2,"name":"Securing Your Ubuntu Server Guide to Changing the SSH Port"}]},{"@type":"WebSite","@id":"https:\/\/www.clientvps.com\/docs\/#website","url":"https:\/\/www.clientvps.com\/docs\/","name":"ClientVPS Documentation","description":"","publisher":{"@id":"https:\/\/www.clientvps.com\/docs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.clientvps.com\/docs\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.clientvps.com\/docs\/#organization","name":"ClientVPS Documentation","url":"https:\/\/www.clientvps.com\/docs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.clientvps.com\/docs\/#\/schema\/logo\/image\/","url":"https:\/\/www.clientvps.com\/docs\/wp-content\/uploads\/2023\/12\/cropped-footer-logo.webp","contentUrl":"https:\/\/www.clientvps.com\/docs\/wp-content\/uploads\/2023\/12\/cropped-footer-logo.webp","width":328,"height":127,"caption":"ClientVPS Documentation"},"image":{"@id":"https:\/\/www.clientvps.com\/docs\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.clientvps.com\/docs\/#\/schema\/person\/2bcacf1f391ca24e8f469abdbaf1ccc7","name":"Edna Deleon","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.clientvps.com\/docs\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/87e4d7f8bc1ce983b427e235829628aec7ca0659559209e6e9b3dc9966a5b42c?s=96&d=robohash&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/87e4d7f8bc1ce983b427e235829628aec7ca0659559209e6e9b3dc9966a5b42c?s=96&d=robohash&r=g","caption":"Edna Deleon"},"sameAs":["https:\/\/www.clientvps.com\/docs"],"url":"https:\/\/www.clientvps.com\/docs\/author\/admin2\/"}]}},"_links":{"self":[{"href":"https:\/\/www.clientvps.com\/docs\/wp-json\/wp\/v2\/posts\/2449","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.clientvps.com\/docs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.clientvps.com\/docs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.clientvps.com\/docs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.clientvps.com\/docs\/wp-json\/wp\/v2\/comments?post=2449"}],"version-history":[{"count":0,"href":"https:\/\/www.clientvps.com\/docs\/wp-json\/wp\/v2\/posts\/2449\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.clientvps.com\/docs\/wp-json\/wp\/v2\/media\/2522"}],"wp:attachment":[{"href":"https:\/\/www.clientvps.com\/docs\/wp-json\/wp\/v2\/media?parent=2449"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.clientvps.com\/docs\/wp-json\/wp\/v2\/categories?post=2449"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.clientvps.com\/docs\/wp-json\/wp\/v2\/tags?post=2449"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}