SSH Authentication
4 September 2024
Important files:
On target server:
.ssh/authorized_keys : Stores the public keys of clients permitted to access the server
ssh/known_hosts : Track history of fingerprints from servers you've connected to
On client:
ssh/known_hosts : Helps to avoid man-in-the-middle attacks.
SSH
Secure Shell Protocol's purpose is to secure a communication an unprotected network with a key-based cryptographic authentication method. The protocol gives the user protected access to remote systems.
Keys
Public and Private keys are generated with text generated by an asymmetric algorithm. The public key is stored here: ~/.ssh/id_rsa.pub
and is located in the server to decrypt data. The private key encrypts the initial client request and is located here: ~/.ssh/id_rsa
on the client's computer.
Generate these files:
ssh-keygen -t ed25519 -C "random comment"
Connecting to remote servers
In order to connect to a remote server, the user needs the public key and private key generated on a local computer. The public key is added to the server host here: ~/.ssh/authorized_keys
.
Now connect:
ssh root@your_ip
How does Key-Based Authentication work?