Linux·28 questions

HOW TO CONFIGURE SSH?

Answer

Configuring a secure and efficient SSH connection is a fundamental requirement for administering any Linux server. This process involves generating cryptographic keys, transferring them to the remote machine, initial connection verification, and subsequent hardening of security measures at the service configuration level. Proper configuration allows you to completely eliminate the risks of unauthorized access via brute-force password attacks.

To implement the described approach, follow these practical steps on your workstation and remote server:

Create an encryption key pair on your local computer using the ssh-keygen command, leaving a passphrase for additional protection.
Copy the public key to the remote server using the ssh-copy-id user@server command so that the system starts recognizing your terminal.
Connect to the server using the created key with the ssh user@server command to verify authorization correctness.
Open the sshd_config service configuration file on the server and disable traditional password login by setting the PasswordAuthentication parameter value to no.
Change the default port 22 to any other in the same configuration file to reduce the number of automated attacks from bots scanning the network.

After completing all changes, be sure to restart the SSH service on the server and do not close the current terminal session until you verify in a new window that a successful connection with the new parameters is working stably. This will protect you from accidentally losing access to the remote machine.

Was this answer helpful?

More questions in this topic

Related questions from other topics