Google Certified Associate Cloud Engineer 2020

Sign Up Free or Log In to participate!

ssh issue with GCE via public ip

Hi Mattias,

I’ve create a instance from cli and try to ssh that via public ip but getting error, when i try the same via hostname it’s connecting fine.

Error with public ip:

[email protected]:~ (project-id)$ gcloud compute ssh 34.93.41.x

ERROR: (gcloud.compute.ssh) Could not fetch resource:

  • Invalid value for field ‘instance’: ‘34.93.41.x’. Must be a match of regex ‘a-z?|[1-9][0-9]{0,19}’

1 Answers

Hi Piyush,

The format of gcloud compute ssh command is expected to be – 

gcloud compute ssh [USER@]INSTANCE 

USER specifies the username with which to SSH. If omitted, the user login name is used. If using OS Login, USER will be replaced by the OS Login user.

INSTANCE specifies the name of the virtual machine instance to SSH into.

Reference –

> Help from the ERROR message

You’re getting the error because you’re specifying an IP address instead of Instance name.

The error is also hinting that the field value for instance should match the regex ‘a-z?|[1-9][0-9]{0,19}’  which essentially does not allow any DOTS(.) in the name and hence IP addresses can’t be used.

Hope this was helpful!

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?