Sunday, November 6, 2011

Change the default SSH port on Linux

OpenSSH server uses TCP Port 22 by default.Since, it is a common target for hackers and brute-forces, it is a good practice to change the port to something higher.Let's assume that we want to change the port to 2222, then as root,

nano /etc/ssh/sshd_config


Edit the line which says Port 22 to Port 2222.

Do remember that the port should not be in use by another program or service.Now,restart SSH server via

service ssh restart


You may want to setup your IPtables rules or other firewall rules to allow incoming TCP packets in port 2222.In case you are using ufw ,you would do ,

ufw allow 2222/tcp

0 comments:

Post a Comment