Environment
- Ubuntu 16.04
- Google Cloud Platform
Prerequisites
Create VM instance.
Before the installation, you need to create a new VM instance based on your requirement. See "How to create a GCP VM instance."Create 5901 port in firewall rules.
Create a port on firewall page for VNC viewer, default port is 5901. To avoid from internet attack, we put constraint on client IP addresses according to CIDR (Classless Inter-Domain Routing). In other words, We only allow some valid hosts that can be used on a specific subnet to connect VNC server.Let's say 123.123.123.123 as client IP address, where it is a dynamic IP address, but the IP may change from 123.123.1.1 to 123.123.255.255. We don't know what IP address would change to next time. To solve this problem we create a VNC server port (5901) in firewall rules according to CIDR table (click here to see more).
Option 1: VPC Network → Firewall rules
Option 2: Create port via gcloud command with CIDR subnet.
gcloud compute firewall-rules create vncserver --allow tcp:5901 --source-ranges 123.123.0.0/16
Installation
Step 1: Open SSH window of the instance.
Step 2: Create a bash script named install_desktop.sh
.
This script is going to upgrade system followed by the installation of desktop dependencies and VNC server.#!/bin/bash
echo '==== Upgrade system ===='
sudo apt-get update
sudo apt-get upgrade -y
echo '==== Install packages ===='
sudo apt-get install -y gnome-shell
sudo apt-get install -y ubuntu-gnome-desktop
sudo apt-get install -y autocutsel
sudo apt-get install -y tightvncserver
sudo apt-get install -y gnome-core
sudo apt-get install -y gnome-panel
sudo apt-get install -y synaptic
touch ~/.Xresources
autocutsel
is a package that allows you to copy and paste between remote server and local computer in vnc viewer.
Run created bash script
install_desktop.sh
.
bash install_desktop.sh
Step 3: Setup VNC server
To setup VNC server, run:$ vncserver
You will require a password to access your desktops.
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
xauth: file /home/chunming/.Xauthority does not exist
New 'X' desktop is multitask-gpu-asia:1
Creating default startup script /home/chunming/.vnc/xstartup
Starting applications specified in /home/chunming/.vnc/xstartup
Log file is /home/chunming
/.vnc/multitask-gpu-asia:1.log
We can see that the startup script was generated under
/home/chunming/.vnc/xstartup
Step 4: Modify VNC configuration
Modify the generated startup script/home/chunming/.vnc/xstartup to the same as below:
#!/bin/sh
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin:$PATH
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
autocutsel -fork
xsetroot -solid grey
export XKL_XMODMAP_DISABLE=1
export XDG_CURRENT_DESKTOP="GNOME-Flashback:Unity"
export XDG_MENU_PREFIX="gnome-flashback-"
unset DBUS_SESSION_BUS_ADDRESS
gnome-session --session=gnome-flashback-metacity --disable-acceleration-check --debug &
Step 5: Edit .bashrc
file
Add a new command to~/.bashrc
. It willl kill VNC session and then start a new one with indicated resolution.
$ vim ~/.bashrc
Add restart_vnc() function
function restart_vnc() {
vncserver -kill :1
vncserver -geometry "$1"
}
Activate it.
$ source ~/.bashrc
Step 6: Run VNC server with 1920x1080 resolution and test connection.
$ restart_vnc 1920x1080
Download VNC viewer (Click HERE to download). You can connect to IP address with 5901 port of VM instance.
Step 7: Adjust desktop theme
Install theme packagessudo apt-get install -y gnome-themes-standard
sudo apt-get install adwaita-icon-theme-full adwaita-icon-theme
gsettings get org.gnome.metacity theme
gsettings set org.gnome.metacity theme 'Adwaita'
Open Terminal after connected to VNC server. Execute following command.
$ sudo gnome-tweak-tool
Then you are allowed to change desktop theme.
Step 8: Keep long running background process (Optional)
Any background processes that were running are likely killed automatically when the user logs out of a session, whether it was a desktop session, a VT session, or when you SSHed into a machine. For example, you can no longer start a screen or tmux session, log out, and expect to come back to it.
This feature by default, and it should rather be disabled by default in Debian, either by compiling systemd with
To enable it, edit system login config.
--without-kill-user-processes
or by setting KillUserProcesses=no
in /etc/systemd/logind.conf
.To enable it, edit system login config.
$ sudo vim /etc/systemd/logind.conf
...
# Uncomment this line
KillUserProcesses=no
...
Then reboot your system.
For more info: systemd kill background processes after user logs out
Troubleshooting
Terminal does not start on Remote desktop
Reason: The environment thatgnome-terminal-server
is started with does not correctly set the locale to a UTF-8 locale. Check /etc/default/locale
$ vim /etc/default/locale
# check if locale is correct
LANG=en_US.UTF-8
Configure locales
$ sudo dpkg-reconfigure locales
Select en_US.UTF-8
However, one of my VM instances does not work at all even though I did reconfigure the locales. The problem is resolved by re-installation from step 1 to step 6. Then it works fine without any problem.
Too many authentication failures with VNC
The likely reason why this occurs is due to bots crawling the internet and looking for vulnerable servers to attack. They will try to brute force their way into a server, which is a numbers game, and will only work on a small amount of servers.Make sure that your instance is not exposed to the internet entirely. Check the Source filter in Firewall rules is not set as 0.0.0.0/0. Limit IP ranges via CIDR rule or your client IP address.
Next, change the VNC password immediately by executing this command.
cd ~/.vnc/passwd
# change password
vncpasswd passwd
→ Read more: Add Swap space to GCP VM Instance
References
- Installing and Running Ubuntu Desktop on Google Cloud Compute: Tutorial for The Absolute Novice
- 【筆記】在GCP上建立可Remote dekstop的Ubuntu環境
- GDBus.Error:org.freedesktop.DBus.Error.Spawn.ChildExited: Process org.gnome.Terminal exited with status 8
- Terminal does not start on Remote Desktop; how to fix it?
- How to Resolve/Prevent ‘Too Many Authentication Failures’ with VNC
- Your desktop on Google Cloud Platform
- Install VNC on Ubuntu 16.04
- vncserver grey screen ubuntu 16.04 LTS
- VNC connection to a Linux VM just shows a gray screen… but isn't gnome running?
thanks for sharing,hope it will be helpful for too many people that are searching for this topic
回覆刪除Google Cloud Platform Training
GCP Online Training
Google Cloud Platform Training In Hyderabad
Setup Gui Desktop On Google Cloud Platform (Gcp) Vm Instance >>>>> Download Now
刪除>>>>> Download Full
Setup Gui Desktop On Google Cloud Platform (Gcp) Vm Instance >>>>> Download LINK
>>>>> Download Now
Setup Gui Desktop On Google Cloud Platform (Gcp) Vm Instance >>>>> Download Full
>>>>> Download LINK RR
Very informative and creative content. This concept is a good way to enhance the knowledge.thanks for sharing
回覆刪除GCP Online Training
Google Cloud Platform Training In Hyderabad
Google Cloud Platform Training
Doesn't work now
回覆刪除
回覆刪除Very nice post..After reading your post,thanks for taking the time to discuss this, I feel happy about and I love learning more about this topic.
Oracle Training in Chennai | Certification | Online Training Course | Oracle Training in Bangalore | Certification | Online Training Course | Oracle Training in Hyderabad | Certification | Online Training Course | Oracle Training in Online | Oracle Certification Online Training Course | Hadoop Training in Chennai | Certification | Big Data Online Training Course
python online training
回覆刪除python training
Setup Gui Desktop On Google Cloud Platform (Gcp) Vm Instance >>>>> Download Now
回覆刪除>>>>> Download Full
Setup Gui Desktop On Google Cloud Platform (Gcp) Vm Instance >>>>> Download LINK
>>>>> Download Now
Setup Gui Desktop On Google Cloud Platform (Gcp) Vm Instance >>>>> Download Full
>>>>> Download LINK
(x-Force keygen) для всех продуктов autocad 2021 Avid Sibelius 8 Camtasia Studio 8 Crack is trustful software which records your computer XForce Keygen Download
回覆刪除Avid Sibelius Ultimate 2022.10.1469 Crack is a songs records gadget, costly software and use it to create a variety of records. Which you require to make.Sibelius Ultimate Crack Reddit
回覆刪除nice,,,,..............................!
回覆刪除google cloud data engineer certification
nice ......................!
回覆刪除ui path training
google cloud data engineer certification