SSH | 22
00. Basic
## ------------------| Debugging and Troubleshooting
ssh -v h4rithd@$IP ## Enable verbose output for debugging
ssh -vvv h4rithd@$IP ## Enable maximum verbose output
## ------------------| Host Key Management
ssh -o UserKnownHostsFile=/dev/null h4rithd@$IP ## Prevents ssh from attempting to save the host key
ssh -o StrictHostKeyChecking=no h4rithd@$IP ## Instruct ssh to not prompt to accept the host key
ssh -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null h4rithd@$IP ## Combine to bypass host key checking (insecure, for testing)
## ------------------| Escaping Restricted Shells
ssh -t bash h4rithd@$IP ## Escape rbash by forcing bash
ssh -t /bin/sh h4rithd@$IP ## Escape rbash using sh
ssh -t python -c 'import pty; pty.spawn("/bin/bash")' h4rithd@$IP ## Escape rbash with Python PTY
## ------------------| Using sshpass for Automation
sshpass -f /path/to/keyfile ssh h4rithd@$IP ## Use sshpass with key file
sshpass -p 'password' ssh h4rithd@$IP ## Use sshpass with password (insecure)
sshpass -p 'password' ssh -o StrictHostKeyChecking=no h4rithd@$IP ## Combine sshpass with no host key checking
## ------------------| Authentication Methods
ssh -o PubkeyAuthentication=no h4rithd@$IP ## Disable public key authentication
ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no h4rithd@$IP ## Force password authentication
ssh -o GSSAPIAuthentication=no h4rithd@$IP ## Disable GSSAPI authentication
ssh -i /path/to/id_rsa_custom h4rithd@$IP ## Use specific private key file
## ------------------| Encryption and Compatibility
ssh -o MACs=hmac-sha2-256 h4rithd@$IP ## Specify modern MAC algorithm
ssh -o MACs=hmac-sha2-512 h4rithd@$IP ## Specify modern MAC algorithm
ssh -o MACs=hmac-md5 h4rithd@$IP ## Try legacy MAC for compatibility (deprecated, insecure)
ssh -o Ciphers=aes256-ctr h4rithd@$IP ## Specify encryption cipher
ssh -o KexAlgorithms=diffie-hellman-group14-sha1 h4rithd@$IP ## Specify legacy key exchange algorithm
ssh -o HostKeyAlgorithms=+ssh-dss h4rithd@$IP ## Specify legacy host key algorithm
ssh -o KexAlgorithms=diffie-hellman-group14-sha1 -o HostKeyAlgorithms=+ssh-dss h4rithd@$IP ## Combine legacy key exchange and host key algorithms
## ------------------| Connection Optimization
ssh -2 h4rithd@$IP ## Force SSHv2 protocol (SSHv1 is insecure)
ssh -C h4rithd@$IP ## Enable compression for faster data transfer
ssh -p 2222 h4rithd@$IP ## Use custom port (e.g., 2222)
ssh -F /path/to/custom_ssh_config h4rithd@$IP ## Use custom SSH config file01. Enumeration & Exploitation
01.1 Enumeration
01.2 Exploitation
Last updated
