Google Cloud Virtual Machine SSH Terminal Could not connect

ng flag

I have a machine installed in Google Cloud VM, I was making the SSH connection here without any problems, but when I wanted to log out and connect again, I started to get no results here.

I stay on the Could not connect, trying screen and when I look at the logs, the output of Updating keys for user and then [UFW BLOCK] catches my attention. Can you help me with this?

John Hanley avatar
cn flag
If the UFW firewall is blocking SSH, I wrote an article on how to either enable SSH or disable the UFW firewall:
pe flag

UFW (uncomplicated firewall) is a firewall configuration tool that runs on top of iptables, included by default within Ubuntu distributions. It provides a streamlined interface for configuring common firewall use cases via the command line.

By default, when enabled UFW will block external access to all ports on a server. In practice, that means if you are connected to a server via SSH and enable ufw before allowing access via the SSH port, you’ll be disconnected. Make sure you follow how to enable SSH access.

To see what is currently blocked or allowed, you may use the verbose parameter when running ufw status, as follows:

sudo ufw status

Allow SSH

When working with remote servers, you’ll want to make sure that the SSH port is open to connections so that you are able to log in to your server remotely.

The following command will enable the OpenSSH UFW application profile and allow all connections to the default SSH port on the server:

sudo ufw allow OpenSSH

Although less user-friendly, an alternative syntax is to specify the exact port number of the SSH service, which is typically set to 22 by default:

sudo ufw allow 22

Disable UFW

If for some reason you need to disable UFW, you can do so with the following command:

sudo ufw disable

Enable UFW

To enable UFW on your system, run:

sudo ufw enable
Ahmet Buğra BUĞA avatar
ng flag
First of all thank you for your answer. I guess I should have given a little more detail. Other users in the Cloud can make SSH connections without any problems, but when my user tries to log in, he gets a Could Not Connect error. This error popped up all of a sudden and I can't log in even though I tried everything, I did the necessary actions in UFWs but it didn't fix it.

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.