How to change default SSH port on Ubuntu server

By | November 3, 2013

The default port of SSH is 22.  To secure SSH more we need to change the port  . This blog helps you how to change default SSH port  on Ubuntu servers.

1. Switch as root user

$sudo su –

[sudo] password for user:

2. Open ssh configuration file

#vim /etc/ssh/sshd_config

3. Change the line (Here changed the port to 5011).

from

Port 22

to

Port 5011

4. Restart SSH  service

#/etc/init.d/ssh restart

After changing the default port you should specify the port while connect to remote system using SSH client

#ssh [email protected] -p 5011

Note : Before selecting the port please make sure that  port is not using by any other services. You can verify this on /etc/services file.

Done !!!

Leave a Reply

Your email address will not be published. Required fields are marked *