I have problem to connect me glassfish server from compute engine - google-cloud-platform

i´m using ubuntu 18.04 lts in google compute engine and glassfish server running perfectly as seen in the following image:
already configure a static ip to the gcp vm:
and i remove the S so I can access my server
and i also add port 8080 to be able to connect and nothing keeps throwing me error
already try like this :http://34.94.96.242:8080
and this: http://34.94.96.242:4848
And i still don't have access

Did you try reaching your glassfish server inside the Compute Engine?, I mean using for example:
curl localhost:[PORT]
in the terminal and see the output, if OK, your installation is OK and probably there is a firewall rule missing, so you have to create it with the specific port.
For example for enabling traffic in port 22 for using SSH, you need to execute the following command in cloud shell:
gcloud compute firewall-rules create default-allow-ssh --allow tcp:22
or for opening port 8080
gcloud compute firewall-rules create default-allow-glassfish --allow tcp:808
Take a look at this documentation about how to set up firewall rules in GCP step-by-step.

Related

There is an open port on GCP but netstat does not show it

I have set up two firewall rules, one opens port 9092 and the other opens port 999. I followed steps outlined here. Here is the picture:
When I execute netstat -tuplen, I get the following:
and non of those ports are there. Also, when I use telnet ip 999 or telnet ip 9092, I do not get any responses. Note that for port 9092, I used Target tags: tag1 and added it to Network tags on my VM but for port 999 it is set to All instances in the network. In addition, when I use gcloud to open a port I get the following message:
user1#instance:~$ gcloud compute firewall-rules create port8000 --allow tcp:8000 --source-tags=tags02 --source-ranges=0.0.0.0/0 --description="blah"
Creating firewall...failed.
ERROR: (gcloud.compute.firewall-rules.create) Could not fetch resource:
- Request had insufficient authentication scopes.
What am I doing wrong and how I can fix it?
Regarding the error you got with the gcloud command, the command looks right. The reason for the "insufficient authentication scopes" error is because it looks like you're trying to run this gcloud command from a GCE VM and there's a scope attached to it.
The default scope should be Allow default access. Here, you won't have access to the API required to add/modify firewall rules. You have to shutdown the VM, update the scope (change it to Allow full access to all Cloud APIs) and start it up again (if you wish to run this from your VM). Otherwise, just use cloud shell.
EDIT: I didn't realize you didn't have anything running that listens on 999 or 9092, so of course you're not going to get any sort of response. If you need a quick listener then use netcat (nc) to run a listener on the port you want (e.g. nc -l 999)

Cannot attempt to google cloud console instance

I was able to login via ssh normally but it just stopped working.
I tried to stop and start instance but it doesn't help. Could anybody help?
You could check your Firewall Rules in GCP console and if it is not created you can create the rule and with port number 22
$ gcloud compute firewall-rules create default-allow-ssh --allow tcp:22
After try to connect to SSH...

Unable to login to a GCP VM machine: kex_exchange_identification: Connection closed by remote host

I am trying to login to a VM machine but unable to get in there as the below error pops up:
ERROR: (gcloud.beta.compute.start-iap-tunnel) Error while connecting [[Errno 1] Operation not permitted].
kex_exchange_identification: Connection closed by remote host
ERROR: (gcloud.beta.compute.ssh) [/usr/bin/ssh] exited with return code [255].
Command used to log in:
gcloud beta compute ssh --zone "us-east1-b" "user1#test" --project "my-test-project"
When I use the same command from a different machine then it allows me to login to the test VM.
I have been looking at possible solutions related to the firewall settings but unable to get success. Can anyone help here ?
I try to connect with an instance with the command that you post and worked for me when I use it from the cloud shell and from another instances. The error that is given to you could happen for different reason, which are:
The VM is booting up and sshd is not running yet. You can't connect to a VM before it is running.
To resolve this issue, wait until the VM has finished booting and try to connect again.
The firewall rule allowing SSH is missing or misconfigured. By default, Compute Engine VMs allow SSH access on port 22. If the default-allow-ssh rule is missing or misconfigured, you won't be able to connect to VMs.
To resolve this issue, Check your firewall rules and re-add or reconfigure default-allow-ssh.
sshd is running on a custom port. If you configured sshd to run on a port other than port 22, you won't be able to connect to your VM. To resolve this issue, create a custom firewall rule allowing tcp traffic on the port that your sshd is running on using the following command:
gcloud compute firewall-rules create FIREWALL_NAME --allow tcp:PORT_NUMBER
Your custom SSH firewall rule doesn't allow traffic from Google services. SSH connections from the Cloud Console are refused if custom firewall rules do not allow connections from Google's IP address range.
To solve this issue visit this link
The sshd daemon isn't running or isn't configured properly. The sshd daemon enables SSH connections. If it's misconfigured or not running, you can't connect to your VM. To resolve this issue, review the user guide for your operating system to ensure that your sshd_config is set up correctly.

Cannot connect o google cloud VM

When trying to connect to my google cloud RDP i receive an error saying that my RDP is offline when it is not. At first I thought the error was on my side, but after trying with another RDP it worked fine, any ideas?
You should first check that port 3389 is open on the GCE firewall. If not, run a command like this to create the rule $ gcloud compute firewall-rules create rdp --allow tcp:3389 --source-ranges 0.0.0.0/0 . More info is available here.
Here is a document to troubleshoot RDP issues, you can try these steps. Also you can connect to the instance using a serial console.

GCP instance ubuntu connection refused using ssh and terminal?

I was using digitalocean and want to try out gcp compute instance. I created an ubuntu instance, did cat ~/.ssh/id_rsa.pub in my terminal and added onto the instance. Then I tried ssh james#external ip in my terminal (I'm using mac) but it just hang there.. then a min later, I got Connection refused error. What's wrong?
There are numerous possible reasons for this, but mostly likely you're missing a firewall rule to allow connections from the outside:
gcloud compute firewall-rules create default-allow-ssh --allow tcp:22
If this doesn't help, check out the Troubleshooting SSH article in the GCP docs.
First check your network can communicate to compute engine via simple ping command.
ping <GCE external IP>
or
telnet <GCE external IP> 22
If you getting request timed out then most probably firewall issue. go to cloud console and create/update firewall rule under VPC section. search tcp:22 in firewalls section and edit/create firewall rule (add your IP ranges into source IP range section) for ssh connection.
refer: https://cloud.google.com/sdk/gcloud/reference/compute/firewall-rules/create