SSH Keys
id_rsa, id_rsa.pub, authorized_keys
What is SSH Keypair?
When we generate a SSH key using ssh-keygen
, we are actually generating a RSA public/private key pair:
Public key:
id_rsa.pub
Private key:
id_rsa
SSH without password requires that your SSH public key id_rsa.pub
is included in authorized_keys
.
Enumeration
Search for SSH private key:
Search for authorized_keys
(authroized public keys so that no password needed when SSH):
SSH without Password
Once we get a SSH private key from the victim machine, we can try SSH in without password. Note that the public key must be recorded in authorized_keys
.
Give appropriate permission to the private key:
SSH in:
~/.ssh/authozied_keys
If ~/.ssh/authozied_keys
is writable on the victim machine, we can generate a SSH keypair and add the generated public key to this file. This will allow us to SSH into the victim machine using the generated private key.
Generate a SSH keypair on the attack machine:
Add mykey.pub
to ~/.ssh/authozied_keys
on the victim machine:
Give appropriate permission to the private key:
SSH in:
Last updated