Get the App
SLTechnology News&Howtos  ›  Servers  › 

Linux sets the configuration of sshd service multi-port mode and single-port mode

Shulou Source: shulou.com Published: 2022-06-02 07:43:16 10月01日 Update

Background environment: redhat 7 default: selinux,iptables enabled modification: / etc/ssh/sshd_config1. Single port mode case 1: Port 3333 case 2: Port 22ListenAddress 0.0.0.0 ListenAddress 0.0.0.0:3333Port 3333 case 3: ListenAddress 0.0.0.0:3333Port 22 the above three results are: 3333 case 4: Port 22Port 3333ListenAddress 0.0.0.0 ListenAddress 0.0.0.0:3333Port 6666 result is 6666 case 5: ListenAddress 0.0.0.0:3333ListenAddress 0.0.0.0:6666Port 22 result is 3333, 66662. Multi-port mode case 1: Port 22Port 3333 case 2: ListenAddress 0.0.0.0:22ListenAddress 0.0.0.0333

The final result of the above situation is 222.3333.

Notice of error report: Job for sshd.service failed because a configured resource limit was exceeded. See "systemctl status sshd.service" and "journalctl-xe" for details. Detailed error report: error: Bind to port 3333 on:: failed: Permission denied

1. Since selinux is enabled by default, the ssh port is not allowed to be modified by default security policy. You need to manually modify the policy release.

Close seliunx or semanage port-a-t ssh_port_t-p tcp 3333

two。 Firewall policy add new port

Firewall-cmd-- add-port=3389/tcp-- permanentfirewall-cmd-- reload other notes: if the system has upgraded ssh, modifying the configuration file / etc/ssh/sshd_config will not take effect. After upgrading openssh, the configuration file is / usr/local/etc/sshd_config

Tags: Situation port result policy mode configuration file upgrade security manual environment system background firewall top three fire prevention service Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Shulou Technology Linux Apple Redmi