ubuntu vnc intranet penetration remote connection

To achieve remote connection at the desktop level of the ubuntu system, vnc needs to be installed in the ubuntu system. Since it is a desktop, the premise is that ubuntu needs to have a graphical interface. If not, you can execute the following command to install a graphical interface


sudo apt install ubuntu-desktop 

sudo apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal 

sudo reboot #重启即可看到图形界面

Install VNC on ubuntu

1. The following command installs vnc in ubuntu

sudo apt-get install x11vnc
  1. Install LightDM, LightDM is designed to support local GUI for best compatibility

sudo apt-get install lightdm

The following options will appear during the installation process, select lightdm and press Enter

3. Set the password. After setting the password, you will be asked if you need to save the password in: /home/root1/.vnc/passwd, select y

x11vnc -storepasswd

Set boot

1. Create a x11vnc.service file

sudo vim /lib/systemd/system/x11vnc.service

2. Press the i key to enter the edit mode, add the following information, !!Note: replace it with your ubuntu user name , press the Esc key to exit editing after adding, and then enter a colon: wq to save

[Unit]
Description=Start x11vnc at startup.
After=multi-user.target
 
[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -auth guess -forever -loop -noxdamage -repeat -rfbauth /home/<USERNAME>/.vnc/passwd -rfbport 5900 -shared
 
[Install]
WantedBy=multi-user.target

2. Set the boot to start

sudo systemctl enable x11vnc.service

2. Start the service

sudo systemctl start x11vnc.service

windows installation VNC viewer connection tool

1. Enter the official website and download the Windows version of the vnc connection tool

https://www.realvnc.com/en/connect/download/viewer/

2. After downloading, open and use the LAN ip to connect, the port is 5900

3. The password interface appears, enter the password set above

  1. The ubuntu desktop appears to indicate success

Intranet penetration

After the local connection is fine, it can only be connected in the LAN at present, but we can use the cpolar intranet penetration tool to achieve remote access.

1. Install cpolar intranet penetration

cpolar official website: https://www.cpolar.com/

Go to the download page of cpolar official website, download the windows installation package to the local and unzip it all the way to install by default

2. Create a tunnel map

cpolar安装成功后,双击打开cpolar【或者在ubuntu浏览器上访问本地9200端口127.0.0.1:9200】,使用cpolar邮箱账号登录 web UI管理界面,如果还没有注册cpolar账号的话,点击免费注册会跳到cpolar官网注册一个账号就可以了

登录成功后,点击左侧仪表盘的隧道管理>>创建隧道,创建一个tcp协议的隧道指向本地5900端口:

隧道名称:可自定义,注意不要与已有的隧道名称重复

协议:tcp

本地地址:5900

域名类型:免费选择随机域名

地区:默认China top即可

点击创建

隧道创建成功后,点击左侧的状态>>;在线隧道列表,可以看到,刚刚创建的隧道已经有生成了相应的公网地址,将其复制下来

公网远程访问

windows vnc viewer 打开,输入tcp公网地址:2.tcp.vip.cpolar.cn:13001,然后点击测试连接

输入上面创建的密码

公网远程连接成功

固定TCP地址

由于以上创建的隧道是随机地址隧道,地址会在24小时内变化,为了使连接更加稳定,需要固tcp地址

需要注意,配置固定TCP端口地址需要将cpolar升级到专业版套餐或以上

保留一个固定的公网TCP端口地址

登录cpolar官网,点击左侧的预留,选择保留的TCP地址。

地区:选择China VIP

描述:即备注,可自定义填写

点击保留

地址保留成功后,系统会生成相应的固定公网地址,将其复制下来

配置固定公网TCP端口地址

在浏览器上访问9200端口,http://127.0.0.1:9200/,登录cpolar web ui管理界面,点击左侧仪表盘的隧道管理>>隧道列表,找到上面创建的隧道,点击右侧的编辑

修改隧道信息,将保留成功的固定tcp地址配置到隧道中

端口类型:修改为固定tcp端口

预留的tcp地址:填写保留成功的地址

点击更新

.隧道更新成功后,点击左侧仪表盘的状态在线隧道列表,找到需要编辑的隧道,可以看到公网地址已经更新成为了固定tcp地址。

测试使用固定TCP端口地址远程ubuntu桌面,我们再次打开VNC viewer,使用固定tcp地址连接,出现密码界面,同样输入上面设置的密码

远程连接成功

Guess you like

Origin blog.csdn.net/probezy/article/details/129147850