We can change the
default SSH port CentOS 8 as an added security concerns. To Change the SSH Port
on CentOS 8 systems connect to server with root privileges.
Step 1: SSH Configuration: open and edit the below ssh configuration file. Find the
below parameter Port 22 and change from Port 22 to Port xxxx (Port 2234) as
desire:
[root@linuxcnf ~]# vi /etc/ssh/sshd_config
…………………….
Port 2234
…………………….
[root@linuxcnf ~]# |
Step 2. SELinux Rule: Run the following command to add a rule in SELinux:
[root@linuxcnf ~]# semanage port -a -t ssh_port_t -p tcp 2234
[root@linuxcnf ~]# |
Step 3: Restart SSH Service: Restart the sshd service by running the following
command:
[root@linuxcnf ~]# systemctl restart sshd
[root@linuxcnf ~]# |
Step
4. Validate the Port Number: Run the following command to validate//verify if the port number
is changed or not:
[root@linuxcnf ~]# netstat -tulnp|grep ssh
tcp
0 0 0.0.0.0:2234 0.0.0.0:* LISTEN 2680/sshd
tcp6
0 0 :::2234 :::* LISTEN 2680/sshd
[root@linuxcnf ~]# |
Done!!!
Now the SSH service would accessible on port
2234 only.
No comments:
Post a Comment