{"id":20822,"date":"2025-08-19T10:36:40","date_gmt":"2025-08-19T10:36:40","guid":{"rendered":"https:\/\/www.webhosting.uk.com\/kb\/?p=20822"},"modified":"2026-06-03T10:11:53","modified_gmt":"2026-06-03T10:11:53","slug":"how-to-restrict-ssh-access-by-ip-address-on-linux-servers","status":"publish","type":"post","link":"https:\/\/www.webhosting.uk.com\/kb\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\/","title":{"rendered":"How to Restrict SSH Access by IP Address on Linux Servers"},"content":{"rendered":"<p>This guide helps you keep your Linux server safe by allowing only trusted people to connect to it via SSH. SSH is like a secure door to your server, and you can control who gets through.<br \/>\nWe will show you how to allow only specific computers (by their IP address) to log in, and block everyone else. This helps stop hackers from trying to guess your password.<\/p>\n<div class=\"more-tab-content\">\n<h2><strong>Table of Contents<\/strong><\/h2>\n<ol>\n<li><a href=\"#matter\">Why does this matter?<\/a><\/li>\n<li><a href=\"#start\">Important safety tips before you start<\/a><\/li>\n<li><a href=\"#different\">Different methods to restrict SSH Access<\/a><\/li>\n<li><a href=\"#setup\">How to Test Your Setup?<\/a><\/li>\n<li><a href=\"#works\">How to Verify Everything Works Well?<\/a><\/li>\n<li><a href=\"#everyone\">Best Practices for Everyone<\/a><a name=\"matter\"><\/a><\/li>\n<li><a href=\"#system\">SSH Access Compatibility by Operating System<\/a><\/li>\n<li><a href=\"#troubleshooting\">Troubleshooting<\/a><\/li>\n<\/ol>\n<\/div>\n<h3><strong>Why does this matter?<\/strong><\/h3>\n<ul>\n<li>Hackers frequently attempt password guessing (also known as &#8220;brute force attacks&#8221;).<\/li>\n<li>Hackers will find it far more difficult to gain access if you only let trusted <a name=\"start\"><\/a>computers connect.<\/li>\n<li>No one else can log in, but you can still do so from your laptop, phone, or business computer.<\/li>\n<\/ul>\n<h3><strong>Important safety tips before you start<\/strong><\/h3>\n<ol>\n<li>When testing, keep your SSH session open and never close it.<\/li>\n<li>Maintain a backup method of accessing your server, such as a console or KVM.<\/li>\n<li>Before making any changes, always create a backup of your configuration.<\/li>\n<li>Carefully test; if something goes wrong, you can revert to the previous configuration.<\/li>\n<\/ol>\n<p><strong>Backup command:<\/strong><\/p>\n<pre>sudo cp \/etc\/ssh\/sshd_config \/etc\/ssh\/sshd_config.backup<\/pre>\n<p class=\"pf0\"><strong><span class=\"cf0\">Disable Root Login <\/span><\/strong><\/p>\n<p class=\"pf0\"><span class=\"cf0\"> The root account is the most powerful on your server. If hackers guess the password, they can take full control. Disabling root login adds a big layer of security.<\/span><\/p>\n<ol>\n<li>Open the SSH configuration file:\n<pre>sudo nano \/etc\/ssh\/sshd_config<\/pre>\n<\/li>\n<li>Find the line that says:\n<pre>PermitRootLogin yes<\/pre>\n<\/li>\n<li>Change it to:\n<pre>PermitRootLogin no<\/pre>\n<\/li>\n<li>Save the file and restart SSH:\n<pre>sudo systemctl restart sshd<\/pre>\n<p>Note: You can still log in as root using sudo after logging in as a regular user.<\/li>\n<\/ol>\n<p class=\"pf0\"><strong><span class=\"cf0\">Change the SSH Default Port <\/span><\/strong><\/p>\n<p class=\"pf0\"><span class=\"cf0\"> Port 22 is the most targeted port by hackers. Changing it to something like 2222 or 4444 makes your server less visible to automated attacks. <\/span><\/p>\n<ol>\n<li>In the same file (\/etc\/ssh\/sshd_config), find the line:\n<pre>#Port 22<\/pre>\n<\/li>\n<li>Uncomment it (remove the #) and change it to a new port:\n<pre>Port 2222<\/pre>\n<\/li>\n<li>Save the file and restart SSH:\n<pre>sudo systemctl restart sshd<\/pre>\n<p>Important: Ensure your firewall allows the new port!<\/li>\n<li>For example, <a name=\"different\"><\/a>if you use firewalld, run:\n<pre>sudo firewall-cmd --permanent --add-port=2222\/tcp\r\nsudo firewall-cmd --reload<\/pre>\n<\/li>\n<\/ol>\n<h3><strong>Different methods to restrict SSH Access<\/strong><\/h3>\n<p class=\"pf0\"><span class=\"cf0\"><strong>Method 1: Use the SSH Settings File (Best for All Systems)<\/strong><br \/>\n<\/span>You can alter the SSH settings to only allow certain people from specific computers.<\/p>\n<p><strong>Option A: Allow Only Specific Users from Specific IPs<\/strong><br \/>\nLet&#8217;s say you have a user named John and you only want him to be able to log in from a computer that has the IP address 192.168.1.10, such as your home computer.<\/p>\n<p>Step-by-step:<\/p>\n<ol>\n<li>Open the SSH settings file:\n<pre>sudo nano \/etc\/ssh\/sshd_config<\/pre>\n<\/li>\n<li>Add this line:\n<pre>AllowUsers john@192.168.1.10<\/pre>\n<p>This means: &#8220;Only user John can log in, and only from the computer at 192.168.1.10.&#8221;<\/li>\n<li>Save the file and restart SSH:\n<pre>sudo systemctl restart sshd<\/pre>\n<\/li>\n<li><span class=\"cf0\">Test: Try to log in from your trusted computer; <\/span><span class=\"cf1\">it should work.<\/span><\/li>\n<\/ol>\n<p><strong>\u00a0Option B: Use More Advanced Rules (For Complex Needs)<br \/>\n<\/strong>\u00a0 You can also say:<br \/>\n<span class=\"cf1\">\u00a0 &#8220;Allow J<\/span><span class=\"cf0\">ohn from 192.168.1.10&#8243;<br \/>\n<\/span><span class=\"cf1\">\u00a0 &#8220;But block J<\/span><span class=\"cf0\">ohn from all other computers&#8221;<\/span><\/p>\n<p>Step-by-step:<\/p>\n<ol>\n<li style=\"list-style-type: none;\">\n<ol>\n<li>Open the SSH settings file:\n<pre>sudo nano \/etc\/ssh\/sshd_config<\/pre>\n<\/li>\n<li>Add this:<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<pre>Match User john Address 192.168.1.10\r\nPasswordAuthentication<span class=\"cf0\"> yes\r\n<\/span>Match User john Address ! 192.168.1.10\r\nDenyUsers john<\/pre>\n<ol>\n<li style=\"list-style-type: none;\">\n<ul>\n<li>This means: &#8220;If John tries to log in from 192.168.1.10, allow it.<\/li>\n<li>If John tries to log in from any other computer, block it.<\/li>\n<\/ul>\n<\/li>\n<li>Save the file and restart SSH:\n<pre>sudo systemctl restart sshd<\/pre>\n<\/li>\n<\/ol>\n<p><strong>Method 2: Use TCP Wrappers (Only for Older Systems)<\/strong><\/p>\n<p class=\"pf0\"><span class=\"cf0\">Important: This method only works on older Linux systems like CentOS 7. It doesn\u2019t work on modern systems like AlmaLinux 8+, Rocky Linux 8+, or Ubuntu 20.04+. <\/span><\/p>\n<p class=\"pf0\"><span class=\"cf0\">If you are using a newer system, skip this method. <\/span><\/p>\n<p>How It Works:<\/p>\n<ul>\n<li>You can create a list of allowed IPs.<\/li>\n<li>Any computer not on the list will be blocked.<\/li>\n<\/ul>\n<p>Step-by-step:<\/p>\n<ol>\n<li>Open the allowed list:\n<pre>sudo nano \/etc\/hosts.allow<\/pre>\n<\/li>\n<li>Add your trusted IP:\n<pre>sshd: 192.168.1.10<\/pre>\n<\/li>\n<li>Open the blocked list:\n<pre>sudo nano \/etc\/hosts.deny<\/pre>\n<\/li>\n<li>Add this line:\n<pre>sshd: ALL<\/pre>\n<p>This means: &#8220;Block everyone except the IPs listed in \/etc\/hosts.allow.&#8221;<\/li>\n<li>No restart required; changes take effect immediately.<\/li>\n<\/ol>\n<p class=\"pf0\"><strong><span class=\"cf1\">Method 3: Use a Firewall (Best for Modern Systems)<br \/>\n<\/span><\/strong><span class=\"cf1\">Modern systems like <\/span><span class=\"cf0\">AlmaLinux 8+, Rocky Linux 8+, and Ubuntu 20.04+ do not support TCP wrappers. So we use a firewall instead.<\/span><\/p>\n<p class=\"pf0\"><!--StartFragment --><\/p>\n<p class=\"pf0\"><span class=\"cf0\">A firewall controls who can enter, much like a security guard at the door.<\/span><\/p>\n<p class=\"pf0\"><strong><span class=\"cf1\">For AlmaLinux, CentOS 8+, or Rocky Linux:<\/span><\/strong><\/p>\n<ol>\n<li>Open the firewall:\n<pre>sudo firewall-cmd --permanent --add-rich-rule='rule family=\"ipv4\" source address=\"192.168.1.10\" service name=\"ssh\" accept'<\/pre>\n<p>This means: &#8220;Allow SSH access only from <span class=\"cf0\">192.168.1.10.&#8221;<\/span><\/li>\n<li>Apply the changes:\n<pre>sudo firewall-cmd --reload<\/pre>\n<\/li>\n<li>Check if it is working:\n<pre>sudo firewall-cmd --list-all<\/pre>\n<\/li>\n<\/ol>\n<p class=\"pf0\"><strong><span class=\"cf0\">For Ubuntu or Debian:<\/span><\/strong><\/p>\n<ol>\n<li>Open the firewall:\n<pre>sudo ufw allow from 192.168.1.10 to any port 22<\/pre>\n<\/li>\n<li>Enable <a name=\"setup\"><\/a>the firewall:\n<pre>sudo ufw enable<\/pre>\n<\/li>\n<li>Check rules:\n<pre>sudo ufw status verbose<\/pre>\n<\/li>\n<\/ol>\n<h3 class=\"pf0\"><strong><span class=\"cf0\">How to Test Your Setup?<\/span><\/strong><\/h3>\n<ol>\n<li><span class=\"cf0\">Keep your current SSH session open,<\/span><span class=\"cf1\">\u00a0don\u2019t close it.<\/span><\/li>\n<li><span class=\"cf1\">Open a <\/span><span class=\"cf0\">new terminal.<\/span><\/li>\n<li>Try to log in from your trusted computer:\n<pre>ssh <span class=\"cf0\">john@your-server-ip\r\n<\/span><\/pre>\n<p>It should <a name=\"works\"><\/a>work.<\/li>\n<li>Try from<a name=\"works\"><\/a> a different computer:<br \/>\nIt should fail or time out.<\/li>\n<\/ol>\n<p><!--StartFragment --><\/p>\n<h3 class=\"pf0\"><strong><span class=\"cf0\">How to Verify Everything Works Well?<\/span><\/strong><\/h3>\n<ol>\n<li>Check if your rules are active:\n<pre>sudo sshd -T | grep -i allow<\/pre>\n<\/li>\n<li>Check <a name=\"everyone\"><\/a>firewall rules:\n<pre>sudo firewall-cmd --list-all<\/pre>\n<\/li>\n<li>Check logs for failed attempts:\n<pre>sudo tail -f \/var\/log\/auth.log<\/pre>\n<\/li>\n<\/ol>\n<p><!--StartFragment --><\/p>\n<h3><strong>Best Practices for Everyone<\/strong><\/h3>\n<ol>\n<li class=\"pf0\">Use a firewall;<span class=\"cf1\">\u00a0it\u2019s the most reliable method on modern systems.<\/span><\/li>\n<li>Use SSH keys instead of passwords, and use special keys (like a digital ID card).<\/li>\n<li>Keep your server updated and install security patches regularly.<\/li>\n<li>Document your allowed IPs; write <a name=\"system\"><\/a>down which computers can connect.<\/li>\n<li>Use a VPN; instead of opening SSH to the internet, use a private network.<\/li>\n<\/ol>\n<p><!--StartFragment --><\/p>\n<h3><strong>SSH Access Compatibility by Operating System<\/strong><\/h3>\n<ul>\n<li class=\"pf0\"><span class=\"cf0\">AlmaLinux 8+ \/ Rocky Linux 8+ \/ CentOS 8+<br \/>\n<\/span>These modern RHEL-based systems work best with SSH settings + firewall rules.<\/li>\n<li>CentOS 7<br \/>\nOlder OS versions where TCP Wrappers are <a name=\"troubleshooting\"><\/a>still supported, along with normal SSH configuration.<\/li>\n<li>Ubuntu 20.04+ \/ Debian 10+<br \/>\nThese Debian-based systems commonly use SSH settings + UFW for access management.<\/li>\n<\/ul>\n<p><!--StartFragment --><\/p>\n<h3><strong>Troubleshooting<\/strong><\/h3>\n<p class=\"pf0\"><span class=\"cf0\">If you get locked out:<\/span><\/p>\n<ol>\n<li class=\"pf0\"><span class=\"cf0\">Use <\/span><span class=\"cf1\"><strong>console access<\/strong> (like a KVM or remote console).<\/span><\/li>\n<li>Restore the backup:\n<pre>sudo cp \/etc\/ssh\/<span class=\"cf1\">sshd_config.backup<\/span><span class=\"cf1\"> \/etc\/ssh\/sshd_config<\/span><\/pre>\n<\/li>\n<li>Restart SSH:\n<pre>sudo systemctl restart sshd<\/pre>\n<\/li>\n<li>If rules don\u2019t work:\n<ol>\n<li>Check for typos in the IP address.<\/li>\n<li>Make sure the service was restarted.<\/li>\n<li>Verify the firewall is not blocking SSH.<\/li>\n<\/ol>\n<\/li>\n<\/ol>\n<p>In this manner, <span class=\"TextRun SCXW61663371 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW61663371 BCX8\">your server?is <\/span><\/span><span class=\"TextRun SCXW61663371 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW61663371 BCX8\">much safer<\/span><\/span><span class=\"TextRun SCXW61663371 BCX8\" lang=\"EN-US\" xml:lang=\"EN-US\" data-contrast=\"none\"><span class=\"NormalTextRun SCXW61663371 BCX8\">?from hackers.<\/span><\/span> It significantly strengthens SSH security and helps safeguard your server against illegal logins.<\/p>\n<div style=\"background: #E6F0FF; padding: 15px; border-left: 4px solid #0047BA; margin: 20px 0;\"><strong>Restricting SSH access and strengthening server security?<\/strong><br \/>\nA <a href=\"https:\/\/www.webhosting.uk.com\/linux-vps\">Linux VPS Hosting<\/a> solution provides full root access and the flexibility needed to manage SSH policies, firewall rules and secure remote administration.<\/div>\n<p style=\"text-align: center;\"><em><strong>Want to secure access in Plesk too? Learn <a href=\"https:\/\/www.webhosting.uk.com\/kb\/how-to-restrict-ip-address-for-administrator-access-in-plesk\/\">How to restrict IP address for administrator access in Plesk<\/a><\/strong><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This guide helps you keep your Linux server safe by allowing only trusted people to connect to it via SSH. SSH is like a secure door to your server, and&hellip;<\/p>\n<p><a href=\"https:\/\/www.webhosting.uk.com\/kb\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\/\" class=\"more-link\">Read More<\/a><\/p>\n<div class='heateorSssClear'><\/div><div  class='heateor_sss_sharing_container heateor_sss_horizontal_sharing' data-heateor-sss-href='https:\/\/www.webhosting.uk.com\/kb\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\/'><div class='heateor_sss_sharing_title' style=\"font-weight:bold\" >Spread the love<\/div><div class=\"heateor_sss_sharing_ul\"><a aria-label=\"Facebook\" class=\"heateor_sss_facebook\" href=\"https:\/\/www.facebook.com\/sharer\/sharer.php?u=https%3A%2F%2Fwww.webhosting.uk.com%2Fkb%2Fhow-to-restrict-ssh-access-by-ip-address-on-linux-servers%2F\" title=\"Facebook\" rel=\"nofollow noopener\" target=\"_blank\" style=\"font-size:32px!important;box-shadow:none;display:inline-block;vertical-align:middle\"><span class=\"heateor_sss_svg\" style=\"background-color:#0765FE;width:40px;height:40px;display:inline-block;opacity:1;float:left;font-size:32px;box-shadow:none;display:inline-block;font-size:16px;padding:0 4px;vertical-align:middle;background-repeat:repeat;overflow:hidden;padding:0;cursor:pointer;box-sizing:content-box\"><svg style=\"display:block;\" focusable=\"false\" aria-hidden=\"true\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 32 32\"><path fill=\"#fff\" d=\"M28 16c0-6.627-5.373-12-12-12S4 9.373 4 16c0 5.628 3.875 10.35 9.101 11.647v-7.98h-2.474V16H13.1v-1.58c0-4.085 1.849-5.978 5.859-5.978.76 0 2.072.15 2.608.298v3.325c-.283-.03-.775-.045-1.386-.045-1.967 0-2.728.745-2.728 2.683V16h3.92l-.673 3.667h-3.247v8.245C23.395 27.195 28 22.135 28 16Z\"><\/path><\/svg><\/span><\/a><a aria-label=\"X\" class=\"heateor_sss_button_x\" href=\"https:\/\/twitter.com\/intent\/tweet?text=Restrict%20SSH%20Access%20by%20IP%20on%20Linux%20Servers%20-%20WHUK&url=https%3A%2F%2Fwww.webhosting.uk.com%2Fkb%2Fhow-to-restrict-ssh-access-by-ip-address-on-linux-servers%2F\" title=\"X\" rel=\"nofollow noopener\" target=\"_blank\" style=\"font-size:32px!important;box-shadow:none;display:inline-block;vertical-align:middle\"><span class=\"heateor_sss_svg heateor_sss_s__default heateor_sss_s_x\" style=\"background-color:#2a2a2a;width:40px;height:40px;display:inline-block;opacity:1;float:left;font-size:32px;box-shadow:none;display:inline-block;font-size:16px;padding:0 4px;vertical-align:middle;background-repeat:repeat;overflow:hidden;padding:0;cursor:pointer;box-sizing:content-box\"><svg width=\"100%\" height=\"100%\" style=\"display:block;\" focusable=\"false\" aria-hidden=\"true\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" viewBox=\"0 0 32 32\"><path fill=\"#fff\" d=\"M21.751 7h3.067l-6.7 7.658L26 25.078h-6.172l-4.833-6.32-5.531 6.32h-3.07l7.167-8.19L6 7h6.328l4.37 5.777L21.75 7Zm-1.076 16.242h1.7L11.404 8.74H9.58l11.094 14.503Z\"><\/path><\/svg><\/span><\/a><a aria-label=\"Linkedin\" class=\"heateor_sss_button_linkedin\" href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=https%3A%2F%2Fwww.webhosting.uk.com%2Fkb%2Fhow-to-restrict-ssh-access-by-ip-address-on-linux-servers%2F\" title=\"Linkedin\" rel=\"nofollow noopener\" target=\"_blank\" style=\"font-size:32px!important;box-shadow:none;display:inline-block;vertical-align:middle\"><span class=\"heateor_sss_svg heateor_sss_s__default heateor_sss_s_linkedin\" style=\"background-color:#0077b5;width:40px;height:40px;display:inline-block;opacity:1;float:left;font-size:32px;box-shadow:none;display:inline-block;font-size:16px;padding:0 4px;vertical-align:middle;background-repeat:repeat;overflow:hidden;padding:0;cursor:pointer;box-sizing:content-box\"><svg style=\"display:block;\" focusable=\"false\" aria-hidden=\"true\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"100%\" height=\"100%\" viewBox=\"0 0 32 32\"><path d=\"M6.227 12.61h4.19v13.48h-4.19V12.61zm2.095-6.7a2.43 2.43 0 0 1 0 4.86c-1.344 0-2.428-1.09-2.428-2.43s1.084-2.43 2.428-2.43m4.72 6.7h4.02v1.84h.058c.56-1.058 1.927-2.176 3.965-2.176 4.238 0 5.02 2.792 5.02 6.42v7.395h-4.183v-6.56c0-1.564-.03-3.574-2.178-3.574-2.18 0-2.514 1.7-2.514 3.46v6.668h-4.187V12.61z\" fill=\"#fff\"><\/path><\/svg><\/span><\/a><\/div><div class=\"heateorSssClear\"><\/div><\/div><div class='heateorSssClear'><\/div>","protected":false},"author":28,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1409],"tags":[204],"class_list":["post-20822","post","type-post","status-publish","format-standard","hentry","category-server","tag-linux"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.9 (Yoast SEO v27.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Restrict SSH Access by IP on Linux Servers - WHUK<\/title>\n<meta name=\"description\" content=\"Learn how to restrict SSH access by IP address on Linux servers using sshd_config, TCP wrappers, and firewall rules to improve security.\" \/>\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.webhosting.uk.com\/kb\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\/\" \/>\n<meta property=\"og:locale\" content=\"en_GB\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Restrict SSH Access by IP on Linux Servers - WHUK\" \/>\n<meta property=\"og:description\" content=\"Learn how to restrict SSH access by IP address on Linux servers using sshd_config, TCP wrappers, and firewall rules to improve security.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webhosting.uk.com\/kb\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\/\" \/>\n<meta property=\"og:site_name\" content=\"Webhosting UK Knowledge Base\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webhostingukcom\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-19T10:36:40+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-03T10:11:53+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2023\/08\/WHUK-logo-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Victor G\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Restrict SSH Access by IP on Linux Servers - WHUK\" \/>\n<meta name=\"twitter:description\" content=\"Learn how to restrict SSH access by IP address on Linux servers using sshd_config, TCP wrappers, and firewall rules to improve security.\" \/>\n<meta name=\"twitter:creator\" content=\"@WebhostingUKcom\" \/>\n<meta name=\"twitter:site\" content=\"@WebhostingUKcom\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\\\/\"},\"author\":{\"name\":\"Victor G\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#\\\/schema\\\/person\\\/ea067684eae84c2b8b49a81c69407297\"},\"headline\":\"How to Restrict SSH Access by IP Address on Linux Servers\",\"datePublished\":\"2025-08-19T10:36:40+00:00\",\"dateModified\":\"2026-06-03T10:11:53+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\\\/\"},\"wordCount\":1004,\"publisher\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#organization\"},\"keywords\":[\"Linux\"],\"articleSection\":[\"Servers, Hosting &amp; Email\"],\"inLanguage\":\"en-GB\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\\\/\",\"url\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\\\/\",\"name\":\"Restrict SSH Access by IP on Linux Servers - WHUK\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#website\"},\"datePublished\":\"2025-08-19T10:36:40+00:00\",\"dateModified\":\"2026-06-03T10:11:53+00:00\",\"description\":\"Learn how to restrict SSH access by IP address on Linux servers using sshd_config, TCP wrappers, and firewall rules to improve security.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\\\/#breadcrumb\"},\"inLanguage\":\"en-GB\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Restrict SSH Access by IP Address on Linux Servers\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#website\",\"url\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/\",\"name\":\"Webhosting UK Knowledge Base\",\"description\":\"Expert Insights on Hosting, Development, Security, Marketing, and SEO\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#organization\"},\"alternateName\":\"WHUK\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-GB\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#organization\",\"name\":\"Webhosting UK\",\"alternateName\":\"WHUK\",\"url\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/WHUK-logo-1.png\",\"contentUrl\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/wp-content\\\/uploads\\\/2023\\\/08\\\/WHUK-logo-1.png\",\"width\":1200,\"height\":628,\"caption\":\"Webhosting UK\"},\"image\":{\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/webhostingukcom\",\"https:\\\/\\\/x.com\\\/WebhostingUKcom\",\"https:\\\/\\\/www.youtube.com\\\/c\\\/webhostinguk\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/webhosting-uk-com-ltd\\\/\",\"https:\\\/\\\/www.instagram.com\\\/webhosting_uk\\\/\",\"https:\\\/\\\/www.tiktok.com\\\/@webhostinguk\"],\"description\":\"Fast, reliable, and cost-effective website hosting services with Webhosting UK. Committed to providing you secure support around the clock.\",\"email\":\"sales@webhosting.uk.com\",\"telephone\":\"0800 862 0890\",\"legalName\":\"Webhosting UK\",\"foundingDate\":\"2001-02-07\",\"numberOfEmployees\":{\"@type\":\"QuantitativeValue\",\"minValue\":\"51\",\"maxValue\":\"200\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.webhosting.uk.com\\\/kb\\\/#\\\/schema\\\/person\\\/ea067684eae84c2b8b49a81c69407297\",\"name\":\"Victor G\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-GB\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9bf0713adcbaded4878508c93d93927ecbfa4f74548fd9bcee41478d8768bd66?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9bf0713adcbaded4878508c93d93927ecbfa4f74548fd9bcee41478d8768bd66?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/9bf0713adcbaded4878508c93d93927ecbfa4f74548fd9bcee41478d8768bd66?s=96&d=mm&r=g\",\"caption\":\"Victor G\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Restrict SSH Access by IP on Linux Servers - WHUK","description":"Learn how to restrict SSH access by IP address on Linux servers using sshd_config, TCP wrappers, and firewall rules to improve security.","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.webhosting.uk.com\/kb\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\/","og_locale":"en_GB","og_type":"article","og_title":"Restrict SSH Access by IP on Linux Servers - WHUK","og_description":"Learn how to restrict SSH access by IP address on Linux servers using sshd_config, TCP wrappers, and firewall rules to improve security.","og_url":"https:\/\/www.webhosting.uk.com\/kb\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\/","og_site_name":"Webhosting UK Knowledge Base","article_publisher":"https:\/\/www.facebook.com\/webhostingukcom","article_published_time":"2025-08-19T10:36:40+00:00","article_modified_time":"2026-06-03T10:11:53+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2023\/08\/WHUK-logo-1.png","type":"image\/png"}],"author":"Victor G","twitter_card":"summary_large_image","twitter_title":"Restrict SSH Access by IP on Linux Servers - WHUK","twitter_description":"Learn how to restrict SSH access by IP address on Linux servers using sshd_config, TCP wrappers, and firewall rules to improve security.","twitter_creator":"@WebhostingUKcom","twitter_site":"@WebhostingUKcom","schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\/#article","isPartOf":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\/"},"author":{"name":"Victor G","@id":"https:\/\/www.webhosting.uk.com\/kb\/#\/schema\/person\/ea067684eae84c2b8b49a81c69407297"},"headline":"How to Restrict SSH Access by IP Address on Linux Servers","datePublished":"2025-08-19T10:36:40+00:00","dateModified":"2026-06-03T10:11:53+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\/"},"wordCount":1004,"publisher":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/#organization"},"keywords":["Linux"],"articleSection":["Servers, Hosting &amp; Email"],"inLanguage":"en-GB"},{"@type":"WebPage","@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\/","url":"https:\/\/www.webhosting.uk.com\/kb\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\/","name":"Restrict SSH Access by IP on Linux Servers - WHUK","isPartOf":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/#website"},"datePublished":"2025-08-19T10:36:40+00:00","dateModified":"2026-06-03T10:11:53+00:00","description":"Learn how to restrict SSH access by IP address on Linux servers using sshd_config, TCP wrappers, and firewall rules to improve security.","breadcrumb":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\/#breadcrumb"},"inLanguage":"en-GB","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webhosting.uk.com\/kb\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.webhosting.uk.com\/kb\/how-to-restrict-ssh-access-by-ip-address-on-linux-servers\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webhosting.uk.com\/kb\/"},{"@type":"ListItem","position":2,"name":"How to Restrict SSH Access by IP Address on Linux Servers"}]},{"@type":"WebSite","@id":"https:\/\/www.webhosting.uk.com\/kb\/#website","url":"https:\/\/www.webhosting.uk.com\/kb\/","name":"Webhosting UK Knowledge Base","description":"Expert Insights on Hosting, Development, Security, Marketing, and SEO","publisher":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/#organization"},"alternateName":"WHUK","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webhosting.uk.com\/kb\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-GB"},{"@type":"Organization","@id":"https:\/\/www.webhosting.uk.com\/kb\/#organization","name":"Webhosting UK","alternateName":"WHUK","url":"https:\/\/www.webhosting.uk.com\/kb\/","logo":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/www.webhosting.uk.com\/kb\/#\/schema\/logo\/image\/","url":"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2023\/08\/WHUK-logo-1.png","contentUrl":"https:\/\/www.webhosting.uk.com\/kb\/wp-content\/uploads\/2023\/08\/WHUK-logo-1.png","width":1200,"height":628,"caption":"Webhosting UK"},"image":{"@id":"https:\/\/www.webhosting.uk.com\/kb\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webhostingukcom","https:\/\/x.com\/WebhostingUKcom","https:\/\/www.youtube.com\/c\/webhostinguk","https:\/\/www.linkedin.com\/company\/webhosting-uk-com-ltd\/","https:\/\/www.instagram.com\/webhosting_uk\/","https:\/\/www.tiktok.com\/@webhostinguk"],"description":"Fast, reliable, and cost-effective website hosting services with Webhosting UK. Committed to providing you secure support around the clock.","email":"sales@webhosting.uk.com","telephone":"0800 862 0890","legalName":"Webhosting UK","foundingDate":"2001-02-07","numberOfEmployees":{"@type":"QuantitativeValue","minValue":"51","maxValue":"200"}},{"@type":"Person","@id":"https:\/\/www.webhosting.uk.com\/kb\/#\/schema\/person\/ea067684eae84c2b8b49a81c69407297","name":"Victor G","image":{"@type":"ImageObject","inLanguage":"en-GB","@id":"https:\/\/secure.gravatar.com\/avatar\/9bf0713adcbaded4878508c93d93927ecbfa4f74548fd9bcee41478d8768bd66?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/9bf0713adcbaded4878508c93d93927ecbfa4f74548fd9bcee41478d8768bd66?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/9bf0713adcbaded4878508c93d93927ecbfa4f74548fd9bcee41478d8768bd66?s=96&d=mm&r=g","caption":"Victor G"}}]}},"_links":{"self":[{"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/posts\/20822","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/users\/28"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/comments?post=20822"}],"version-history":[{"count":65,"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/posts\/20822\/revisions"}],"predecessor-version":[{"id":22726,"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/posts\/20822\/revisions\/22726"}],"wp:attachment":[{"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/media?parent=20822"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/categories?post=20822"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webhosting.uk.com\/kb\/wp-json\/wp\/v2\/tags?post=20822"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}