How to: Open Ssh Port 22 on Linux APF Firewall under CentOS / RHEL

Q. I’d like to change ssh port from 22 to 2346. I changes the ssh port and reloaded OpenSSH but didn’t get through my firewall. I’m using APF firewall script under cPanel control panel? How do I open port 2346?

ADVERTISEMENTS

A. By default APF configured via /etc/apf/conf.apf file. All you have to do is login as the root and specify port number.

Open port 2346 using APF

Login as the root

Open config file /etc/apf/conf.apf
# vi /etc/apf/conf.apf
Find line that read as follows:
IG_TCP_CPORTS
Add port 2346 (keep all other ports):
IG_TCP_CPORTS="2346,22,25,53,80,443,993,904,...."
Close and save the file. Restart firewall:
# /etc/init.d/apf restart

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallCentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNCentOS 8 Debian 10 Firewall Ubuntu 20.04

ADVERTISEMENTS
3 comments… add one
  • cubemed Apr 2, 2009 @ 23:41

    Thank you for letting us know that.
    very useful for me right now.

  • LaiQue Sep 14, 2011 @ 14:16

    Thanks Dude, It worked.

  • Mark Nov 21, 2011 @ 6:50

    Look for IG_UDP_CPORTS if you need to open a port for UDP

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.