Change the default port number of ssh server
SSH Default Port no. = 22
To change the default port number of ssh server hardly takes a few steps but with the point of security it is important to change the default port no. 22
After this you can also use the anti port scan script which is already written in post. (Reference : note; change the port no. of ssh (22) as per your requirement Restrict Port Scanning IPTABLE script )
Follow the given below steps to change the port no. of ssh
Step 1 : Open the file /etc/ssh/sshd_config with the help of your favorite 🙂 editor. I use vi editor
Step 2: Search the line “Port 22” and the change the value of 22 to any number, here I am using 2786
vi /etc/ssh/sshd_config Port 2786
Step 3: After save and exit. Restart the ssh service.
In CentOS and Red Hat /etc/init.d/sshd restart
In Ubuntu and Debian /etc/init.d/ssh restart
Now how to access from client
Now from your client machine for ssh you have to use flag -p and for scp -P
eg.
ssh -p 2786 username@ssh-server
scp -P 2786 filename username@ssh-server:~
Leave a Reply