This article provides the command and Junos OS version that supports changing the default SSH port on Juniper devices.
The following command is used to change the SSH port:
set system services ssh port <port number> - Port number to accept incoming connections (1..65535)
Example: 1) SSHD is listening on the default port: user@router#show system services ssh | display set set system services ssh
user@router#show system services ssh | display set set system services ssh
user@router# run show system connections extensive | match "22|50005" | match LISTEN tcp4 0 0 *.22 *.* LISTEN 2) SSHD changed to listen on different port:
user@router# run show system connections extensive | match "22|50005" | match LISTEN
tcp4 0 0 *.22 *.* LISTEN
user@router#show system services ssh | display set set system services ssh port 50005
user@router# run show system connections extensive | match "22|50005" | match LISTEN tcp4 0 0 *.50005 *.* LISTEN
tcp4 0 0 *.50005 *.* LISTEN
This feature is supported in the following versions and later.
Junos OS 12.3R12-S12 Junos OS 12.3R13 Junos OS 15.1R8 Junos OS 16.1R8 Junos OS 16.2R3 Junos OS 17.1R3 Junos OS 17.2R3 Junos OS 17.3R2 Junos OS 17.4R1 Junos OS 18.1R1
2019-08-03: Reformatted text output. 2019-07-27: Updated Junos OS versions and command output.