Secure Shell (SSH), known as Secure Socket Shell, is a UNIX-based command interface and protocol for securely getting access to a remote computer. Network administrators widely use it to control Web and other kinds of servers remotely.
SSH is a suite of three utilities - slogin, ssh, and SCP - secure versions of the earlier UNIX utilities, rlogin, rsh, and RCP. SSH commands are encrypted and secured in several ways. Both ends of the client/server connection are authenticated using a digital certificate, and passwords protected by being encrypted. SSH manages 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 SSH port is TCP 22 since SSH works over a reliable connection provided by TCP, not UDP. SSH port 22 is registered in 1995 by Tatu Ylonen from the IANA or Internet Assigned Numbers Authority. Though SSH works with TCP, it can also be designed to replaced both telnet and FTP. Telnet uses port number 21, whereas FTP uses 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. For example, the Linux ssh command can connect SSH TCP 22 port with the following usage. We will also provide the user name ismail and hostname/IP address.
$ ssh email@example.com
Connect Default SSH Port
Alternatively, we can define the port number explicitly by applying the -p option and providing the port number. In the following example, we will connect to port number 22, but we can use other port numbers.
$ ssh -p 22 ismail@
Change SSH Port
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: Changing The SSH Port
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 the SSH port change to make the new configuration effective, we will restart the SSH server, reload the 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 a different port than the default. We will use the -p option and provide the port number we want to connect.
$ ssh -p 2222 firstname.lastname@example.org