Jump to content


Changing Your SSH Port

SSH Port Change Linux

  • Please log in to reply
4 replies to this topic

#1 Joseph


    Advanced Member

  • Administrators
  • 46 posts
  • LocationPhilippines

Posted 05 August 2014 - 05:01 PM

Port 22 is the default port for almost all SSH Connections. But you can change your port especially if it is having errors.
Additionally, changing your SSH port is a security measure. I would recommend everyone to do this to prevent brute force attacks.

Here is a tutorial on how to change your SSH port.

1. Log into your server as root. In case you can't log into your server, You can also log into your server through the Virtual Login credentials provided on your panel. 

2. Install an editor software.
For CentOS:

yum install vim

For Ubuntu/Debian:

apt-get update && apt-get -y install vim

3. Execute this command on your terminal.

vi /etc/ssh/sshd_config

4. Search for the line:

#Port 22

5. Enter into editing mode by pressing letter 'A' from the keyboard. Change the number into your desired port. Please take note that you can only assign a port that is free and open. I would suggest that you use a port from the 30-65535 range. Make sure to remove the # sign.

6. Save your changes by pressing the escape button and type:


7. Reboot your server or execute this command on the VPS terminal:

service sshd restart

  • Perwiz and Pete like this

#2 Riste



  • Members
  • PipPip
  • 18 posts

Posted 09 August 2014 - 12:20 AM

Nano editor is better in my option and is more easy for using, also i understand vim, but i using nano. :)

#3 Oakenfold



  • Members
  • Pip
  • 9 posts

Posted 10 August 2014 - 10:52 PM


And another tip.


In the sshd_config config file. The line

PermitRootLogin yes

Is insecure. Change to "no" ;)

Prevent login with root. Prevent brute force attacks. 


PD. Sorry for my english u.u

#4 Riste



  • Members
  • PipPip
  • 18 posts

Posted 10 August 2014 - 11:00 PM

And rebooting the server isn't required, could only with this

service sshd restart

#5 issue89



  • Members
  • Pip
  • 6 posts

Posted 19 December 2014 - 03:46 AM

VIM or Nano is the same argument between mac vs pc, doesn't matter how you get there as long as you can achieve results. Everyone should always change their SSH ports, good tutorial.

Also tagged with one or more of these keywords: SSH, Port, Change, Linux

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users