How to change SSH Port of your server ?

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.

change-ssh-port-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:

[sourcecode language=”plain”]nano /etc/ssh/sshd_config[/sourcecode]

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

[sourcecode language=”plain”]Port 9999[/sourcecode]

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

Open port if you are using firewall

– Stop iptables

[sourcecode language=”plain”]service iptables stop[/sourcecode]

– Edit file iptables configuration

[sourcecode language=”plain”]nano /etc/sysconfig/iptables[/sourcecode]

– Edit or update this lines bellow

[sourcecode language=”plain”]## 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[/sourcecode]

– Now restart SSHD service

[sourcecode language=”plain”]service sshd reload[/sourcecode]

– Restart iptables

[sourcecode language=”plain”]service iptables start[/sourcecode]

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

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Free Designsave Spinner 100% Unique & Readable!Free Spinner