How to change SSH remote login port in Linux

SSH: short for Secure Shell, SSH (developed by SSH Communications Security Ltd.) is a secure protocol for remote logins. Using an SSH client, a user can connect to a server to transfer information in a more secure manner than other methods, such as telnet. The image to the right is an example of how an SSH session, which uses a command-line interface, may look. SSH defaults to port 22.

To increase the security for your server, you should change the SSH login port on the server instead of using the default port 22. How to change SSH remote login port in Linux.

  1. Edit sshd_config file
    nano /etc/ssh/sshd_config
    Search for the #Port 22 line, remove the # character at the beginning and replace it with the port you want to use, for example, 2404. Make sure that has no service that is running on port 2404.
  2. Restart your sshd service
    service sshd restart
  3. [Option] If you are using the firewall like iptables, you need to open port 2404.
    service iptables stop
    iptables -A INPUT -m state –state NEW -m tcp -p tcp –dport 2404 -j ACCEPT
    service iptables save
    service iptables start