Rapid7

module

SSH Key Persistence

Disclosed
Jul 1, 1995
Created
Jan 27, 2026

Description

This module will add an SSH key to a specified user (or all), to allow
remote login via SSH at any time. No payload is required for this module to work.

If an SSH key is not provided, a new 4096 bit RSA keypair will be generated.
The private key will be stored as loot for later use.

Authors

Platform

Linux,Unix,Windows

Architectures

x86, x86_64, x64, mips, mipsle, mipsbe, mips64, mips64le, ppc, ppce500v2, ppc64, ppc64le, cbea, cbea64, sparc, sparc64, armle, armbe, aarch64, cmd, php, tty, java, ruby, dalvik, python, nodejs, firefox, zarch, r, riscv32be, riscv32le, riscv64be, riscv64le, loongarch64

Module Options

To display the available options, load the module within the Metasploit console and run the commands 'show options' or 'show advanced':


msf > use exploit/multi/persistence/ssh_key
msf exploit(ssh_key) > show targets
...targets...
msf exploit(ssh_key) > set TARGET < target-id >
msf exploit(ssh_key) > show options
...show and set options...
msf exploit(ssh_key) > exploit

Title
Rapid7 Labs

2026 Global Threat Landscape Report

The predictive window has collapsed. Exploitation follows disclosure in days. See how attackers are accelerating and how to stay ahead.