0

我有一个在 GCP 内运行的 Linux (Debian 9) VM,我可以通过 PuTTY 连接到它。现在我想用VNC连接它,但失败了。

以下步骤是我到目前为止所做的。

  1. 我尝试按照文章 ( https://linuxize.com/post/how-to-install-and-configure-vnc-on-debian-9/ ) 设置 vnc 服务器,它看起来不错。

       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)
    
  2. 我通过firewalld打开端口5901(5901-5910)

    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:
    
  3. 使用 netstat 检查

    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
    
  4. 在GCP中创建防火墙规则,tcp:5901上的tags映射,VM有这个tag。

    remote-access Ingress remote-access IP ranges: 0.0.0.0/0 tcp:6443,3389,5900-5910 Allow 1000
    
  5. 尝试使用 Chrome VNC 查看器通过端口 5901 连接到虚拟机公共 IP 并收到错误消息“无法建立连接。您确定输入了正确的网络地址和端口号(如果需要)?”

我错过了什么?

4

0 回答 0