VPS SSH Login Troubleshooting
2026-07-11 2 min read 360 words
中文版
Restored SSH access after fail2ban blocked VPS login attempts caused by outdated username configuration.

contents
1Backgroud
Issue: SSH connection failed after changing the VPS username
- Created a temporary sudo user to change the main VPS username
- Tried connecting to VPS through new username
- Failed to notice that my snippet of VPS connection was still using the old username
- Tried connecting with an incorrect/non-existent username and password
- After multiple failed attempts, SSH access stopped working
2Troubleshooting Process
2.1Access VPS via Remote Console
Logged into the VPS through the provider’s Remote Console and started troubleshooting locally.

2.2Check SSH Service Status
Check SSH status:
systemctl status sshFound that the SSH service was not running.

Start SSH and enable it on boot:
sudo systemctl start ssh # start
sudo systemctl enable ssh # enable on boot
systemctl status ssh # check status2.3Check Firewall Configuration
Check UFW status:
ufw statusConfirmed that the SSH port was not blocked by UFW and ruled out firewall issues.
2.4Check fail2ban Ban Status
Check fail2ban service:
sudo systemctl status fail2banSee my own IP locally:
curl https://api.ipify.orgOn the remote console, see whether my IP was banned:
# Check SSH jail status:
sudo fail2ban-client status sshd
# Banned IP list: <my_ip>
Cause:
- The SSH connection snippet still used the old username after the username change
- Multiple login attempts were made with an invalid username/password
- Failed attempts exceeded the fail2ban threshold (5 attempts)
- fail2ban automatically banned my IP (ban duration: 1 hour)
2.5Unban My IP
Check current banned IPs:
sudo fail2ban-client status sshdRemove the IP ban:
sudo fail2ban-client set sshd unbanip <my_ip>Restart fail2ban if needed:
sudo systemctl restart fail2ban3Final Result
- SSH service restored
- UFW confirmed not causing the issue
- Root cause identified: fail2ban blocked my IP
- SSH connection successfully restored after unbanning the IP
4Follow-up Notes
- Update the SSH connection snippet immediately after changing usernames
- Avoid repeated login attempts with incorrect usernames/passwords in a short period
- Keep a backup sudo account before modifying SSH-related settings
- Check fail2ban status as one of the first troubleshooting steps when SSH login fails