Troubleshooting SSH2 Spider: Common Errors and Fixes
1. Connection refused / cannot reach host
- Cause: SSH server not running, wrong host/port, or network blocked.
- Fixes:
- Verify host and port:
ssh -p(replace values).user@host - Ensure SSH service is running on target (e.g.,
systemctl status sshd). - Check firewall/NAT and open port 22 (or custom port).
- Use
telnet host portornc -vz host portto test reachability.
- Verify host and port:
2. Authentication failures (password or key rejected)
- Cause: Wrong credentials, key not authorized, key format mismatch, or permissions too open.
- Fixes:
- Confirm username/password.
- For key auth: ensure public key is in
/.ssh/authorized_keyson target and file permissions are700for/.sshand600forauthorized_keys. - Convert key formats if needed (OpenSSH vs. PEM) using
ssh-keygen -i/ssh-keygen -p. - Enable verbose logging: run the spider with
-vvv(or enable SSH clientssh -vvv) to inspect auth negotiation.
3. Host key verification failed / mismatched host key
- Cause: Target host key changed (possible MITM) or cached key differs.
- Fixes:
- Inspect
~/.ssh/known_hostsentry for the host and remove the offending line:ssh-keygen -R hostname. - Verify the new host key out-of-band (admin or console) before accepting.
- In automated testing only, allow new keys temporarily with strictness disabled — but avoid in production.
- Inspect
4. Timeout during commands or SFTP transfers
- Cause: Network latency, server load, aggressive timeouts, or large transfers.
- Fixes:
- Increase SSH timeout/retry settings in spider configuration (e.g., connection and command timeouts).
- Use compression (
-C) for transfers or limit concurrency. - Monitor server load and IO; reduce parallel sessions.
5. Partial or corrupted file downloads/uploads
- Cause: Interrupted transfers, encoding issues, or SFTP subsystem problems.
- Fixes:
- Use checksums (e.g.,
sha256sum) before and after transfer to verify integrity. - Retry with resume support if available, or switch to SCP/SFTP clients that support resumption.
- Ensure binary mode used for non-text files.
- Use checksums (e.g.,
6. Permission denied when running remote commands
- Cause: Insufficient user privileges or restricted shell.
- Fixes:
- Confirm the account has required permissions or use
sudowith proper configuration (/etc/sudoers). - Check the shell assigned to the user and any forced commands in
authorized_keys. - Use an account with needed privileges or adjust remote command invocation.
- Confirm the account has required permissions or use
7. Host environment differences causing failures (PATH, shell, missing deps)
- Cause: Remote environment lacks required tools or has different PATH.
- Fixes:
- Execute commands with full paths (e.g.,
/usr/bin/rsync). - Source profile files in the command (
. ~/.profile) or start an interactive shell when needed. - Install required dependencies on target.
- Execute commands with full paths (e.g.,
8. High resource use or too many concurrent sessions
- Cause: Spider configured with aggressive concurrency causing server overload.
- Fixes:
- Lower concurrency and rate limits in spider config.
- Add exponential backoff for retries.
- Monitor and throttle based on server responses.
9. Cipher/kex algorithm mismatch
- Cause: Client and server have no overlapping ciphers/kex or server disables weak algorithms.
- Fixes:
- Update client/server to support modern algorithms (e.g., AES-GCM, ECDH).
- Temporarily enable compatible algorithms on the client or server with caution.
- Review SSH logs for negotiated algorithms.
10. Logs show “broken pipe” or connection resets
- Cause: Idle timeouts, NAT timeouts, or abrupt server disconnects.
- Fixes:
- Enable keepalives: set
ServerAliveInterval/ClientAliveInterval. - Adjust TCP keepalive settings or increase timeout on intermediate devices.
- Investigate server logs for reasons of disconnect.
- Enable keepalives: set
Troubleshooting workflow (quick checklist)
- Reproduce the issue with
-vvv/detailed logging. - Confirm basic network reachability.
- Verify credentials and permissions.
- Check server-side logs (
/var/log/auth.logorjournalctl -u sshd). - Adjust timeouts, concurrency, and ciphers as needed.
- Validate transfers with checksums and retry.
Useful commands
- Connection test:
nc -vz host port - Verbose SSH client:
ssh -vvv -p port user@host - Remove known host:
ssh-keygen -R hostname - Check service:
systemctl status sshd - Verify file integrity:
sha256sum file
If you want, I can produce a concise checklist tailored to your SSH2 Spider config—provide the spider config file or its key settings.
Leave a Reply