Jump to content


- - - - -

How to: Change SSH Port on CentOS 7

CentOS 7

  • Please log in to reply
1 reply to this topic

#1 Wilson18



  • root
  • 112 posts
  • LocationUniversity of Birmingham

Posted 21 April 2015 - 06:03 PM

In this guide, I will be showing you how you can change the SSH port on CentOS 7.


To do this, you will need to navigate to the ssh config file. You can do this with your favourite text edit (e.g nano)

sudo nano /etc/ssh/sshd_config

Once in the file, you will see where it says:

Port 22

Change the number 22 to the port of your choice. Once you have done this, save and exit (Ctrl + O and then Ctrl + X in nano).


You can then enter this to let SELinux know of the change and to allow it through the firewall. (Replace #yournewport with the port you entered above) 

semanage port -a -t ssh_port_t -p tcp #yournewport

You can then restart your ssh server to apply the change. 

systemctl restart  sshd

All done! You can now connect using the amended details. 

List what you read?

Check me out on: YouTube, Twitter, Facebook, Google+

#2 back2basics



  • Geeks
  • Pip
  • 4 posts

Posted 22 April 2015 - 02:41 PM


Also tagged with one or more of these keywords: CentOS 7