servermanagement:keybasedauthentication
Differences
This shows you the differences between two versions of the page.
| servermanagement:keybasedauthentication [2022/12/23 11:55] – created dimitrij | servermanagement:keybasedauthentication [2022/12/23 11:55] (current) – removed dimitrij | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== Securing SSH Server ====== | ||
| - | To secure a Linux server' | ||
| - | |||
| - | ===== Key base ===== | ||
| - | |||
| - | with key-based authentication, | ||
| - | |||
| - | Generate a public/ | ||
| - | Open a terminal window and enter the following command: ssh-keygen | ||
| - | Follow the prompts to specify the location to save the key pair, and enter a passphrase for the private key (optional). | ||
| - | This will generate a public key and a private key in the specified location. The public key is stored in a file with the .pub extension, and the private key is stored in a file with no extension. | ||
| - | |||
| - | Copy the public key to the server: | ||
| - | Enter the following command to copy the public key to the server, replacing 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_IP | ||
| - | You will be prompted to enter the password for the user on the server. | ||
| - | This will copy the public key to the server and append it to the authorized_keys file in the ~/.ssh directory of the user's home directory on the server. | ||
| - | |||
| - | Disable password-based authentication: | ||
| - | Edit the / | ||
| - | Save the file and restart the SSH service by running the following command: systemctl restart ssh | ||
| - | |||
| - | Test the key-based authentication: | ||
| - | From your local machine, try connecting to the server using the ssh command and the private key file: | ||
| - | ssh -i / | ||
| - | If the connection is successful, you have successfully set up key-based authentication for the server' | ||
servermanagement/keybasedauthentication.1671792918.txt.gz · Last modified: 2022/12/23 11:55 by dimitrij