How to Change the Default SSH Port on Linux
linux ssh portchange ssh default portsshd_configsecure ssh connectionssh port 50000
Published·Modified·
The default SSH port on Linux is 22. For security reasons, it is necessary to modify this port to prevent malicious scanning by bots. Here, we will change the port to 50000.
The modification method is as follows:
- Open
/etc/ssh/sshd_configand changePort 22toPort 50000, or specify the port using/usr/sbin/sshd -p 50000.
[root@localhost /]# vi /etc/ssh/sshd_config
Port 50000
[root@localhost /]# /usr/sbin/sshd -p 50000
[root@localhost /]# service sshd restart
Stopping sshd: [ OK ]
Starting sshd [ OK ]
If you want to keep both port 22 and port 50000 open simultaneously, simply add a new line in /etc/ssh/sshd_config as shown below:
[root@localhost /]# vi /etc/ssh/sshd_config
Port 22
Port 60000
Save and exit the file.