{"id":3923,"date":"2016-06-06T17:21:35","date_gmt":"2016-06-06T21:21:35","guid":{"rendered":"https:\/\/www.inmotionhosting.com\/support\/2016\/06\/06\/how-to-use-port-knocking\/"},"modified":"2021-08-16T22:41:10","modified_gmt":"2021-08-17T02:41:10","slug":"how-to-use-port-knocking","status":"publish","type":"post","link":"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/","title":{"rendered":"How to use Port Knocking"},"content":{"rendered":"<p class=\"alert alert-danger\"> <i>Note that you will require <a href=\"\/support\/amp\/obtain-root-access\/\">root access<\/a> in order to use these directions.<\/i><\/p>\n<p>This tutorial will go over how to use port knocking which will be considered an advanced guide and does require you to have root access and have <a href=\"\/support\/security\/install-csf\/\">CSF installed on your server<\/a>. Port knocking is the act of opening ports on your server\u2019s firewall through a series of network requests. This tool is most widely used for your SSH port, WHM\/cPanel ports etc. Port knocking will reduce brute force attacks as it adds a second layer of security to your server.<\/p>\n<h2>   Using the Knock Server feature in CSF<\/h2>\n<p>For this tutorial, we will be opening port 22 as a demonstration. The steps below will enable the port knocking ability to open the port you specify (please keep in mind that you can do this for multiple ports).<\/p>\n<ol class=\"article_list\">\n<li>Log into your Server via <a href=\"\/support\/server\/ssh\/how-to-login-ssh\/\">SSH<\/a> as the \u201c<a href=\"\/support\/amp\/obtain-root-access\/\">root<\/a>\u201d user.<\/li>\n<li>Edit the CSF configuration file.\n<div class=\"cli\"><span style=\"color:red\">vim \/etc\/csf\/csf.conf<\/span><\/div>\n<div style=\"clear:both;\"><\/div>\n<\/li>\n<li>By default, you will see what is in the image to the right after you search for Port Knocking (should be around line 1350).<a href=\"\/support\/images\/stories\/portknocking\/step2.jpg\" rel=\"lightbox-0\"><img decoding=\"async\" alt=\"\" class=\"std_ss\" src=\"\/support\/images\/stories\/portknocking\/step2.jpg\" style=\"float:right; margin:0px 15px 15px 15px;\" title=\"Click here to view the larger image\" width=\"200\"><\/a>\n<div style=\"clear:both;\"><\/div>\n<div style=\"clear:both;\"><\/div>\n<\/li>\n<li>We will make it so that if you send a TCP request on port 1000, a TCP request on 2000, a TCP request on 3000 and lastly another TCP request on port 4050 then the port 22 will open up for the IP sending the request. Feel free to use any ports you like to make the sequence more secure.<a href=\"\/support\/images\/stories\/portknocking\/step3.jpg\" rel=\"lightbox-0\"><img decoding=\"async\" alt=\"\" class=\"std_ss\" src=\"\/support\/images\/stories\/portknocking\/step3.jpg\" style=\"float:right; margin:0px 15px 15px 15px;\" title=\"Click here to view the larger image\" width=\"200\"><\/a>\n<div style=\"clear:both;\"><\/div>\n<div style=\"clear:both;\"><\/div>\n<\/li>\n<li>Save the configuration file (use this command if you used vim).\n<div class=\"cli\"><span style=\"color:red\">:wq<\/span><\/div>\n<div style=\"clear:both;\"><\/div>\n<\/li>\n<li>Restart your CSF.\n<div class=\"cli\"><span style=\"color:red\">csf -r<\/span><\/div>\n<div style=\"clear:both;\"><\/div>\n<\/li>\n<\/ol>\n<h2>   Knocking the ports from Linux<\/h2>\n<p>You can run a command like the one below to knock the ports on the server.<\/p>\n<div class=\"cli\"><span style=\"color:red\">     for x in 1000 2000 3000 4050; do nmap -Pn \u2013host_timeout 201 \u2013max-retries 0 -p $x YourServersIP; done<\/span><\/div>\n<h2>   Knocking the ports from Windows<\/h2>\n<p>If you are trying to use port knocking with Windows, then try using Greg Sowell\u2019s <a href=\"https:\/\/gregsowell.com\/?p=2020\" rel=\"noopener noreferrer\" target=\"_blank\">Windows Port Knock Application<\/a>. After opening the program you would fill out the fields that you set the configuration to in the section above.<\/p>\n<p><a href=\"\/support\/images\/stories\/portknocking\/step4.jpg\" rel=\"lightbox-0\"><img decoding=\"async\" alt=\"\" class=\"std_ss\" src=\"\/support\/images\/stories\/portknocking\/step4.jpg\" style=\"float:right; margin:0px 15px 15px 15px;\" title=\"Click here to view the larger image\" width=\"200\"><\/a><\/p>\n<div style=\"clear:both;\"><\/div>\n<p>To the right is what you should see before you click <strong>Knock<\/strong>.<\/p>\n<div style=\"clear:both;\"><\/div>\n<h2>   Using your phone to knock the ports<\/h2>\n<p>We have found two applications that seem to do the trick, if you are on an android device we suggest the <a href=\"https:\/\/play.google.com\/store\/apps\/details?id=com.xargsgrep.portknocker&amp;hl=en\" target=\"_blank\" rel=\"noopener noreferrer\">Port Knocker<\/a> or if you are running iOS the best option was <a href=\"https:\/\/itunes.apple.com\/us\/app\/portknock\/id358353536?mt=8\" target=\"_blank\" rel=\"noopener noreferrer\">PortKnock<\/a>. Either of these apps will be able to knock your server\u2019s firewall to open the desired ports. Please keep in mind that if you use your phone to unlock a port while on a wifi network it will open the port for any device on the same network.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Note that you will require root access in order to use these directions. This tutorial will go over how to use port knocking which will be considered an advanced guide and does require you to have root access and have CSF installed on your server. Port knocking is the act of opening ports on your<a class=\"moretag\" href=\"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/\"> Read More ><\/a><\/p>\n","protected":false},"author":57014,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4307],"tags":[],"class_list":["post-3923","post","type-post","status-publish","format-standard","hentry","category-ssh"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to use Port Knocking | InMotion Hosting<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to use Port Knocking | InMotion Hosting\" \/>\n<meta property=\"og:description\" content=\"Note that you will require root access in order to use these directions. This tutorial will go over how to use port knocking which will be considered an advanced guide and does require you to have root access and have CSF installed on your server. Port knocking is the act of opening ports on your Read More &gt;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/\" \/>\n<meta property=\"og:site_name\" content=\"InMotion Hosting Support Center\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/inmotionhosting\/\" \/>\n<meta property=\"article:published_time\" content=\"2016-06-06T21:21:35+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-08-17T02:41:10+00:00\" \/>\n<meta name=\"author\" content=\"InMotion Hosting Contributor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/InMotionHosting\" \/>\n<meta name=\"twitter:site\" content=\"@InMotionHosting\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"InMotion Hosting Contributor\" \/>\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\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/\"},\"author\":{\"name\":\"InMotion Hosting Contributor\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644\"},\"headline\":\"How to use Port Knocking\",\"datePublished\":\"2016-06-06T21:21:35+00:00\",\"dateModified\":\"2021-08-17T02:41:10+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/\"},\"wordCount\":442,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"articleSection\":[\"SSH and Root Access\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/\",\"name\":\"How to use Port Knocking | InMotion Hosting\",\"isPartOf\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\"},\"datePublished\":\"2016-06-06T21:21:35+00:00\",\"dateModified\":\"2021-08-17T02:41:10+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.inmotionhosting.com\/support\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to use Port Knocking\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#website\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"name\":\"InMotion Hosting Support Center\",\"description\":\"Web Hosting Support &amp; Tutorials\",\"publisher\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#organization\",\"name\":\"InMotion Hosting\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"contentUrl\":\"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg\",\"width\":696,\"height\":696,\"caption\":\"InMotion Hosting\"},\"image\":{\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/inmotionhosting\/\",\"https:\/\/x.com\/InMotionHosting\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644\",\"name\":\"InMotion Hosting Contributor\",\"description\":\"InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!\",\"sameAs\":[\"https:\/\/www.linkedin.com\/company\/inmotion-hosting\/\",\"https:\/\/x.com\/https:\/\/twitter.com\/InMotionHosting\"],\"url\":\"https:\/\/www.inmotionhosting.com\/support\/author\/inmotion-hosting-contributor\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to use Port Knocking | InMotion Hosting","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.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/","og_locale":"en_US","og_type":"article","og_title":"How to use Port Knocking | InMotion Hosting","og_description":"Note that you will require root access in order to use these directions. This tutorial will go over how to use port knocking which will be considered an advanced guide and does require you to have root access and have CSF installed on your server. Port knocking is the act of opening ports on your Read More >","og_url":"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/","og_site_name":"InMotion Hosting Support Center","article_publisher":"https:\/\/www.facebook.com\/inmotionhosting\/","article_published_time":"2016-06-06T21:21:35+00:00","article_modified_time":"2021-08-17T02:41:10+00:00","author":"InMotion Hosting Contributor","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/InMotionHosting","twitter_site":"@InMotionHosting","twitter_misc":{"Written by":"InMotion Hosting Contributor","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/#article","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/"},"author":{"name":"InMotion Hosting Contributor","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644"},"headline":"How to use Port Knocking","datePublished":"2016-06-06T21:21:35+00:00","dateModified":"2021-08-17T02:41:10+00:00","mainEntityOfPage":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/"},"wordCount":442,"commentCount":0,"publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"articleSection":["SSH and Root Access"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/","url":"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/","name":"How to use Port Knocking | InMotion Hosting","isPartOf":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#website"},"datePublished":"2016-06-06T21:21:35+00:00","dateModified":"2021-08-17T02:41:10+00:00","breadcrumb":{"@id":"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.inmotionhosting.com\/support\/server\/ssh\/how-to-use-port-knocking\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.inmotionhosting.com\/support\/"},{"@type":"ListItem","position":2,"name":"How to use Port Knocking"}]},{"@type":"WebSite","@id":"https:\/\/www.inmotionhosting.com\/support\/#website","url":"https:\/\/www.inmotionhosting.com\/support\/","name":"InMotion Hosting Support Center","description":"Web Hosting Support &amp; Tutorials","publisher":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.inmotionhosting.com\/support\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.inmotionhosting.com\/support\/#organization","name":"InMotion Hosting","url":"https:\/\/www.inmotionhosting.com\/support\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/","url":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","contentUrl":"https:\/\/www.inmotionhosting.com\/support\/wp-content\/uploads\/2023\/02\/inmotion-hosting-logo-yoast.jpg","width":696,"height":696,"caption":"InMotion Hosting"},"image":{"@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/inmotionhosting\/","https:\/\/x.com\/InMotionHosting"]},{"@type":"Person","@id":"https:\/\/www.inmotionhosting.com\/support\/#\/schema\/person\/f9a4fc454cd1df128ee8e898d30d4644","name":"InMotion Hosting Contributor","description":"InMotion Hosting contributors are highly knowledgeable individuals who create relevant content on new trends and troubleshooting techniques to help you achieve your online goals!","sameAs":["https:\/\/www.linkedin.com\/company\/inmotion-hosting\/","https:\/\/x.com\/https:\/\/twitter.com\/InMotionHosting"],"url":"https:\/\/www.inmotionhosting.com\/support\/author\/inmotion-hosting-contributor\/"}]}},"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"primary_category":null,"_links":{"self":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3923","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/users\/57014"}],"replies":[{"embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/comments?post=3923"}],"version-history":[{"count":2,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3923\/revisions"}],"predecessor-version":[{"id":83955,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/posts\/3923\/revisions\/83955"}],"wp:attachment":[{"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/media?parent=3923"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/categories?post=3923"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.inmotionhosting.com\/support\/wp-json\/wp\/v2\/tags?post=3923"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}