SSH User Enumeration Exploitation
After confirming valid usernames via timing-based enumeration on OpenSSH below 7.7, the next step is using that list to drive targeted credential attacks. Generic spraying against all possible users is noisier and slower than attacking only confirmed accounts. This page covers turning the enumeration output into access.
The username list comes from SSH User Enumeration. Run that first and save the confirmed users to a file before continuing here.
Targeted Password Attack with nxc
nxc handles SSH credential testing cleanly and reports success immediately:
SSH 10.10.10.5 22 10.10.10.5 [+] git:git123 (Pwn3d!) SSH 10.10.10.5 22 10.10.10.5 [-] root:password
[+] with (Pwn3d!) confirms shell access. Stop testing that user and connect directly:
Targeted Password Attack with Hydra
For more control over threading and rate limiting:
-t 4 limits to four threads. Keep this low — aggressive threading against SSH triggers fail2ban on most real systems. On lab targets without lockout, raise it if speed matters.
Priority Accounts to Attack First
Not all confirmed users are equal. Order your attacks by likely impact:
root first if password authentication is enabled — confirmed root access skips privilege escalation entirely.
Service accounts second (www-data, git, postgres, deploy, jenkins) — these often have weak or default passwords and the same credentials may reuse across services.
Standard user accounts last — lowest privilege, but may have reused passwords that work elsewhere.
Spray One Password Across All Users
A single common password across all confirmed users is faster and quieter than a full matrix. Useful when you suspect a site-wide default or a leaked credential:
Wait for results, then try the next candidate. This minimises authentication volume per account and avoids lockouts on systems with per-user thresholds.
Test Harvested Keys Against Confirmed Users
If you recovered private key files from elsewhere in the environment, test each key against every confirmed username:
for user in $(cat /tmp/valid_users.txt); do
for key in /tmp/keys/*; do
chmod 600 "$key"
result=$(ssh -i "$key" -o BatchMode=yes -o StrictHostKeyChecking=no -o ConnectTimeout=3 $user@@$TARGET_IP "id" 2>/dev/null)
if [ -n "$result" ]; then
echo "KEY $key USER $user: $result"
fi
done
done
A single key reused across multiple servers is common in environments with shared deployment keys. Confirmed usernames make this sweep precise rather than speculative.
What Comes Next
A confirmed credential or working key gives you an SSH session. Depending on what the account can do, continue with:
SSH Config and Known Hosts Enumeration to map lateral movement paths
SSH Private Key Discovery and Passphrase Cracking to collect key material
Linux privilege escalation pages if the account is low-privilege
References
-
Pennyw0rth/NetExecgithub.com/Pennyw0rth/NetExec (opens in new tab)
nxc SSH module for credential validation against single hosts and target lists
-
vanhauser-thc/thc-hydragithub.com/vanhauser-thc/thc-hydra (opens in new tab)
Hydra with SSH module for controlled password attacks with threading limits
Was this helpful?
Your feedback helps improve this page.