I had a Linux (Debian 9) VM running inside the GCP, I can ssh to it via PuTTY. Now I want to use VNC to connect it and failed.
The following steps are what I did so far.
I tried to follow the article (https://linuxize.com/post/how-to-install-and-configure-vnc-on-debian-9/) to set up a vnc server and it looks good.
clin4@chen-k8s-master:~$ sudo systemctl status vncserver@1.service vncserver@1.service - Remote desktop service (VNC) Loaded: loaded (/etc/systemd/system/vncserver@.service; enabled; vendor preset: enabled) Active: active (running) since Fri 2020-04-03 00:41:24 UTC; 17h ago Process: 734 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill :1 > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS) Main PID: 956 (vncserver) Tasks: 0 (limit: 4915) CGroup: /system.slice/system-vncserver.slice/vncserver@1.service ‣ 956 /usr/bin/perl /usr/bin/vncserver :1 -geometry 1440x900 -alwaysshared -fg Apr 03 00:41:23 chen-k8s-master systemd[1]: Starting Remote desktop service (VNC)... Apr 03 00:41:23 chen-k8s-master systemd[734]: pam_unix(login:session): session opened for user clin4 by (uid=0) Apr 03 00:41:24 chen-k8s-master systemd[1]: Started Remote desktop service (VNC). Apr 03 00:41:25 chen-k8s-master systemd[956]: pam_unix(login:session): session opened for user clin4 by (uid=0)
I open the port 5901 (5901-5910) via firewalld
clin4@chen-k8s-master:~$ sudo firewall-cmd --list-all public target: default icmp-block-inversion: no interfaces: sources: services: ssh dhcpv6-client ports: 443/tcp 6443/tcp 2379-2380/tcp 10250/tcp 10251/tcp 10252/tcp 10255/tcp 6783/tcp 30000-32767/tcp 5901-5910/tcp protocols: masquerade: no forward-ports: source-ports: icmp-blocks: rich rules:
Use netstat to check
clin4@chen-k8s-master:~$ sudo netstat -tulpn | grep LISTEN tcp 0 0 127.0.0.1:5901 0.0.0.0:* LISTEN 1003/Xtigervnc tcp6 0 0 ::1:5901 :::* LISTEN 1003/Xtigervnc
Create a firewall rule in the GCP, tags mapping on tcp:5901, and the VM has this tag.
remote-access Ingress remote-access IP ranges: 0.0.0.0/0 tcp:6443,3389,5900-5910 Allow 1000
Try to use Chrome VNC viewer to connect to the VM public IP with port 5901 and got the error message "Cannot establish connection. Are you sure you have entered the correct network address, and port number if necessary?"
What did I miss?