SSH (Secure Shell) Pentesting
Enumeration
nmap --script ssh-brute -p 22 <target-ip>
nmap --script ssh-auth-methods --script-args="ssh.user=username" -p 22 <target-ip>
nmap --script ssh-* -p 22 <target-ip>
# User enumeration
msfconsole
msf> use auxiliary/scanner/ssh/ssh_enumusersBrute Force Credentials
# -t: tasks
hydra -l username -P passwords.txt <target-ip> ssh -t 4
hydra -L usernames.txt -p password <target-ip> ssh -t 4
# Specific ports
hydra -l username -P passwords.txt -s 2222 <target-ip> ssh -t 4
hydra -l username -P passwords.txt ssh://<target-ip>:2222 -t 4cewl http://<target-ip> > wordlist.txtCrack SSH Private Key
Investigation
Banner Grabbing
Configuration Files
Connect
Additional Options
Execute Commands after Connecting
Test Connection
Connect to Windows via Active Directory
Connect using an Existing Private Key
Transfer Files
Send a File/Directory to Another Machine
Download a File/Directory from Another Machine
Create SSH Keys
Generate Keys
Install SSH Key
Generate SSH Keys and Set Up Public Key to Connect Remote Machine
1. Check if authorized_keys Exists in Remote Machine
2. Generate SSH Keys in Local Machine
3. Add the Content of Publick Key to authorized_keys
4. Login with Private Key
SSH Server
Start/Stop/Restart
Status
Configuration
Check for any Established Connection
Logs
SSH Proxy Server
Sshuttle
SSH-MITM for Stealing Credentials
2FA Bypass
Google Authenticator
References
Last updated