{"id":636,"date":"2016-09-08T00:00:00","date_gmt":"2016-09-08T00:00:00","guid":{"rendered":"http:\/\/blog.hostinger.io\/hostinger-tutorials\/uncategorized\/vpshow-to-change-ssh-port-vps\/"},"modified":"2026-03-10T09:31:30","modified_gmt":"2026-03-10T09:31:30","slug":"how-to-change-ssh-port-vps","status":"publish","type":"post","link":"\/ca\/tutorials\/how-to-change-ssh-port-vps\/","title":{"rendered":"How to change the SSH port"},"content":{"rendered":"<?xml encoding=\"utf-8\" ?><p>SSH, or Secure Shell, is an essential protocol for securely accessing and managing remote servers. It encrypts all communication, ensuring that data remains protected from unauthorized interception.<\/p><p>By default, SSH runs on port 22, which is often targeted by brute force attacks. Changing the default SSH port can significantly enhance security by reducing the likelihood of automated attacks.<\/p><p>This article will guide you through all the steps to changing the SSH port on a Linux virtual private server (VPS), from selecting the appropriate new port to ensuring your server remains accessible after the change.<\/p><p class=\"has-text-align-center\"><a href=\"https:\/\/assets.hostinger.com\/content\/tutorials\/pdf\/SSH-Cheat-Sheet-EN.pdf\" target=\"_blank\" rel=\"noopener\">Download ultimate SSH commands cheat sheet<\/a><\/p><p>\n\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-choosing-a-new-ssh-port\">Choosing a new SSH port<\/h2><p>It&rsquo;s important to select a port that is not already in use by other services to avoid potential conflicts and <a href=\"\/ca\/tutorials\/vps-security\/\">reduce security risks on your VPS<\/a>. Here are some of the most commonly used port numbers with their associated services and protocols:<\/p><figure tabindex=\"0\" class=\"wp-block-table\"><table><tbody><tr><td><strong>Port number<\/strong><\/td><td><strong>Service<\/strong><\/td><td><strong>Protocol<\/strong><\/td><\/tr><tr><td>20<\/td><td>FTP (data transfer)<\/td><td>TCP<\/td><\/tr><tr><td>21<\/td><td>FTP (control)<\/td><td>TCP<\/td><\/tr><tr><td>22<\/td><td>SSH<\/td><td>TCP<\/td><\/tr><tr><td>23<\/td><td>Telnet<\/td><td>TCP<\/td><\/tr><tr><td>25<\/td><td>SMTP<\/td><td>TCP<\/td><\/tr><tr><td>53<\/td><td>DNS<\/td><td>TCP\/UDP<\/td><\/tr><tr><td>67\/68<\/td><td>DHCP<\/td><td>UDP<\/td><\/tr><tr><td>69<\/td><td>TFTP<\/td><td>UDP<\/td><\/tr><tr><td>80<\/td><td>HTTP<\/td><td>TCP<\/td><\/tr><tr><td>110<\/td><td>POP3<\/td><td>TCP<\/td><\/tr><tr><td>123<\/td><td>NTP<\/td><td>UDP<\/td><\/tr><tr><td>137\/138\/139<\/td><td>NetBIOS<\/td><td>TCP\/UDP<\/td><\/tr><tr><td>143<\/td><td>IMAP<\/td><td>TCP<\/td><\/tr><tr><td>161\/162<\/td><td>SNMP<\/td><td>TCP\/UDP<\/td><\/tr><tr><td>179<\/td><td>BGP<\/td><td>TCP<\/td><\/tr><tr><td>389<\/td><td>LDAP<\/td><td>TCP\/UDP<\/td><\/tr><tr><td>443<\/td><td>HTTPS<\/td><td>TCP<\/td><\/tr><tr><td>636<\/td><td>LDAPS<\/td><td>TCP\/UDP<\/td><\/tr><tr><td>989\/990<\/td><td>FTPS<\/td><td>TCP<\/td><\/tr><tr><td>3306<\/td><td>MySQL<\/td><td>TCP<\/td><\/tr><tr><td>8080<\/td><td>Alternative to HTTP (web)<\/td><td>TCP<\/td><\/tr><tr><td>8443<\/td><td>Alternative to HTTPS (web)<\/td><td>TCP<\/td><\/tr><\/tbody><\/table><\/figure><p>Additionally, consider selecting a port outside the well-known range (<strong>0-1023<\/strong>) and the registered ports range (<strong>1024-49151<\/strong>). It&rsquo;s advisable to opt for a custom port within the dynamic or private ports range (<strong>49152-65535<\/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                    Suggested Reading                <\/p>\n            <\/div>\n            <p class=\"protip__content\">SSH uses three different encryption techniques: symmetric, asymmetric, and hashing. Learn more about these methods in our <a href=\"\/ca\/tutorials\/ssh-tutorial-how-does-ssh-work\/\">SSH tutorial<\/a> article.<\/p>\n                    <\/div>\n        \n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-change-the-default-ssh-port\">How to change the default SSH port<\/h2><p>Now that you have chosen a new port, let&rsquo;s proceed with the steps to implement the change.<\/p><h3 class=\"wp-block-heading\" id=\"h-1-access-your-server-via-ssh\">1. Access your server via SSH<\/h3><p>Before you can make any changes, you need to access your server securely. Follow these steps to connect to your server via SSH:<\/p><ol class=\"wp-block-list\">\n<li>Whether you&rsquo;re using Windows, macOS, or Linux, start by opening a new terminal window. On Windows, you may need an <a href=\"\/ca\/tutorials\/how-to-use-putty-ssh\/\">SSH client like PuTTY<\/a>.<\/li>\n\n\n\n<li>Use the following command to connect to your server. Replace <strong>username<\/strong> with your actual server username and <strong>server_ip<\/strong> with your server&rsquo;s IP address:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">ssh username@server_ip<\/pre><ol start=\"3\" class=\"wp-block-list\">\n<li>Enter the password associated with the username you provided. For enhanced security, it is recommended to use <a href=\"\/ca\/tutorials\/ssh\/how-to-set-up-ssh-keys\/\">SSH keys<\/a> instead of passwords.<\/li>\n<\/ol><h3 class=\"wp-block-heading\" id=\"h-2-edit-the-ssh-configuration-file\">2. Edit the SSH configuration file<\/h3><p>Once you&rsquo;ve successfully accessed your server, the next step is modifying the SSH configuration to use a new port. This involves editing the <strong>sshd_config<\/strong> file, which controls various parameters of your SSH daemon.<\/p><ol class=\"wp-block-list\">\n<li>Use the following command to open the SSH daemon configuration file in the <a href=\"\/ca\/tutorials\/how-to-install-and-use-nano-text-editor\/\">nano text editor<\/a>:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">sudo nano \/etc\/ssh\/sshd_config<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>Scroll down until you find the line that includes <strong>#Port 22<\/strong>. This line is commented out by default, and the number <strong>22<\/strong> represents the default port.<\/li>\n\n\n\n<li>Remove the <strong>#<\/strong> to uncomment this line and change <strong>22<\/strong> to your desired port number, such as <strong>61189<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"6a58815173ad7\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a58815173ad7\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1122\" height=\"678\" 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\/2024\/04\/terminal-nano-port-highlighted.png\/w=1024,h=1024,fit=scale-down\" alt=\"Editing the sshd_config file to change the SSH port\" class=\"wp-image-108267\"  sizes=\"auto, (max-width: 1122px) 100vw, 1122px\" \/><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><ol start=\"4\" class=\"wp-block-list\">\n<li>Once done, press <strong>Ctrl + X &rarr; Y &rarr; Enter<\/strong> to save the changes and exit <strong>nano<\/strong>.<\/li>\n<\/ol><h3 class=\"wp-block-heading\" id=\"h-3-adjust-firewall-settings\">3. Adjust firewall settings<\/h3><p>After updating your SSH port, it&rsquo;s essential to adjust your firewall settings to allow traffic on the new port. However, if you&rsquo;ve never configured any firewall rules, you can skip this step and proceed to the next section.<\/p><p>Here&rsquo;s how to update firewall settings using <a href=\"\/ca\/tutorials\/how-to-configure-firewall-on-ubuntu-using-ufw\/\">Uncomplicated Firewall (UFW)<\/a>:<\/p><ol class=\"wp-block-list\">\n<li>Execute the following command to allow incoming connections on your new port over TCP, replacing <strong>61189<\/strong> with your specific port:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">sudo ufw allow 61189\/tcp<\/pre><ol start=\"2\" class=\"wp-block-list\">\n<li>Reload UFW to apply the changes:<\/li>\n<\/ol><pre class=\"wp-block-preformatted\">sudo ufw reload<\/pre><p>For <a href=\"\/ca\/vps-hosting\">Hostinger&rsquo;s VPS hosting<\/a> customers, you can easily configure firewall settings on hPanel. Follow these steps:<\/p><ol class=\"wp-block-list\">\n<li>Access your VPS dashboard and navigate to <strong>Security &rarr; Firewall<\/strong>.<\/li>\n\n\n\n<li>Click <strong>Create firewall configuration<\/strong>, name your new configuration, and click <strong>Create<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"6a5881517c0b0\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a5881517c0b0\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"2226\" height=\"712\" 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\/2024\/04\/hpanel-vps-firewall-create-highlighted.png\/w=1024,h=1024,fit=scale-down\" alt=\"Creating a new firewall configuration on hPanel\" class=\"wp-image-108268\"  sizes=\"auto, (max-width: 2226px) 100vw, 2226px\" \/><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><ol start=\"3\" class=\"wp-block-list\">\n<li>Click the <strong>three-dot horizontal<\/strong> button and choose <strong>Edit<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"6a5881517fd83\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a5881517fd83\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"2250\" height=\"562\" 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\/2024\/04\/hpanel-vps-firewall-edit-highlighted.png\/w=1024,h=1024,fit=scale-down\" alt=\"Editing the newly created firewall rule on hPanel\" class=\"wp-image-108269\"  sizes=\"auto, (max-width: 2250px) 100vw, 2250px\" \/><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><ol start=\"4\" class=\"wp-block-list\">\n<li>In the <strong>Add firewall rule<\/strong> section, configure the rules you prefer and click <strong>Add Rule<\/strong>.<\/li>\n<\/ol><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"6a58815182efc\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a58815182efc\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"2300\" height=\"1074\" 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\/2024\/04\/hpanel-vps-firewall-configuration-add-rule-highlighted.png\/w=1024,h=1024,fit=scale-down\" alt=\"Adding a new firewall rule on hPanel\" class=\"wp-image-108270\"  sizes=\"auto, (max-width: 2300px) 100vw, 2300px\" \/><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><ol start=\"5\" class=\"wp-block-list\">\n<li>Return to the <strong>Firewall<\/strong> page and click <strong>Activate<\/strong>.<\/li>\n<\/ol><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><p>After setting up your firewall rules using either method, verify the current UFW status with this command:<\/p><pre class=\"wp-block-preformatted\">sudo ufw status<\/pre><h3 class=\"wp-block-heading\" id=\"h-4-restart-the-ssh-service\">4. Restart the SSH service<\/h3><p>Once you&rsquo;ve updated the SSH configurations and firewall rules, it&rsquo;s time to restart the SSH service to apply the new settings.<\/p><p>For systems using <strong>systemd<\/strong>, which is common in newer distributions like Ubuntu, Debian, and CentOS, restart the SSH service by running the following command:<\/p><pre class=\"wp-block-preformatted\">sudo systemctl restart sshd<\/pre><p>For older systems that use <strong>SysVinit<\/strong>, use this command instead:<\/p><pre class=\"wp-block-preformatted\">sudo service ssh restart<\/pre><p>After restarting, verify the SSH service status to make sure everything is running smoothly:<\/p><pre class=\"wp-block-preformatted\">sudo systemctl status sshd<\/pre><h3 class=\"wp-block-heading\" id=\"h-5-verify-the-new-port\">5. Verify the new port<\/h3><p>Now that you&rsquo;ve restarted the SSH service, the final step is verifying that SSH is indeed operating on the new port. This ensures that your changes have been successfully implemented and the server is accessible.<\/p><p><strong>Check the SSH port with ss or netstat<\/strong><\/p><p>If you have <strong>ss<\/strong> installed, use the following command to list active connections, filtering for your new SSH port:<\/p><pre class=\"wp-block-preformatted\">ss -tuln | grep [new_port_number]<\/pre><p>Here&rsquo;s the output you might see:<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"6a588151881bd\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a588151881bd\" class=\"aligncenter size-full wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"884\" height=\"90\" 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\/2024\/04\/terminal-ss.png\/public\" alt=\"The output after running the ss command\" class=\"wp-image-108271\"  sizes=\"auto, (max-width: 884px) 100vw, 884px\" \/><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>If you prefer using the <strong><a href=\"\/ca\/tutorials\/netstat-command\/\">netstat<\/a><\/strong> command, you can check with:<\/p><pre class=\"wp-block-preformatted\">netstat -tuln | grep [new_port_number]<\/pre><p>The output should resemble:<\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"6a5881519467f\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a5881519467f\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1058\" height=\"92\" 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\/2024\/04\/terminal-netstat.png\/w=1024,h=1024,fit=scale-down\" alt=\"The output after executing the netstat command\" class=\"wp-image-108272\"  sizes=\"auto, (max-width: 1058px) 100vw, 1058px\" \/><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>Alternatively, Hostinger VPS users can verify whether the new SSH port is open by asking the <strong>Kodee AI assistant<\/strong>. For example, ask Kodee &ldquo;Check the status of port 61189,&rdquo; and it will output the port status like so. <\/p><div class=\"wp-block-image\"><figure data-wp-context='{\"imageId\":\"6a588151984ea\"}' data-wp-interactive=\"core\/image\" data-wp-key=\"6a588151984ea\" class=\"aligncenter size-large wp-lightbox-container\"><img loading=\"lazy\" decoding=\"async\" width=\"1460\" height=\"450\" 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\/2016\/09\/kodee-checks-port-status.png\/w=1024,h=1024,fit=scale-down\" alt=\"Kodee checks the new SSH port status\" class=\"wp-image-124606\"  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>        <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                    Ask Kodee to manage your firewall                <\/p>\n            <\/div>\n            <p class=\"protip__content\">You can also ask <strong>Kodee<\/strong> to set up a new firewall rule for your VPS. For example, ask it, \"Create and activate a new firewall rule that opens port 66189 TCP to any IP address.\"<\/p>\n                    <\/div>\n        \n\n\n\n<\/p><p><strong>Log in using the new port<\/strong><\/p><p>Open a new terminal window to test connecting to the server with the new SSH port number by executing this command:<\/p><pre class=\"wp-block-preformatted\">ssh -p new_port_number username@server_ip<\/pre><p>Replace <strong>new_port_number<\/strong>, <strong>username<\/strong>, and <strong>server_ip<\/strong> with your specific details.<\/p><p>A successful SSH connection using the new port confirms that your server is functioning correctly with the changes.<\/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> Do not log out of your previous root session until you&rsquo;ve confirmed that the new setup is working correctly.\n            <\/p><\/div>\n\n\n\n<\/p><h2 class=\"wp-block-heading\" id=\"h-conclusion\">Conclusion<\/h2><p>Changing the default SSH port is an effective security measure that can reduce your server&rsquo;s vulnerability to attacks.<\/p><p>By implementing this change along with other best practices, such as using firewalls, regularly updating server packages, and setting up multi-factor authentication, you create a more secure environment for your SSH server.<\/p><p>Remember, security is an ongoing process that benefits from regular attention and adaptation.<\/p><h2 class=\"wp-block-heading\" id=\"h-how-to-change-the-ssh-port-faq\">How to change the SSH port FAQ<\/h2><p>This section will answer the most common questions on how to change the SSH port.<\/p><div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1714135979489\"><h3 class=\"schema-faq-question\">Why should I change the default SSH port?<\/h3> <p class=\"schema-faq-answer\">Changing the default port for SSH reduces your server&rsquo;s visibility to automated attacks and port scans, enhancing security for sensitive data and root access.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1714135988032\"><h3 class=\"schema-faq-question\">What is the best port to choose when changing the default SSH port?<\/h3> <p class=\"schema-faq-answer\">Choose a port above <strong>1024<\/strong> that isn&rsquo;t used by the most common privileged services to minimize conflicts and reduce exposure to attacks.<\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1714135997181\"><h3 class=\"schema-faq-question\">Will changing the SSH port affect my server&rsquo;s performance?<\/h3> <p class=\"schema-faq-answer\">Changing the SSH port does not affect Linux server performance. It merely alters the entry point for SSH connections to improve security.<\/p> <\/div> <\/div><h3 class=\"wp-block-heading\" id=\"h-\"><\/h3>\n","protected":false},"excerpt":{"rendered":"<p>SSH, or Secure Shell, is an essential protocol for securely accessing and managing remote servers. It encrypts all communication, ensuring that data remains protected from unauthorized interception. By default, SSH runs on port 22, which is often targeted by brute force attacks. Changing the default SSH port can significantly enhance security by reducing the likelihood [&#8230;]<\/p>\n<p><a class=\"btn btn-secondary understrap-read-more-link\" href=\"\/ca\/tutorials\/how-to-change-ssh-port-vps\/\">Read More&#8230;<\/a><\/p>\n","protected":false},"author":411,"featured_media":140156,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"rank_math_title":"How to Change the SSH Port on a Linux Server","rank_math_description":"Check this article to learn how to change the default SSH port: 1. Connect to the server through SSH 2. Edit SSH configuration and more.","rank_math_focus_keyword":"change ssh port","footnotes":""},"categories":[22703,22699],"tags":[],"class_list":["post-636","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-managing-monitoring-and-security","category-vps"],"hreflangs":[{"locale":"en-US","link":"https:\/\/www.hostinger.com\/tutorials\/how-to-change-ssh-port-vps","default":0},{"locale":"pt-BR","link":"https:\/\/www.hostinger.com\/br\/tutoriais\/como-alterar-a-porta-ssh-no-linux-vps","default":0},{"locale":"id-ID","link":"https:\/\/www.hostinger.com\/id\/tutorial\/cara-ganti-port-ssh-di-vps","default":0},{"locale":"en-GB","link":"https:\/\/www.hostinger.com\/uk\/tutorials\/how-to-change-ssh-port-vps","default":0},{"locale":"en-MY","link":"https:\/\/www.hostinger.com\/my\/tutorials\/how-to-change-ssh-port-vps","default":0},{"locale":"en-PH","link":"https:\/\/www.hostinger.com\/ph\/tutorials\/how-to-change-ssh-port-vps","default":0},{"locale":"pt-PT","link":"https:\/\/www.hostinger.com\/pt\/tutoriais\/como-alterar-a-porta-ssh-no-linux-vps","default":0},{"locale":"en-IN","link":"https:\/\/www.hostinger.com\/in\/tutorials\/how-to-change-ssh-port-vps","default":0},{"locale":"en-CA","link":"https:\/\/www.hostinger.com\/ca\/tutorials\/how-to-change-ssh-port-vps","default":0},{"locale":"en-AU","link":"https:\/\/www.hostinger.com\/au\/tutorials\/how-to-change-ssh-port-vps","default":0},{"locale":"en-NG","link":"https:\/\/www.hostinger.com\/ng\/tutorials\/how-to-change-ssh-port-vps","default":0}],"_links":{"self":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/636","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\/411"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/comments?post=636"}],"version-history":[{"count":55,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/636\/revisions"}],"predecessor-version":[{"id":140155,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/posts\/636\/revisions\/140155"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/media\/140156"}],"wp:attachment":[{"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/media?parent=636"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/categories?post=636"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hostinger.com\/ca\/tutorials\/wp-json\/wp\/v2\/tags?post=636"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}