{"id":146,"date":"2016-05-01T14:48:56","date_gmt":"2016-05-01T09:18:56","guid":{"rendered":"http:\/\/hostmayo.com\/blog\/?p=146"},"modified":"2016-05-01T15:02:56","modified_gmt":"2016-05-01T09:32:56","slug":"change-default-linux-ssh-port","status":"publish","type":"post","link":"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/","title":{"rendered":"How to change your default Linux SSH port?"},"content":{"rendered":"<p>As being a Linux system administrator, one should monitor SSH log in activities to trace out failed log in attempts. This is required now-a-days because attackers are targeting SSH connections and if you are running SSH service on a default port then you can definitely become a victim of attackers.<\/p>\n<p>All SSH failed log in attempts are saved at <b>\/var\/log\/secure<\/b> file. But it becomes cumbersome job to monitor all such failed log in attempts regularly.<\/p>\n<p>Therefore, implement a very simple and secure way to overcome from the failed SSH attempts is change SSH connection port from the default to any random value. There are just 2 simple steps to change the SSH port. Once you are done with it, your server will become more secure than it was earlier.<\/p>\n<p><b> Step &#8211; 1:-<\/b> Open sshd_config file using any text editor installed in your server<\/p>\n<p><code><span style=\"color: navy;\">$ nano \/etc\/ssh\/sshd_config<\/span><\/code><\/p>\n<p><b> Step &#8211; 2:-<\/b> After opening the configuration file, change the SSH port from 22 to any random number like 6340<\/p>\n<p><code><span style=\"color: navy;\"> $ Port 6340<\/span><\/code><\/p>\n<p><b> Step &#8211; 3:-<\/b> After specifying the new port, save the file and restart the SSH service<\/p>\n<p><code><span style=\"color: navy;\"> $ service sshd restart<\/span><\/code><\/p>\n<p><b> Step &#8211; 4:-<\/b> Now, change the SSH port in iptables rules<\/p>\n<p><code><span style=\"color: navy;\"> $ nano \/etc\/sysconfig\/iptables<\/span><\/code><\/p>\n<p>Here, search port 22 and change it to 6340<\/p>\n<p><b> Step &#8211; 5:-<\/b> After changing the port in iptables, save the file and restart iptables service<\/p>\n<p><code><span style=\"color: navy;\"> $ service iptables restart<\/span><\/code><\/p>\n<p>That&#8217;s it! You are done with all basic settings.<\/p>\n<p>Also your port should be not in use and less than 65536.<\/p>\n<p>Your should be using port <strong>below 1025.<\/strong> By using a well-known port you can prevent a non-root user from setting up their own SSH server that they could use for example to steal passwords of users who log in via SSH. This is because you have to be root to set up a program that can listen on ports below 1024. If you use a port above 1023, someone can crash your SSH server and set up their own SSH server to listen on the same port.<\/p>\n<p><span style=\"color: darkred;\"><b> Important Note: If you are using any Firewall \/ Anti-virus in your server then you have to allow the new SSH port in its configuration as well.<\/b><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>As being a Linux system administrator, one should monitor SSH log in activities to trace out failed log in attempts. This is required now-a-days because [&hellip;] <span class=\"read-more-link\"><a class=\"read-more\" href=\"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/\">Read More<\/a><\/span><\/p>\n","protected":false},"author":1,"featured_media":147,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"footnotes":""},"categories":[7],"tags":[],"class_list":["post-146","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-vps"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v23.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to change your default Linux SSH port?<\/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:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to change your default Linux SSH port?\" \/>\n<meta property=\"og:description\" content=\"As being a Linux system administrator, one should monitor SSH log in activities to trace out failed log in attempts. This is required now-a-days because [&hellip;] Read More\" \/>\n<meta property=\"og:url\" content=\"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/\" \/>\n<meta property=\"og:site_name\" content=\"Host Mayo\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/Hostmayoservers\" \/>\n<meta property=\"article:published_time\" content=\"2016-05-01T09:18:56+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2016-05-01T09:32:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/hostmayo.com\/blog\/wp-content\/uploads\/2016\/05\/centos_1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"250\" \/>\n\t<meta property=\"og:image:height\" content=\"250\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Billa\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@hostmayo\" \/>\n<meta name=\"twitter:site\" content=\"@hostmayo\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Billa\" \/>\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:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/\"},\"author\":{\"name\":\"Billa\",\"@id\":\"https:\/\/hostmayo.com\/blog\/#\/schema\/person\/a511fa95af50c3cb2614311b73c2ea9d\"},\"headline\":\"How to change your default Linux SSH port?\",\"datePublished\":\"2016-05-01T09:18:56+00:00\",\"dateModified\":\"2016-05-01T09:32:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/\"},\"wordCount\":352,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/hostmayo.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/hostmayo.com\/blog\/wp-content\/uploads\/2016\/05\/centos_1.png\",\"articleSection\":[\"vps\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/\",\"url\":\"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/\",\"name\":\"How to change your default Linux SSH port?\",\"isPartOf\":{\"@id\":\"https:\/\/hostmayo.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/hostmayo.com\/blog\/wp-content\/uploads\/2016\/05\/centos_1.png\",\"datePublished\":\"2016-05-01T09:18:56+00:00\",\"dateModified\":\"2016-05-01T09:32:56+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/#primaryimage\",\"url\":\"https:\/\/hostmayo.com\/blog\/wp-content\/uploads\/2016\/05\/centos_1.png\",\"contentUrl\":\"https:\/\/hostmayo.com\/blog\/wp-content\/uploads\/2016\/05\/centos_1.png\",\"width\":250,\"height\":250,\"caption\":\"centos\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/hostmayo.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to change your default Linux SSH port?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/hostmayo.com\/blog\/#website\",\"url\":\"https:\/\/hostmayo.com\/blog\/\",\"name\":\"Host Mayo\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/hostmayo.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/hostmayo.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/hostmayo.com\/blog\/#organization\",\"name\":\"Host Mayo\",\"url\":\"https:\/\/hostmayo.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/hostmayo.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/hostmayo.com\/blog\/wp-content\/uploads\/2015\/12\/ico.png\",\"contentUrl\":\"https:\/\/hostmayo.com\/blog\/wp-content\/uploads\/2015\/12\/ico.png\",\"width\":64,\"height\":64,\"caption\":\"Host Mayo\"},\"image\":{\"@id\":\"https:\/\/hostmayo.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/Hostmayoservers\",\"https:\/\/x.com\/hostmayo\",\"https:\/\/www.linkedin.com\/company\/host-mayo\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/hostmayo.com\/blog\/#\/schema\/person\/a511fa95af50c3cb2614311b73c2ea9d\",\"name\":\"Billa\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/hostmayo.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/55380a32a6c37aba9b35b3d51dbd6cd6460322a433ecdaaacb28aece47163e51?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/55380a32a6c37aba9b35b3d51dbd6cd6460322a433ecdaaacb28aece47163e51?s=96&d=mm&r=g\",\"caption\":\"Billa\"},\"description\":\"Geek, Banker &amp; Entrepreneur.\",\"sameAs\":[\"https:\/\/hostmayo.com\/\"],\"url\":\"https:\/\/hostmayo.com\/blog\/author\/waqass\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to change your default Linux SSH port?","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:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/","og_locale":"en_US","og_type":"article","og_title":"How to change your default Linux SSH port?","og_description":"As being a Linux system administrator, one should monitor SSH log in activities to trace out failed log in attempts. This is required now-a-days because [&hellip;] Read More","og_url":"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/","og_site_name":"Host Mayo","article_publisher":"https:\/\/www.facebook.com\/Hostmayoservers","article_published_time":"2016-05-01T09:18:56+00:00","article_modified_time":"2016-05-01T09:32:56+00:00","og_image":[{"width":250,"height":250,"url":"https:\/\/hostmayo.com\/blog\/wp-content\/uploads\/2016\/05\/centos_1.png","type":"image\/png"}],"author":"Billa","twitter_card":"summary_large_image","twitter_creator":"@hostmayo","twitter_site":"@hostmayo","twitter_misc":{"Written by":"Billa","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/#article","isPartOf":{"@id":"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/"},"author":{"name":"Billa","@id":"https:\/\/hostmayo.com\/blog\/#\/schema\/person\/a511fa95af50c3cb2614311b73c2ea9d"},"headline":"How to change your default Linux SSH port?","datePublished":"2016-05-01T09:18:56+00:00","dateModified":"2016-05-01T09:32:56+00:00","mainEntityOfPage":{"@id":"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/"},"wordCount":352,"commentCount":0,"publisher":{"@id":"https:\/\/hostmayo.com\/blog\/#organization"},"image":{"@id":"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/#primaryimage"},"thumbnailUrl":"https:\/\/hostmayo.com\/blog\/wp-content\/uploads\/2016\/05\/centos_1.png","articleSection":["vps"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/","url":"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/","name":"How to change your default Linux SSH port?","isPartOf":{"@id":"https:\/\/hostmayo.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/#primaryimage"},"image":{"@id":"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/#primaryimage"},"thumbnailUrl":"https:\/\/hostmayo.com\/blog\/wp-content\/uploads\/2016\/05\/centos_1.png","datePublished":"2016-05-01T09:18:56+00:00","dateModified":"2016-05-01T09:32:56+00:00","breadcrumb":{"@id":"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/#primaryimage","url":"https:\/\/hostmayo.com\/blog\/wp-content\/uploads\/2016\/05\/centos_1.png","contentUrl":"https:\/\/hostmayo.com\/blog\/wp-content\/uploads\/2016\/05\/centos_1.png","width":250,"height":250,"caption":"centos"},{"@type":"BreadcrumbList","@id":"https:\/\/hostmayo.com\/blog\/change-default-linux-ssh-port\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/hostmayo.com\/blog\/"},{"@type":"ListItem","position":2,"name":"How to change your default Linux SSH port?"}]},{"@type":"WebSite","@id":"https:\/\/hostmayo.com\/blog\/#website","url":"https:\/\/hostmayo.com\/blog\/","name":"Host Mayo","description":"","publisher":{"@id":"https:\/\/hostmayo.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/hostmayo.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/hostmayo.com\/blog\/#organization","name":"Host Mayo","url":"https:\/\/hostmayo.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/hostmayo.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/hostmayo.com\/blog\/wp-content\/uploads\/2015\/12\/ico.png","contentUrl":"https:\/\/hostmayo.com\/blog\/wp-content\/uploads\/2015\/12\/ico.png","width":64,"height":64,"caption":"Host Mayo"},"image":{"@id":"https:\/\/hostmayo.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/Hostmayoservers","https:\/\/x.com\/hostmayo","https:\/\/www.linkedin.com\/company\/host-mayo"]},{"@type":"Person","@id":"https:\/\/hostmayo.com\/blog\/#\/schema\/person\/a511fa95af50c3cb2614311b73c2ea9d","name":"Billa","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/hostmayo.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/55380a32a6c37aba9b35b3d51dbd6cd6460322a433ecdaaacb28aece47163e51?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/55380a32a6c37aba9b35b3d51dbd6cd6460322a433ecdaaacb28aece47163e51?s=96&d=mm&r=g","caption":"Billa"},"description":"Geek, Banker &amp; Entrepreneur.","sameAs":["https:\/\/hostmayo.com\/"],"url":"https:\/\/hostmayo.com\/blog\/author\/waqass\/"}]}},"jetpack_featured_media_url":"https:\/\/hostmayo.com\/blog\/wp-content\/uploads\/2016\/05\/centos_1.png","_links":{"self":[{"href":"https:\/\/hostmayo.com\/blog\/wp-json\/wp\/v2\/posts\/146","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hostmayo.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hostmayo.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hostmayo.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hostmayo.com\/blog\/wp-json\/wp\/v2\/comments?post=146"}],"version-history":[{"count":0,"href":"https:\/\/hostmayo.com\/blog\/wp-json\/wp\/v2\/posts\/146\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hostmayo.com\/blog\/wp-json\/wp\/v2\/media\/147"}],"wp:attachment":[{"href":"https:\/\/hostmayo.com\/blog\/wp-json\/wp\/v2\/media?parent=146"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hostmayo.com\/blog\/wp-json\/wp\/v2\/categories?post=146"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hostmayo.com\/blog\/wp-json\/wp\/v2\/tags?post=146"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}