{"id":22102,"date":"2025-04-29T15:21:59","date_gmt":"2025-04-29T13:21:59","guid":{"rendered":"https:\/\/contabo.com\/blog\/kb\/103000271395-how-do-i-change-my-server-s-port\/"},"modified":"2025-05-08T11:15:08","modified_gmt":"2025-05-08T09:15:08","slug":"103000271395-how-do-i-change-my-server-s-port","status":"publish","type":"kb","link":"https:\/\/contabo.com\/blog\/kb\/103000271395-how-do-i-change-my-server-s-port\/","title":{"rendered":"How Do I Change My Server&#8217;s Port?"},"content":{"rendered":"<h4 dir=\"ltr\"><strong dir=\"ltr\">Why should I change my server&#8217;s port?&nbsp;<\/strong><\/h4>\n<p dir=\"ltr\">The default SSH port is 22. It is recommended that you change this setting on your server as soon as possible, as the default port makes you vulnerable to primitive brute force attacks. By default, there are no restrictions on which port you can use.<\/p>\n<p dir=\"ltr\"><\/p>\n<p dir=\"ltr\">The way to change your server&#8217;s port depends on the Operating System (OS) your server uses. Below you&#8217;ll find instructions on how to change the port on Windows and Linux servers.<\/p>\n<p dir=\"ltr\"><\/p>\n<h4 dir=\"ltr\"><strong dir=\"ltr\">How do I change my port on a Windows server?<\/strong><\/h4>\n<ol>\n<li dir=\"ltr\">Start the Registry Editor by typing the following in the Windows Search box:<br \/><code>regedit<\/code><\/li>\n<li dir=\"ltr\">The registry editor you just opened should look like this:<br \/><img loading=\"lazy\" decoding=\"async\" width=\"752\" height=\"391\" src=\"https:\/\/s3-eu-central-1.amazonaws.com\/euc-cdn.freshdesk.com\/data\/helpdesk\/attachments\/production\/103082477289\/original\/alqQXH_bD4gwDO3kWxdv5EFiPdUGmz-72A.png?1706179043\" alt=\"windows registry\" class=\"wp-image-12890 webpexpress-processed fr-fic fr-dib inline-image\" data-id=\"103082477289\" data-attachment=\"[object Object]\"><\/li>\n<li dir=\"ltr\">Navigate to the following registry subkey: <strong>HKEY_LOCAL_MACHINESystemCurrentControlSetControlTerminal ServerWinStationsRDP-Tcp<\/strong><\/li>\n<li dir=\"ltr\">Find <strong>PortNumber&nbsp;<\/strong>entry.<\/li>\n<li dir=\"ltr\">Click <strong>Edit &gt; Modify<\/strong>, and then click <strong>Decimal<\/strong>.<\/li>\n<li dir=\"ltr\">Type the new port number, and then click OK.<\/li>\n<li dir=\"ltr\">Close the registry editor and restart your computer.<\/li>\n<li dir=\"ltr\"><em>Important: Don&rsquo;t forget to allow the new port in your Windows Firewall<\/em>. To access the port settings, open your firewall settings and go to: <strong>Inbounds rules &gt; New Rule &gt; Port<\/strong><br \/><strong dir=\"ltr\"><img loading=\"lazy\" decoding=\"async\" width=\"741\" height=\"429\" src=\"https:\/\/s3-eu-central-1.amazonaws.com\/euc-cdn.freshdesk.com\/data\/helpdesk\/attachments\/production\/103082477290\/original\/36V1KQHaA9rEG5vu7OqKOHJUz7YM_poK-A.png?1706179043\" alt=\"set your new port in firewall\" class=\"wp-image-12894 webpexpress-processed fr-fic fr-dib inline-image\" data-id=\"103082477290\" data-attachment=\"[object Object]\"><\/strong><\/li>\n<li dir=\"ltr\">Follow the <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows-server\/remote\/remote-desktop-services\/clients\/change-listening-port\" rel=\"noopener noreferrer nofollow nofollow\" target=\"_blank\"><u>official documentation<\/u><\/a> from Microsoft for detailed information, including PowerShell commands.<\/li>\n<li dir=\"ltr\">If you want to establish an RDC connection to the server using a non-standard port, you must specify the port to use. This can be done by simply adding a colon and the new port. For example:<br \/><strong>73.xxx.xxx.xxx:4567<\/strong> (To connect to Port 4567).<\/li>\n<\/ol>\n<h4 dir=\"ltr\"><strong dir=\"ltr\">How do I change my port on a Linux server?<\/strong><\/h4>\n<ol>\n<li dir=\"ltr\">To grant you all the necessary admin rights, always enter the command sudo -i at the beginning of every session:<br \/><code dir=\"ltr\">sudo -i<\/code><br \/>This command will grant you the rights of a power user, so you don&rsquo;t have to write the command sudo at the beginning of every command line.<\/li>\n<li dir=\"ltr\">Connect to your Contabo server.<\/li>\n<li dir=\"ltr\">Now you have to access and edit sshd_config file. Let&rsquo;s use the vi text editor in this case:<br \/><code>vi \/etc\/ssh\/sshd_config<\/code><\/li>\n<li dir=\"ltr\">Find the line containing Port 22.<\/li>\n<li dir=\"ltr\">Replace the number with any value from 1024 to 65536 (command &ldquo;I&rdquo; in the vi editor). If there is a hashtag symbol next to &ldquo;Port&rdquo;, erase it.<\/li>\n<li dir=\"ltr\">Save and exit the sshd_config file (type command &ldquo;:wq&rdquo; in the vi editor).<\/li>\n<li dir=\"ltr\">Restart the SSH service using:<br \/><code>systemctl restart ssh<\/code><\/li>\n<li>Don&rsquo;t forget to adjust your firewall depending on your Linux version. For instance, in case you use Debian or Ubuntu with a default UFW firewall, type:<br \/><code>ufw allow &lt;PORT_NUMBER&gt;\/tcp<\/code><\/li>\n<\/ol>\n<p><\/p>\n<\/p>\n<p><span class=\"ast-load-more active\"><a href=\"https:\/\/help.contabo.com\/en\/support\/solutions\/articles\/103000271395-how-do-i-change-my-server-s-port-\" rel=\"nofollow\">Details&#8230;<\/a> <\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Why should I change my server&#8217;s port?&nbsp; The default SSH port is 22. It is recommended that you change this setting on your server as soon as possible, as the default port makes you vulnerable to primitive brute force attacks. By default, there are no restrictions on which port you can use. The way to [&hellip;]<\/p>\n","protected":false},"author":72,"featured_media":0,"template":"","meta":{"inline_featured_image":false,"_uag_custom_page_level_css":"","site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[2067],"tags":[],"class_list":["post-22102","kb","type-kb","status-publish","hentry","category-kb"],"uagb_featured_image_src":{"full":false,"thumbnail":false,"medium":false,"medium_large":false,"large":false,"1536x1536":false,"2048x2048":false},"uagb_author_info":{"display_name":"Contabo Web","author_link":"https:\/\/contabo.com\/blog\/author\/julius-nalivaiko\/"},"uagb_comment_info":0,"uagb_excerpt":"Why should I change my server&#8217;s port?&nbsp; The default SSH port is 22. It is recommended that you change this setting on your server as soon as possible, as the default port makes you vulnerable to primitive brute force attacks. By default, there are no restrictions on which port you can use. The way to&hellip;","_links":{"self":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/kb\/22102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/users\/72"}],"version-history":[{"count":2,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/kb\/22102\/revisions"}],"predecessor-version":[{"id":23543,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/kb\/22102\/revisions\/23543"}],"wp:attachment":[{"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/media?parent=22102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/categories?post=22102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/contabo.com\/blog\/wp-json\/wp\/v2\/tags?post=22102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}