In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article focuses on "how to install and configure VNC on Ubuntu18.04". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to install and configure VNC on Ubuntu18.04.
VNC is a free open source connection system based on UNIX and Linux operating systems that allows users to interact with the graphical desktop environment on a remote server using the keyboard and mouse.
To complete this tutorial, you need to:
A Ubuntu server with a non-root account that can use the sudo command is set up, and the firewall is turned on.
A local computer with a VNC client installed that supports VNC connections through SSH tunnels.
On Winows, you can use TightVNC,RealVNC or UltraVNC.
On macOS, you can use built-in screen sharing programs or cross-platform applications such as RealVNC.
On Linux, you can choose from many options, including selecting vinagre,krdc,RealVNC, or TightVNC.
Step 1-install the desktop environment and VNC server by default, the Ubuntu 18.04 server does not have a graphical desktop environment or VNC server installed, so we will install them first. Specifically, we will install the TightVNC package available in the latest Xfce desktop environment and the official Ubuntu repository.
On your server, update your package list:
Sudo apt update now installs the Xfce desktop environment on your server:
After the sudo apt install xfce4 xfce4-goodies installation is complete, install the TightVNC server:
"sudo apt install tightvncserver to complete the initial configuration of the VNC server after installation, use the vncserver command to set the security password and create the initial configuration file:"
The vncserver system will prompt you to enter and verify your password to access your computer remotely:
You will require a password to access your desktops. Password: Verify: the password must be between six and eight characters long. Passwords longer than 8 characters are automatically truncated.
After verifying the password, you can choose to create a view-only password. Users who log in with only the view password will not be able to control the VNC instance using the mouse or keyboard. This is a useful option if you want to use a VNC server to present content to others, but it is not required.
The process then creates the necessary default profile and connection information for the server:
Would you like to enter a view-only password (YBO)? N xauth: file / home/sammy/.Xauthority does not exist New'X' desktop is your_hostname:1 Creating default startup script / home/sammy/.vnc/xstartup Starting applications specified in / home/sammy/.vnc/xstartup Log file is / home/sammy/.vnc/your_hostname:1.log now let's configure the VNC server.
Step 2-configuring the VNC server VNC server requires knowing the commands to be executed at startup. Specifically, VNC needs to know which graphical desktop it should connect to.
These commands are located in the configuration files invoked in the .vnc folder of xstartup under the home directory. The startup script was created when vncserver was running in the previous step, but we will create our own script to start the Xfce desktop.
The first time you set up VNC, it starts the default server instance on port 5901. This port is called the display port and is called: 1 by VNC. VNC can launch multiple instances on other display ports, such as 2, refine, 3, and so on.
Because we are going to change the way the VNC server is configured, first 5901 stop the VNC server instance running on the port with the following command:
The output of vncserver-kill: 1 should look like this, although you will see a different PID:
Killing Xtightvnc process ID 17648 before modifying the xstartup file, back up the original file:
Mv / .vnc/xstartup ~ / .vnc / xstartup.bak now create a new xstartup file and open it in a text editor:
Nano ~ / .vnc / xstartup automatically executes the commands in this file whenever you start or restart the VNC server. If it hasn't started yet, we need VNC to start our desktop environment. Add these commands to the file:
#! / bin/bash xrdb $HOME/.Xresources startxfce4 & the first command in the file, xrdb $HOME/.Xresources, tells VNC's GUI framework to read the server user's .Xresources file. Users can change some settings of the graphics desktop in .Xresources, such as terminal colors, cursor themes, and font rendering. The second command tells the server to start Xfce, where you can find all the graphics software you need to manage the server comfortably.
To ensure that the VNC server can use this new boot file correctly, we need to make it executable.
Sudo chmod + x ~ / .vnc / xstartup now restart the VNC server.
Vncserver you will see output similar to this:
Once the New 'X' desktop is your_hostname:1 Starting applications specified in / home/sammy/.vnc/xstartup Log file is / home/sammy/.vnc/your_hostname:1.log is in place, let's connect to the server from the local computer.
Step 3-VNC itself does not use a security protocol when connecting securely to a VNC desktop connection. We will use the SSH tunnel to securely connect to our server and then tell our VNC client to use the tunnel instead of connecting directly.
Create a SSH connection on the local computer so that it can be safely forwarded to the localhostVNC connection. You can do this from a terminal on Linux or macOS using the following command:
Ssh-L 5901 sammy your_server_ip 127.0.0.1 5901-C-N-l the port binding specified by the-L switch. In this case, we bind port 5901 of the 5901 remote connection to the port on the local computer. The-C switch enables compression, while the-N switch tells ssh that we do not want to execute remote commands. The-l switch specifies the remote login name.
Remember to replace sammy and your_server_ip with your server's Suto non-root username and IP address.
If you are using a graphical SSH client, such as PuTTY, use your_server_ip as the connection IP and set localhost:5901 as the new forwarding port in the program's SSH tunnel settings.
After the tunnel is running, use the VNC client to connect to the localhost:5901. You will be prompted to authenticate using the password you set in step 1.
Once connected, you will see the default Xfce desktop. It should look like this:
You can use the File Manager or the command line to access files in the home directory, as follows:
Press the CTRL+C terminal to stop the SSH tunnel and return to your prompt. This will also disconnect your VNC session.
Next, let's set up the VNC server as a service.
Step 4-run VNC as a system service next, we set up the VNC server as a systemd service so that we can start, stop, and restart it as needed, just like any other service. This will also ensure that VNC starts when the server is restarted.
First, create a new / etc/systemd/system/vncserver@.service unit file using your favorite text editor:
The symbol at the end of the sudo nano / etc/systemd/system/vncserver@.service@ name will let us pass in a parameter that we can use in the service configuration. We will use it to specify the VNC display port we want to use when managing the service.
Add the following line to the file. Be sure to change the values of the user, group, WorkingDirectory, and the user name in the PIDFILEE value to match your user name:
[Unit] Description=Start TightVNC server at startup After=syslog.target network.target [Service] Type=forking User=sammy Group=sammy WorkingDirectory=/home/sammy PIDFile=/home/sammy/.vnc/%H:%i.pid ExecStartPre=-/usr/bin/vncserver-kill:% I > / dev/null 2 > & 1 ExecStart=/usr/bin/vncserver-depth 24-geometry 1280x800:% I ExecStop=/usr/bin/vncserver-kill:% I [Install] WantedBy=multi-user.target if VNC is already running, the ExecStartPre command will stop. The ExecStart command starts VNC and sets the color depth to a 24-bit color with a resolution of 1280 × 800. You can also modify these startup options to meet your needs.
Save and close the file.
Next, let the system know about the new unit file.
Sudo systemctl daemon-reload enables unit files.
Sudo systemctl enable vncserver@1.service 's @ symbol below 1 indicates that the service whose number is displayed should have appeared, in which case the default: 1 is discussed in step 2.
If the VNC server is still running, stop its current instance.
Vncserver-kill: 1 then starts it, just like any other systemd service.
Sudo systemctl start vncserver@1 you can use this command to verify that it is started:
Sudo systemctl status vncserver@1 if it starts correctly, the output should look like this:
● vncserver@1.service-Start TightVNC server at startup Loaded: loaded (/ etc/systemd/system/vncserver@.service; indirect; vendor preset: enabled) Active: active (running) since Mon 2018-07-09 18:13:53 UTC; 2min 14s ago Process: 22322 ExecStart=/usr/bin/vncserver-depth 24-geometry 1280x800: 1 (code=exited, status=0/SUCCESS) Process: 22316 ExecStartPre=/usr/bin/vncserver-kill: 1 > / dev/null 2 > & 1 (code=exited, status=0/SUCCESS) Main PID: 22330 (Xtightvnc). After restarting your computer, your VNC server is now available.
Start the SSH tunnel again:
Ssh-L 5901 localhost:5901 127.0.0.1 sammy your_server_ip then use the VNC client software to establish a new connection localhost:5901 to connect to your computer.
At this point, I believe you have a deeper understanding of "how to install and configure VNC on Ubuntu18.04". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.