What Is Default SSH Port and How To Change It? – POFTUT

What Is Default SSH Port and How To Change It?


SSH or Secure Shell is a very popular remote connection and management protocol used to manage different types of devices. SSH can be used to manage Linux, Ubuntu, CentOS, Cisco, Fortinet, and a lot more devices. As a remove port SSH is accessed via the network using TCP 22 port.

SSH Default Port Is TCP 22

The default port for SSH is TCP 22. TCP is important because traditionally SSH works over a reliable connection that is provided via TCP, not UDP. SSH port 22 is registered in 1995 by Tatu Ylonen from the IANA or Internet Assigned Numbers Authority. Well SSH is designed to replaced both telnet and FTP. Telnet is using port number 21 and Ftp is using port number 23. Port number 22 was free at that time and as an alternative to Telnet and FTP, SSH is assigned to the TCP 22. SSH designed and standardized with the RFC 791, RFC 792, RFC 793.

Connect Default SSH Port

SSH port TCP 22 can be connected by using different SSH clients and tools. As an example Linux ssh command can be used to connect SSH TCP 22 port with the following usage. We will also provide the user name ismail and hostname/IP address.

$ ssh ismail@192.168.142.183
Connect Default SSH Port

Alternatively, we can specify the port number explicitly by using the -p option and providing the port number. In the following example, we will connect to port number 22 but we can use different port numbers too.

$ ssh -p 22 ismail@

Change SSH Port

For Linux systems like Ubuntu, Debian, CentOS, Kali, Fedora, RHEL can run the SSH server. The SSH server can be installed with the following commands for different systems.

LEARN MORE  Git- Clone Operations

Debian, Mint, Kali, Ubuntu

$ sudo apt install openssh-server

Fedora, CentOS, RHEL

$ sudo dnf install openssh-server

The SSH server configuration is stored in the /etc/ssh/sshd_config file. We will open this file with root privileges with the following command.

$ sudo nano /etc/ssh/sshd_config

We change the Port configuration into different numbers like 2222. If we set # before the configuration it will be a comment and not effective anymore.

SSH Server Configuration

After making SSH port change in order to make new configuration effective we will restart the SSH server which will reload new configuration.

$ sudo systemctl restart ssh

Connect Non Default SSH Port

By default, the ssh command will try to connect the default SSH port. But in some cases, we may need to specify different port than the default. We will use the -p option and provide the port number we want to connect.

$ ssh -p 2222 ismail@192.168.142.183
Connect Non Default SSH Port

Leave a Comment