Monday, December 16, 2013

How to change ssh port to a non default port in Unix

Yesterday I have to change default ssh port from 22 to 1022. This change in port from default to non-default  enhances security of your server a little bit. Changing port from 22 to 1022 will stop automated attacks and it becomes difficult to guess from which port server is accessible.

Solution :-

1. As root user edit the sshd_config file in /etc/ssh location.

edit Port 22 to Port 1022

2. Before changing port to a non default value, check port is not being used by any other server.

3. Once Port has been changed in /etc/ssh/sshd_config file , restart SSH service :-

  #stopsrc -s sshd
  #startsrc -s sshd

  or by 

  #service sshd restart

4. Check that the changed port is working:-

ssh -p 1022 server1

I hope this article helped you.

Regards,
Amit Rath

No comments:

Post a Comment