SSH Pentesting Notes
Protocol Overview
Basic Information
Port: TCP 22 (default)
Protocol Type: Encrypted, application layer
Purpose: Secure remote access and file transfer
Security: Strong encryption and authentication mechanisms
Protocol Versions
SSH-1
Legacy protocol
Vulnerable to MITM attacks
Should be disabled
SSH-2
Current standard
Improved security
Supports multiple authentication methods
Initial Enumeration
Port Scanning
Banner Grabbing
Authentication Methods
Testing Different Auth Methods
Key-Based Authentication Check
Brute Force Attacks
Using Hydra
Using Medusa
Using Ncrack
Common NSE Scripts
SSH Auditing
Using SSH-Audit
File Operations
SCP (Secure Copy)
SFTP Operations
Configuration Files
Server Configuration
Main config:
/etc/ssh/sshd_config
Host keys:
/etc/ssh/ssh_host_*_key
Known hosts:
/etc/ssh/ssh_known_hosts
User Configuration
SSH directory:
~/.ssh/
Private keys:
~/.ssh/id_*
Known hosts:
~/.ssh/known_hosts
Authorized keys:
~/.ssh/authorized_keys
Common Vulnerabilities
Configuration Issues:
Weak passwords allowed
Root login enabled
Old protocol versions
Weak ciphers/MACs
Authentication Problems:
Password authentication enabled
Empty passwords allowed
Weak private key protection
Misconfigured authorized_keys
Version-specific:
OpenSSH vulnerabilities
Legacy SSH-1 problems
Weak key exchange methods
Deprecated algorithms
Post Exploitation
Information Gathering
Check SSH configuration
List authorized keys
Examine user permissions
Review SSH logs
Search for private keys
Privilege Escalation
Check for writable config files
Look for unprotected keys
Test for SSH agent hijacking
Examine cron jobs
Review sudo permissions
Common SSH Response Codes
Permission denied
Authentication failed
Connection refused
Port closed or filtered
Host key verification failed
Changed/unknown host key
Connection timed out
Host unreachable/blocked
Best Practices for Pentesting
Initial Reconnaissance:
Identify SSH version
Check available algorithms
Test authentication methods
Review banners/fingerprints
Deep Enumeration:
Run SSH audits
Test key-based auth
Check configuration
Verify encryption methods
Documentation:
Record findings
Note configurations
Document vulnerabilities
Save evidence
Risk Assessment:
Evaluate security posture
Check compliance
Assess attack surface
Recommend hardening steps
Common Dangerous Settings
PermitRootLogin yes
Allows direct root access
PasswordAuthentication yes
Enables password attacks
PermitEmptyPasswords yes
Allows blank passwords
Protocol 1
Uses vulnerable protocol
X11Forwarding yes
Potential GUI exploitation
AllowTcpForwarding yes
Possible tunneling abuse
DebianBanner yes
Information disclosure