How to change SSH Port on CentOS 6

Open SSH connection to the server, then:

1. Type:

nano /etc/ssh/sshd_config

2. Press CTRL+W to search and then type 'Port' to search for the word Port on the config file
3. Replace #Port 22 with Port 1234 (replace 1234 with a port number of your choice)
4. Press CTRL+X
5. Press Y and Enter
6. Type:

service sshd restart

Now you've changed the ssh port.

Note: Keep the current SSH session open and try to connect to the new SSH port from a new session to avoid losing connection in case the new port doesn't work.
Note 2: If you have a firewall installed, you need to open the new port on the firewall.


If you need help, please open a support ticket.





  • SSH, PORT, CENTOS
  • 10267 Users Found This Useful
Was this answer helpful?

Related Articles

How to reinstall an OS on my server?

If you already have an OS installed on your server and want to change or reinstall it, you can do...

How to set rDNS records for my dedicated server IPs?

You can update rDNS records of your server IPs from Client Area (One Portal) Log in to your...

Do you provide KVM/IPMI access?

Yes, we provide KVM access to all servers in all locations.KVM access is free of charge in all...

Can I install a custom OS?

Yes, you can install a custom OS (OS that is not listed on the server order page) by attaching...

How to change SSH Port on CentOS/AlmaLinux9/RockyLinux9/RHEL 9

Here's how to change SSH port on Almalinux/RHEL to increase your server security. Changing the...