Cannot SSH to google cloud Linux machine - google-cloud-platform

When i attempt to SSH from https://console.cloud.google.com/compute/instances?authuser=0&projec
I get the error:
Connection via Cloud Identity-Aware Proxy Failed
Code: 4010
Reason: destination read failed
Please ensure you can make a proper https connection to the IAP for
TCP hostname: https://tunnel.cloudproxy.app You may be able to connect
without using the Cloud Identity-Aware Proxy.
Though on a seperate machine i am able to login, but Firewall and other settings seem identical ?
What should i do to get in ?
Krgds.
C

This issue is due to the lack of a firewall rule to allow-ingress-from-iap with this IP range 35.235.240.0/20 that needs to be configured when using IAP (Identity-Aware Proxy).
To Allow SSH access to all VM instances in your network, do the following:
1- Open the Firewall Rules page (Navigation menu > VPC network > Firewall) and click Create firewall rule
2- Configure the following settings:
Name: allow-ingress-from-iap
Direction of traffic: Ingress
Target: All instances in the network
Source filter: IP ranges
Source IP ranges: 35.235.240.0/20
Protocols and ports: Select TCP and enter 22 to allow SSH
3- Click Create

My impression is that the root casuse, was the the linux box had run out of hard disk space, causing the issues.
So when i recreated the same machine, with more disk space, the issue was resolved.

Related

Can't run GCP VM on public IP with SSH

I am setting up a Virtual Machine node.js server at Google Cloud Platform. I have set up SSH keys so that I can log into my VM. I can successfully log into my VM using SSH-in-browser and start my server.
I can't access my public IP address through Chrome. I get this message:
This site can’t provide a secure connection.
When I try to connect to the IP within SSH-in-browser, I get the following:
$ curl -vso /dev/null --connect-timeout 5 34.68.254.120:8080
* Trying 34.68.254.120:8080...
* connect to 34.68.254.120 port 8080 failed: Connection refused
* Failed to connect to 34.68.254.120 port 8080: Connection refused
* Closing connection 0
I'm new at this. Any ideas would be appreciated. Thanks!
Edit1: Some more details --
Linux VM
port 8080 ingress is open on the firewall
I'm using OSLogin (`enable-oslogin = TRUE' 'enable-oslogin-sk = FALSE')
I can successfully log into console with both SSH-in-Browser and PuTTY, and I can start my server on port 8080
In both, I get the error above when I try to connect to the IP address
EDIT:
Follow below steps to fix “This Site Can’t Provide a Secure Connection” Error :
This error typically indicates a problem with either your browser’s configuration or the SSL certificate on your site.
1) Your local environment doesn’t have an SSL certificate.
2) Outdated SSL caches in the browser : (This is one of the more popular causes. Web browsers store SSL certificates in a cache, much
like other data. This means they don’t have to verify the certificate
every time you visit a site, which speeds up browsing. However, if
your SSL certificate changes and the browser is still loading an
older, cached version, it can cause this error to pop up).
3) Incorrect time and date settings on your computer.
4) Rogue browser extensions.
5) Overzealous antivirus software.
6) An invalid or expired SSL certificate.
If your firewall rules prevent external access:
Check your firewall rules with the following command: gcloud compute firewall-rules list with this, you can review the VPC where
the VM instance was migrated; and if it has allowed the Ingress TCP:
22 Port.
If this firewall rule is missing, you can add the firewall rule in the GCP console -> VPC Networks ->select your VPC network _Click on
the firewall rules to double check that the tcp: 22 port is allowed.
If the issue still is ongoing after checking the firewall rules, you
can follow this guide to start troubleshooting SSH connection.

Code: 4010 - Connection via Cloud Identity-Aware Proxy Failed

I have seen a similar error on stackoverflow, but with a different code (so maybe it is not the same?). Any how I have been thrown this error spontaneously. Sometimes after 20 seconds of starting my instance (and launching SSH in browser), sometimes after 30 minutes, but it completely shuts down my instance.
Connection via Cloud Identity-Aware Proxy Failed
Code: 4010
Reason: destination read failed
You may be able to connect without using the Cloud Identity-Aware Proxy.
If I click the "Cloud Identity-Aware Proxy" button I am getting:
Connection Failed
We are unable to connect to the VM on port 22. Learn more about possible causes of this issue.
Any idea what is happening? I havn't done any changes in my instance settings for a long time.
The issue regarding the Identity-Aware Proxy(IAP) connection to the instance is due to the lack of a firewall rule allow-ingress-from-iap with this IP ranges 35.235.240.0/20 that needs to be configured when using IAP.
To Allow SSH access to all VM instances in your network, do the following:
1- Open the Firewall Rules page (Navigation menu > VPC network > Firewall) and click Create firewall rule
2- Configure the following settings:
Name: allow-ingress-from-iap
Direction of traffic: Ingress
Target: All instances in the network
Source filter: IP ranges
Source IP ranges: 35.235.240.0/20
Protocols and ports: Select TCP and enter 22 to allow SSH
3- Click Create

Connection via Cloud Identity-Aware Proxy Failed

