How to unblock the IP after failed sftp login attempts to google cloud compute instance

google-compute-engineip-blocking

We just started using google cloud compute engine, and to connect to the server using sftp a couple of colleagues did a number of failed login attempts. Now we cannot access our google cloud engine vm instance from our office anymore, on any port directly from our IP. From any other location (IP address) we can access. First we thought it might be a temp block, but it has been a week now so it seems to be rather permanent.

Best Answer

Joinning the party years later, but someone could benefit from this.

Looks like every ubuntu image has sshguard installed, after a few failed SSH login attempts your IP gets banned/blocked.

You need to connect to your instance from another ip, or use the ssh connection inside web-console from google compute engine.

What you can do is check if your ip has been banned:

sudo iptables --list sshguard --line-numbers --numeric | grep [you.ip.goes.here]

On the output you will have a line with a number at the beginning, that line must be removed (replace [N] with that line number):

sudo iptables --delete sshguard [N]

Then you should be able to connect to your server again.

There are people that suggest adding the ip to the sshguard white list and then restarting the sshguard service... I didn't try it because my i think my solution is safer given the fact that my ip can change. If you happen to need a fixed IP being white listed of solution, comment is here:

https://stackoverflow.com/questions/26813070/google-compute-engine-getting-blocked-after-accessing-ssh-a-few-times/26827428#comment84875330_26827428

Also some doc from sshguard where I got my final answer: https://wiki.archlinux.org/index.php/Sshguard#Unbanning

Related Topic