0

i have created a firewall rule in VPC network for port 22 by assigning an IP with the port e.g (192.168.xx.yy) instead of 0.0.0.0/0 in rules. Now, When I create a compute engine VM instance in Google Cloud Platform and SSH into it, it states that "cannot connect to port 22". I dont want the port tcp:22 to have ip range 0.0.0.0/0 but only have a single ip as stated above? How to solve the issue?

2
  • What system are you SSHing from? From home or from another GCP VM? Dec 1, 2019 at 14:04
  • There is a ssh button near the created instance and gcp opens another browers tab and ssh into it.
    – Saad Tahir
    Dec 1, 2019 at 19:52

1 Answer 1

0

The default SSH firewall rule specifies 0.0.0.0/0 in context of Allow SSH from ANYWHERE (0.0.0.0/0). You can change that IP to the external IP of your local machine, but not an internal 192.168.xx.xx address. You need the one from your router. For example, get your external IPV4 address from here: https://whatismyipaddress.com/

List out the your SSH firewall rule details from the GCP console by clicking on the firewall rule name in VPC Network -> Firewall Rules. The SSH firewall rule details should be as follows if it is to work:

Network = default OR other network name that your VM belongs to

Direction = Ingress (applies to incoming)

Action on match = Allow

Protocols and ports = tcp:22

Source Filters = 0.0.0.0/0 OR the specific external IP address you are using SSH FROM [since this applies to the SSH source IP, not the SSH destination IP]

Enforcement = Enabled

You can also re-affirm the firewall rule applies to your VM by confirming it is listed under Applicable to instances

1
  • this. dont use the IP address given to you by the router but use the public IP as stated. Alternatively, just SSH in on the VM instances page or use puttygen to create a fresh secure set of ssh keys that you can then put in the VM metadata and use putty or winscp to login if you need to be away from GCP. Dec 23, 2020 at 8:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .