arrow_upward

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to change SSH port in VPS
#3
(09-13-2017, 11:38 AM)Liquidips Wrote: Depending of what Linux version you are using
you can do a search on google
but if you are using Cent OS Linux, try following the below instructions


1: Login with the root user name and password
-su

2: Backup the ssh config file
-sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak

3: Edit the ssh config file
-sudo vi /etc/ssh/sshd_config

4: press insert key to begin the edit of the file
5: scroll down to #Port 22 - and enter the port number you wish you use - make sure to remove # after editing
6: type: ":wq" to save the changes and press: "ENTER" to confirm

7: Next install the python config
-sudo yum -y install policycoreutils-python

8: reenter the new port is here
-sudo semanage port -a -t ssh_port_t -p tcp "ENTER THE TCP PORT HERE FROM STEP 5"

9: Next check the firewall
-sudo firewall-cmd --permanent --zone=public --add-port="ENTER THE TCP PORT HERE FROM STEP 5"/tcp
-sudo firewall-cmd --reload

10: now restart the SSH services
-sudo systemctl restart sshd.service

11: Now the new port has been configured -
ss -tnlp | grep ssh

12: if you would like to rollback the change from steps 1 - 10
IN THE CASE SSH ISNT WORKING ANYMORE
you may need to Reinstall the SSH services - USING THIS COMMAND
-yum -y install openssh-server openssh-clients

Hope this help and please provide me your feedback.

Very nice but I have done all this in 3 commands only and no need to reinstall the SSH service or checking the firewall or anything else. Btw thank you for additional, my tutorial might doesn't work with some people so they may try yours. Big Grin


Messages In This Thread
How to change SSH port in VPS - by AmirGT - 09-13-2017, 09:04 AM
RE: How to change SSH port in VPS - by Liquidips - 09-13-2017, 11:38 AM
RE: How to change SSH port in VPS - by AmirGT - 09-13-2017, 03:03 PM
RE: How to change SSH port in VPS - by sagher - 09-14-2017, 04:16 AM
RE: How to change SSH port in VPS - by AmirGT - 09-14-2017, 09:01 AM
RE: How to change SSH port in VPS - by sagher - 09-14-2017, 11:42 AM
RE: How to change SSH port in VPS - by AmirGT - 09-14-2017, 11:16 AM
RE: How to change SSH port in VPS - by AmirGT - 09-14-2017, 01:12 PM
RE: How to change SSH port in VPS - by sagher - 09-15-2017, 05:03 AM
RE: How to change SSH port in VPS - by AmirGT - 09-15-2017, 04:04 PM
RE: How to change SSH port in VPS - by AmirGT - 09-17-2017, 12:35 PM

Possibly Related Threads…
Thread
Author
Replies
Views
Last Post
3,099
11-03-2019, 02:31 AM
Last Post: tiwil

person_pin_circle Users browsing this thread: 1 Guest(s)
Sponsors: VirMach - Host4Fun - CubeData - Evolution-Host - HostDare - Hyper Expert - Shadow Hosting - Bladenode - Hostlease - RackNerd - ReadyDedis - Limitless Hosting