{"id":63,"date":"2014-02-14T14:51:07","date_gmt":"2014-02-14T14:51:07","guid":{"rendered":"https:\/\/qbytes.cloud\/?p=56"},"modified":"2014-02-14T14:51:07","modified_gmt":"2014-02-14T14:51:07","slug":"change-openssh-port-centos","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2014\/02\/14\/change-openssh-port-centos\/","title":{"rendered":"Change OpenSSH Port CentOS"},"content":{"rendered":"<p>Want to change the ssh port for ssh? Here is a good tutorial.<br \/>\n(Note: If you are making these changes &#8211; ssh to the server and keep the terminal open as you make the changes. Test with a new terminal. This way if something is amiss &#8211; you are not locked out.)<\/p>\n<p>Edit \/etc\/ssh\/sshd_config, enter:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# vi \/etc\/ssh\/sshd_config\n<\/pre>\n<p>Note:<br \/>\nThe strategy used for options in the default sshd_config shipped with OpenSSH is to specify options with their default value where possible, but leave them commented. Uncommented options change a default value.<\/p>\n<p>Uncomment the following and edit to set the port to 10221:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\nPort 10221\n<\/pre>\n<p>ListenAddress option<\/p>\n<p>Note: If you have multiple IP address on the server, add you IP addresses.<\/p>\n<p>ListenAddress as follows :<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n## bind sshd to two ip address on a non-standard port ##\nListenAddress 192.168.1.5:10221\nListenAddress 203.1.2.3:10221\n<\/pre>\n<p>Save and close the file.<\/p>\n<p>Before you restart or reload sshd server. You need to update SELinux configuration or Firewall settings (iptables).<\/p>\n<p>You also need to update firewall settings so that users can login using TCP # 10221. Edit, <\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\/etc\/sysconfig\/iptables and open sshd port 10221:\n# vi \/etc\/sysconfig\/iptables\n<\/pre>\n<p>Edit\/append as follows:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\"> \n## delete or comment out port 22 line ##\n## -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT\n## open port 22\n-A INPUT -m state --state NEW -m tcp -p tcp --dport 10221 -j ACCEPT\n<\/pre>\n<p>Save and close the file. If you are using IPv6, edit \/etc\/sysconfig\/ip6tables file too. Temporally, stop the firewall so that you will not loose the connectivity to the server:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# service iptables stop\n# service ip6tables stop\n<\/pre>\n<p>Restart sshd on a CentOS <\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# service sshd restart\n<\/pre>\n<p>Verify new port settings with the following netstat command:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# netstat -tulpn | grep sshd\n<\/pre>\n<p>Finally, start the firewall:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# service iptables start\n## IPv6 ##\n# service ip6tables start\n<\/pre>\n<p>Now, login with a different terminal to check the settings.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Want to change the ssh port for ssh? Here is a good tutorial. (Note: If you are making these changes &#8211; ssh to the server and keep the terminal open as you make the changes. Test with a new terminal. This way if something is amiss &#8211; you are not locked out.) Edit \/etc\/ssh\/sshd_config, enter: &#8230; <a title=\"Change OpenSSH Port CentOS\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2014\/02\/14\/change-openssh-port-centos\/\" aria-label=\"Read more about Change OpenSSH Port CentOS\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[110],"tags":[],"class_list":["post-63","post","type-post","status-publish","format-standard","hentry","category-ssh"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/63","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=63"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/63\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=63"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=63"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=63"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}