Centos 7: changing SSH-port
Deal with SSH (changing port) from 22
- cp -p /etc/ssh/sshd_config /etc/ssh/sshd_config.orig.$(date +%F)
exisiting rule backup
- nano /etc/ssh/sshd_config
#
Port 269
#AddressFamily any
- The configuration file for the sshd daemon.
systemctl restart sshd
- firewall-cmd --permanent --zone=public --add-port=269/tcp
Open the required ports
- firewall-cmd --reload
reload the firewall configuration
- ss -tnlp|grep ssh
- firewall-cmd --list-all
public (active)
target: default
icmp-block-inversion: no
interfaces: eth0 eth1
sources:
services: dhcpv6-client ssh
ports: 269/tcp
protocols:
masquerade: no
forward-ports:
source-ports:
icmp-blocks:
rich rules: systemctl restart sshd
now we have to edit some more files, according the made changes- nano /etc/services
ssh 22/tcp # The Secure Shell (SSH) Protocol
# ssh connection was modified to different location - port №269
ssh 22/udp # The Secure Shell (SSH) Protocol
- ls /usr/lib/firewalld/services
cp /usr/lib/firewalld/services/ssh.xml /usr/lib/firewalld/services/ssh.xml.orig.$(date +%F)
- nano /usr/lib/firewalld/services/ssh.xml
<description>Secure Shell (SSH) is a protocol for logging into and executing commands on remote m$
<port protocol="tcp" port="269"/>
</service>
either sed -i 's|port="22"|port="269"|' /usr/lib/firewalld/services/ssh.xml
- systemctl restart sshd.service
- netstat -tunlp |grep ssh {yum install net-tools}
- REBOOT