How to change the default SSH port (22) ?

The Secure Shell (SSH) Protocol by default uses port 22. Accepting this value does not make your system insecure, nor will changing the port provide a significant variance in security. However, changing the default SSH port will stop many automated attacks and a bit harder to guess which port SSH is accessible from. In other words, a little security though obscurity.

Step 1

As root, use your favorite text editor (vi) to edit the sshd configuration file.
vi /etc/ssh/sshd_config

Step 2

Edit the line which states 'Port 22'. But before doing so, you'll want to read the note below. Choose an appropriate port, also making sure it not currently used on the system.

# What ports, IPs and protocols we listen for
Port 50683

Step 3

Switch over to the new port by restarting SSH.

/etc/init.d/ssh restart

Step 4

Verify SSH is listening on the new port by connecting to it. Note how the port number now needs to be declared.

ssh -p 50683
  • 300 Users Found This Useful
Was this answer helpful?

Related Articles

How to install VestaCp on VPS / Dedicated Server ?

#    Currently Supported Operating Systems: #    RHEL 5, RHEL 6...

How do i change the language in centos?

How do i change the language in centos?Step 1 ) yum install system-config-languageStep 2) ...

Powered by WHMCompleteSolution