How to connect to SSH port other than default 22

If you are trying to SSH on a remote server that is not running on the default port i.e. 22, you can connect to it by using the below syntax.

Syntax:

ssh user-name@server-name-or-ip -p <port-number>

Let's take a look at an example where we try to connect to port number 60 instead of 22.

Example:

% ssh admin@192.168.0.112 -p 60
SSH to a non default port of 22 example

From SSH Man Page:

-p port: Port to connect to on the remote host. This can be specified on a per-host basis in the configuration file.

Reference: https://man.openbsd.org/ssh#p

Comments & Discussion

Facing issues? Have questions? Post them here! We're happy to help!