To secure a Linux server's SSH service, there are a few options, which will be discussed on this page.
For using key-based authentication, you can follow these steps:
ssh-keygen.pub extension, and the private key is stored in a file with no extension.user with the username on the server and server_hostname_or_IP with the hostname or IP address of the server:ssh-copy-id user@server_hostname_or_IPauthorized_keys file in the ~/.ssh directory of the user's home directory on the server./etc/ssh/sshd_config file on the server and set the PasswordAuthentication option to no. This will disable password-based authentication for the SSH service on the server.systemctl restart sshssh -i /path/to/private_key user@server_hostname_or_IPIf the connection is successful, you have successfully set up key-based authentication for the server's SSH service.