Authentication
The SSH server supports AAA authentication, PKI certificate authentication, and public-key authentication. Only authenticated users can log in to the desired device and enter the CLI. AAA authentication supports both remote and local authentication, and remote authentication takes precedence over local authentication.
Disabling services
When the SSH server is started, socket listening is enabled for devices. In this case, the devices are prone to scanning by attackers. If the SSH server does not need to be used, you can disable the SSH server and the corresponding port.
Disabling the SSHv1 service
The SSHv1 service is prone to attacks and the algorithm used by it is insecure. To reduce attack risks, you can disable the SSHv1 service.
Port number change
SSH server port 22 is a well-known port number, which is prone to scanning and attacks. You can change the SSH server port number to a private port number to reduce the possibility of being scanned or attacked. A private port number can be 22 or range from 1025 to 65535.
ACL
On the SSH server, you can configure ACL rules to control the login to the device's client IP address through STelnet, SFTP, SCP, or SNETCONF.
In the user interface view, you can configure an ACL rule for each VTY channel to control the IP addresses of clients that can log in to the device through STelnet. ACL rules do not control the IP addresses of clients that log in to the device in other modes.
You are advised to configure the SSH client on the SSH server, not on the VTY channel.
Source interface configuration
Source interfaces supported by the SSH server can be configured. Users must access a device using the IP addresses of the configured source interfaces. In this way, the access range is controlled and the device security is enhanced.
Configuring the source IPv6 address
You can configure the source IPv6 address supported by the SSH server to allow users to log in to the device only through this IPv6 address. This restricts the access range and improves device security.
CPCAR-based flood attack defense
In the scenario where Internet public addresses are deployed, a device may be attacked by traffic flooding on the management and control plane. You can configure a CPU defense policy to protect the device against traffic attacks.
Brute-force attack
After an attacker obtains the SSH port number, the attacker attempts to access a device. When the device asks authentication information, the attacker may crack the password, pass the authentication, and obtain the access right.
DoS attack
An SSH server supports only a limited number of users. When the number of login users reaches the upper limit, new users cannot access the server. This problem may be caused by normal use or attacks.
Set the authentication mode to AAA.
When the authentication mode is set to AAA, you must specify the access type of the local user.
Disable the SSH service. (By default, the SSH service is enabled.)
Run the system-view command to enter the system view.
Run the undo stelnet server enable command to disable the STelnet service.
Change the port number to 53555.
Run the system-view command to enter the system view.
Configure an ACL to restrict login rights of users.
Run the system-view command to enter the system view.
Run the acl acl-number { inbound | outbound } command to configure inbound and outbound limits for the VTY user interface.
To control the permission of users logging in to the router from a specified IP address or IP address segment, specify inbound in the command.
To prevent users who have logged in from logging in to other routers, specify outbound in the command.
Run the ssh server acl { acl-number | acl-name } command to configure the IP address of the client that is allowed to log in to the device through SSH.
Specify the source interface for a user to log in to the SSH server.
Run the system-view command to enter the system view.
Run the ssh server-source -i loopback interface-number command to specify the source interface of the SSH server.
Before specifying the source interface for the SSH server, ensure that the loopback interface has been created. Otherwise, the configuration fails to be executed.
Specify the source IPv6 address for a user to log in to the SSH server.
Run the system-view command to enter the system view.
Run the ssh ipv6 server-source -a ipv6-address [ -vpn-instance vpn-instance-name ] command to specify a source IPv6 address for the SSH server.
A VPN instance has been created before you specify it for an SSH server. Otherwise, the command cannot be executed.
Configure CPCAR-based flood attack defense.
Run the system-view command to enter the system view.
Run the acl { name advance-acl-name [ advance | [ advance ] number advance-acl-number ] | [ number ] advance-acl-number } [ match-order { config | auto } ] command to create an advanced ACL and enter the ACL view.
SSH is a TCP-based protocol. You can use SSH to log in to a device. To ensure security, you are advised to configure an independent ACL to protect SSH. The device supports dynamic link protection for SSH. The protocol packets with session entries being set up can be forwarded through a dynamic whitelist. In this example, ACLs are used to limit the rate of SSH protocol packets for which no connection has been established. It is recommended that the management protocol directly filter and discard the access traffic from unknown sources.
Run the following commands to configure ACL rules to allow SSH packets with the source IP addresses in the specified range to be sent to the CPU and deny other SSH packets:
Run the quit command to exit the ACL view.
Run the tcpsyn-flood enable command to enable defense against TCP SYN flood attacks.
Run the fragment-flood enable command to enable defense against fragmented packet attacks.
Run the udp-packet-defend enable command to enable defense against UDP packet attacks.
Run the abnormal-packet-defend enable command to enable defense against malformed packet attacks.
Run the priority { protocol-name | index index | whitelist | whitelist-v6 | blacklist | tcpsyn | fragment | user-defined-flow flow-id } { high | middle | low | be | af1 | af2 | af3 | af4 | ef | cs6 } command to configure a priority for packets to be sent to the CPU.
SSH is an access protocol, which requires less processing bandwidth and does not have high requirements on real-time performance. Therefore, you are advised to set the priority to medium.
Run the quit command to exit the attack defense policy view.
Plan IP addresses for managing devices separately to prevent the devices from being scanned and listened on.
Change the port number of the SSH server.
Configure an ACL policy to limit the IP addresses that can access the SSH server.
Configure public-key authentication for SSH users.