Resetting SSH access after “Too many authentication failures for …” on Google Cloud Compute Engine

Locked yourself out of SSH/SFTP access on Google Cloud Compute Engine? Does the below look familiar… Fun times…

Status: Connecting to domain.com...
Status: Connecting to domain.com...
Response: fzSftp started, protocol_version=8
Command: open "...@domain.com" 22
Error: Server sent disconnect message
Error: type 2 (protocol error):
Error: "Too many authentication failures for ... from 125.18.17.115 port 7145 ssh2"
Error: Could not connect to server

Here’s how to increase the number of allowed login attempts within sshd_config and then restart the sshd service so you can get back to work. 🙂

  1. Open up Google Cloud Console
  2. From the Menu button open Compute Engine > VM Instances
  3. Beside your Compute Engine instance hit the SSH button within the Connect column
  4. When your terminal connection is established enter the following:
    sudo nano /etc/ssh/sshd_config
  5. By default the sshd_config file does not have a MaxAuthTries entry but scroll through the file using the up/down keys and check just incase…
  6. I set the maximum number of login attempts to 10, change this number to suit your security needs. Add the following lines anywhere within the sshd_config file:
    # Max login attempts
    MaxAuthTries 10
  7. Save and close the file by using the following keyboard combinations:
    CTRL+O followed by the enter key to save the file changes
    CTRL+X to close the Nano file editor
  8. Reboot the sshd service using the following commands (I’m not sure which one works so let’s do all of them…)
    sudo service sshd restart
    sudo systemctl restart sshd
  9. Try and reconnect to your Compute Engine instance using Putty (SSH) or Filezilla (SFTP)

That’s it 🙂

Fixing Installation Failed message on Bitnami WordPress and Google Cloud Compute Engine

Getting WordPress installed on Google’s Cloud Compute Engine service is super easy using the Bitnami Launchpad for Google Cloud Platform, the gotcha is the default permissions set during installation mean you cannot use the WordPress Administration to update Theme’s, Plugins or WordPress core itself.

To set the file and directory permissions correctly you will need to connect via SSH to the container that your WordPress instance is installed on.

Here’s how to set the directory and file permissions correctly, split up into the different WordPress core directories:

WordPress base directory

sudo find /opt/bitnami/apps/wordpress/htdocs -type f -exec chmod 664 {} \;

sudo find /opt/bitnami/apps/wordpress/htdocs -type d -exec chmod 775 {} \;

sudo chown bitnami:daemon -R /opt/bitnami/apps/wordpress/htdocs

wp-admin

sudo find /opt/bitnami/apps/wordpress/htdocs/wp-admin -type f -exec chmod 664 {} \;

sudo find /opt/bitnami/apps/wordpress/htdocs/wp-admin -type d -exec chmod 775 {} \;

sudo chown bitnami:daemon -R /opt/bitnami/apps/wordpress/htdocs/wp-admin

wp-includes

sudo find /opt/bitnami/apps/wordpress/htdocs/wp-includes -type f -exec chmod 664 {} \;

sudo find /opt/bitnami/apps/wordpress/htdocs/wp-includes -type d -exec chmod 775 {} \;

sudo chown bitnami:daemon -R /opt/bitnami/apps/wordpress/htdocs/wp-includes

wp-content

sudo find /opt/bitnami/apps/wordpress/htdocs/wp-content -type f -exec chmod 664 {} \;

sudo find /opt/bitnami/apps/wordpress/htdocs/wp-content -type d -exec chmod 775 {} \;

sudo chown bitnami:daemon -R /opt/bitnami/apps/wordpress/htdocs/wp-content

That’s it!