I am getting the following disconnection issues in the GCP Jupiter notebook.
error code: 4010
and
error code: 1006
Can you please suggest some solution?
As part of the IAP configuration steps, you should create a firewall rule that allows ingress traffic to the SSH port from the IAP address range:
GCP Console => VPC network => Firewall rules => Create Firewall Rule
Name: allow-ingress-from-iap
Direction of traffic: Ingress
Target: All instances in the network
Source filter: IP ranges
Source IP ranges: 35.235.240.0/20
Protocols and ports: select TCP and enter 22 to allow SSH
Identity-Aware Proxy > Doc > Setting up IAP for Compute Engine
The error 1006 appears in the GCP Console UI after 1 hour of inactivity of the SSH session via IAP with VMs with Internal IP only, and this is a session timeout on the Google side.
As #mebius99 has mentioned, IAP (Identity-Aware Proxy) requests come from the IP address range 35.235.240.0/20.
Your network firewall must allow these requests to be able to SSH through IAP.
One way to do that (create a firewall-rule) is to run gcloud compute firewall-rules create command.
To do that, first open the cloud shell on the Google cloud console,
Then once the cloud shell opens up, run the following:
gcloud compute firewall-rules create ssh-ingress-from-iap --allow=tcp:22 --source-ranges 35.235.240.0/20 --network [network-name]
Replace [network-name] with your network name (the default VPC network is named: default)
If the above solution doesn't work (or have a similar firewall rule in place already), consider checking the network tags (on the firewall-rules and the VM). It maybe the case that your firewall-rule is allowing the requests to only certain instances that has some tags and the instance you're trying to SSH into doesn't.
For me the error 1006 was related to system Time. I had changed the system time manually to another time zone. SSH worked when system time was sy
Create a firewall for port 22 and add this IP 35.235.240.0/20
attach it to all VM so you will able to establish connection

Problem connecting 2 external IP Google Cloud Platafform

I created my VM(Google Cloud Platform), working with Windows Server 2008 R2. So i installed a program that needs the port 6900 opened to run. The program for work must connect to it own server that is: 200.229.50.3:6900. So i entered in the firewall rules of Google Cloud Platform, put ip as 0.0.0.0/0 and opened the port 6900. Also entered in the advanced configures of firewall on my VM, and also allowed the port 6900. Tried to run the program and failed, tried to run telnet to test and failed. Already checked security settings, disabled firewall, etc. I don't know whats is happening.
Follow my Google Cloud Platafform Firewall Rules bellow:
Firewall Rules
Follow my instance Firewall Rules:
Instance Firewall Rules
Follow the program getting error trying to connect on it own server:
Program error
If someone want enter in my instance to check better it, can download the RDP file from here: RDP file
my external ip: 104.198.152.164
user: lala2018
password: ^#0aQaaz)MXbMNy
The program that the error is ocurring is on the desktop with the name xstart.
Feel free to run it, and try to understand what is the problem, because i can't find reasons for it isn't running right.
Someone can help me?
Edit 1:
Follow my VPC routting:
VPC 1 VPC 2
Edit 2:
Traced Route - 200.229.50.3
After seeing the screenshot of the message you attached, it looks like you are trying to connect from a GCP instance to the server "200.229.50.3" whose IP address belongs to "LEVEL UP! INTERACTIVE LTDA" in Brasil; however, seems "200.229.50.3" is not allowing you to connect ("200.229.50.3" it doesn't respond). If this is correct, you may have to create firewall rules in "200.229.50.3" instead of creating them in GCP.
I can see you have three rules to permit ingress and egress traffic from and to the GCP instances but none of them affects to "200.229.50.3" because this server doesn't belong to the GCP project:
- The GCP firewall rule named "testeee" allows incoming connections from the IP address 200.229.50.3 to all instances within your GCP project through the port 6900.
- The Windows firewall rule named "Port 6900" allows connections from any IP outside the Windows server through the port 6900.
- The GCP firewall rules "mean-stack" and "exit900" are allowing egress traffic from GCP instances to any IP outside the GCP project through the port 6900.
I tried to establish a telnet connection to 200.229.50.3:6900 but it doesn't respond. This could be normal because there could be a firewall in that server which is not allowing connections from my IP address; however, I have to ask the following:
Can you confirm 200.229.50.3 is allowing connections through the port 6900 from your GCP Instance?

Access localhost on Google Cloud instance using External IP

There are many similar questions to this on SO, but none of the solutions I saw really solved my issue completely. I'm doing test runs for a website framework hosted on the Google Cloud Platform.
By default, the website is hosted on http://localhost:2800 And I know the external IP of the instance I'm running it on. How can I access the hosted website through a browser on my local machine? Do I use virtual hosts / port forwarding etc.?
go to your VPC firewall
https://console.cloud.google.com/networking/firewalls
and create a firewall rule to allow traffic on your desired tcp port
Create a Firewall Rule for SQL Server
Configure a firewall rule to allow traffic on port 1433 so other clients can connect to the newly created SQL Server instance over the public internet:
In the Developers Console main menu, go to the Firewall rules section.
OPEN THE FIREWALL RULES
Click the Add firewall rule button.
Name the new firewall rule allow-tcp-1433.
Set Source Filter to IP Ranges.
For Source IP Ranges enter 0.0.0.0/0. This value allows access by all IP addresses.
Warning: This configuration leaves your SQL Server instance open to traffic from everyone, everywhere. It is used only for demonstration purposes. In production environments, restrict access to only those IP addresses that need access.
For Allowed protocols and ports enter tcp:1433.
Click the Create button to create the firewall rule.
Set firewall rules for you google cloud project with following properties:
Target: all instances
Direction: ingress
Source IP ranges: 0.0.0.0/0
Ports and protocols: allow all
Then Depending on your framework, set allowed_host to externalIP or "*" .
For example - In Django, in settings.py set ALLOWED_HOSTS = ["*"]
Now run server on specific 0.0.0.0:[your_port]
For example in django - Python manage.py runserver 0.0.0.0:8000
After this note down you instance external IP address and then in your browser :- goto
[external-IP:[your_port]]
you have to go VPC network, then add firewall to allow your port. then don't forget to select [All intances in the network] (see pic). because, by default its value is [Spesified by tags].
and you can access that instance to its External IP
Try your [externalip]:[port] This worked for me in Amazom ec2.
example: 31.181.171.141:2800