How to change my ssh port

IMPORTANT: Beofre changing your port, make sure the new port is whitelisted in your firewall, if you have a firewall setup.

Step 1

As root, use your favorite text editor (vi) to edit the sshd configuration file.

vi /etc/ssh/sshd_config

Step 2

Edit the line which states 'Port 22'. But before doing so, you'll want to read the note below. Choose an appropriate port, also making sure it not currently used on the system.

# What ports, IPs and protocols we listen for
Port 50683

Note: The Internet Assigned Numbers Authority (IANA) is responsible for the global coordination of the DNS Root, IP addressing, and other Internet protocol resources. It is good practice to follow their port assignment guidelines. Having said that, port numbers are divided into three ranges: Well Known Ports, Registered Ports, and Dynamic and/or Private Ports. The Well Known Ports are those from 0 through 1023 and SHOULD NOT be used. Registered Ports are those from 1024 through 49151 should also be avoided too. Dynamic and/or Private Ports are those from 49152 through 65535 and can be used. Though nothing is stopping you from using reserved port numbers, our suggestion may help avoid technical issues with port allocation in the future.
Step 3

Switch over to the new port by restarting SSH.

/etc/init.d/ssh restart

Was this answer helpful?

 Print this Article

Also Read

Guide to Install VNC and GNOME on CentOS VPS

1. Installing Desktop Environtment : # yum -y install gnome*# yum -y groupinstall “X...

Install vnStat Network Traffic Monitor To Keep a Log Of Daily Traffic on CentOS / RHEL

How do I install vnstat software - a console-based network traffic monitor under CentOS or RHEL...

Setting up IPtables

1. Introduction CentOS has an extremely powerful firewall built in, commonly referred to as...

CentOS Directory Server, Basic Install

Prerequisites This guide is written to assume that you have a minimal install of CentOS-5.x....

Enable & Install EPEL Repo on CentOS / RHEL / Scientific Linux 6

Extra Packages for Enterprise Linux (or EPEL) is a Fedora Special Interest Group that creates,...