SSH Key Based Authentication - savannahc502/SavC-TechJournal-SEC350 GitHub Wiki

SSH (Secure Shell) key-based authentication is a method of logging into a remote server without using a password. Instead, it uses a pair of cryptographic keys: a private key, which is kept secure on your local machine, and a public key, which is placed on the remote server. When you attempt to log in, the server uses your public key to verify the private key on your machine. If they match, access is granted without the need for a password.

Step Description Command
1. Generate SSH Keys Creates a pair of SSH keys on your local machine. ssh-keygen
2. Copy Public Key to Server Copies the public key to the remote server for the specified user. ssh-copy-id user@remote_server
3. Configure SSH on Remote Server Manually add the public key if ssh-copy-id is not available. `cat ~/.ssh/id_rsa.pub
4. Connect to the Server Connects to the remote server using SSH key-based authentication. ssh user@remote_server

[!NOTE] Permissions: Ensure the permissions of ~/.ssh and ~/.ssh/authorized_keys are correctly set. Use chmod 700 ~/.ssh and chmod 600 ~/.ssh/authorized_keys.

[!TIP] For a more in-depth guide on how to automate authorized ssh users with passwordless login, see this lab.