Virtual machine ubuntu uses VNC to implement remote desktop


        During project development, the visualization of the project is not always available. Especially for the use of personal virtual spaces such as workspaces at work, there is no way to achieve a visual interface and can only be operated through the terminal. However, without visualization, the results of the projects we develop cannot be checked at all times. At this time, VNC can be used for remote desktop.

1. Install related components

        Implementing remote desktop requires multiple components, and the component installation can be completed through Linux terminal commands. Remember that the following components are all installed in a personal virtual space, such as ubuntu. Note that the virtual machine needs to be connected to the external network first.

Install Vnc and desktop

eval $(curl -s deploy.i.brainpp.cn/httpproxy)	# 使用外网代理
sudo apt-get update
sudo apt install xfce4 xfce4-goodies
sudo apt install tigervnc-standalone-server tigervnc-common
sudo apt-get install xserver-xorg

Install tigervnc

oss cp s3://wjn-share/Carla/vnc/tigervnc-1.11.0.x86_64.tar.gz .
tar xvf tigervnc-1.11.0.x86_64.tar.gz
cd tigervnc-1.11.0.x86_64
mv usr local
sudo cp -r local/* /usr/local/

Download noVNC

git clone https://github.com/novnc/noVNC.git

2.Configure components

Configure vncserver

vncserver             # 输入密码,用来以后登录远程桌面..
vncserver -kill :*    # 删除已经在运行的server
		              #注意如果运行的server过多可以用此命令一次性全部关闭

Configuration parameter file

        Open $HOME/.vnc/xstartup, use the vim command to open the operation, and fill in the blank area at once

#!/bin/sh
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
startxfce4 &

Configure browser plug-in

        Install the SwitchyOmega plug-in in the browser that needs to open the remote desktop. You can use Google Chrome to see if it is available and make the following configuration.

        Enter the option configuration interface, click the Proxy item on the right, and make the following modifications:

        Click the auto switch item on the right and make the following modifications:

        Complete the configuration and open the proxy settings in the upper right corner of the browser before opening:

3.Open the window

 Virtual machine terminal:

        First, open tmux on your personal virtual machine and run the following command on the virtual machine terminal.

vncserver -geometry 1280x720

        Obtain the internal DNS through the following command

hostname --fqdn

        cd to the noVNC/utils directory downloaded earlier, run the following command and keep it still

./novnc_proxy --vnc 127.0.0.1:5901

Personal browser:

        Press Win+R, enter cmd, and hang up the agent on the personal computer terminal. Nothing may happen after running it, but it is actually successful.

ssh -N -D 7071 {虚拟机2用户名和地址}@域名通配符

        Visit the page in the browser

http://{内部 DNS}:{novnc指定端口}/vnc.html

display effect

        If normal, the desktop can be displayed in the browser

Guess you like

Origin blog.csdn.net/q1234567890012/article/details/131292613