How to change SSH Port of your server ?


Last modified: February 11, 2015

By default, connect from SSH to Linux Server is using port 22, so it can be use for attack your root account. To make your connection more security, today we will guide you simle step to to change SSH Port of your server.


Below is step by step to change login SSH port in VPS without using port 22.

Step 1: Login to your VPS use Root account
Step 2: Edit sshd_config file use this command:

nano /etc/ssh/sshd_config

Step 3: Search #Port 22 and remove #, change whatever post you want. Example 9999

Port 9999

Note: The post must FREE and do not duplicate with any running service.

Open port if you are using firewall

– Stop iptables

service iptables stop

– Edit file iptables configuration

nano /etc/sysconfig/iptables

– Edit or update this lines bellow

## delete or comment out port 22 line ##
## -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
## open port 2222
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2222 -j ACCEPT

– Now restart SSHD service

service sshd reload

– Restart iptables

service iptables start

Okey done! Now you can login SSH and use new port.


About Author

I'm a freelance with over 3 years experience working in PHP with CMS Wordpress and design website layout. In my spare time, I go fishing, lean internet marketing, scout new blogging strategies,free Xbox live gold codes and techniques, and work from wherever. View me on: Google+ | Facebook.

Leave A Reply