How to Connect to SSH using Custom Port Number in Linux

Introduction

Port 22 is utilized by default when connecting to a Linux server over SSH. In certain circumstances, you may be required to use a different port number to connect to the server for security or other reasons. This article describes how to connect to an SSH server on Linux using a custom port number. Also, we will discuss how to access the server through the command line and Putty.

Connecting via SSH with a different port number in Linux using the command line:

Syntax :

# ssh -p port_number username@remote_server_ip

Example remote host :

Host Name: 192.168.1.35
Port: 2022

Run the following commnad in linux terminal and remotely connect using ssh command as below :

# ssh -p 2222 [email protected]

Connect to SSH using Custom Port Number in Linux using PuTTY

To connect to a remote server via SSH on a custom port number using PuTTY, you can follow these steps:

  • Open PuTTY
  • In the “Host Name (or IP address)” field, enter the remote server’s IP or hostname.
  • In the “Port” field, enter the custom port number.
  • Click on the “Open” button to establish the connection.

Note: make sure that the server is configured to listen on the specific port you are trying to connect to.

Example of connecting server 192.168.1.35 via port 2022 using PuTTY .

Host Name: 192.168.1.35
Port: 2022

Connect to SSH using Custom Port

Conclusion

In this post, we have discuss how to connect to an SSH server on linux using a custom port number. This can be useful for improving server security by using a non-standard port number or for diagnosing connection problems. In addition, we have covered connecting the server through the command line and Putty. Be sure to verify the connection before implementing it in a production environment, as changing the default port number may cause connectivity problems with such firewalls and other security devices.

Leave a Comment