Install and configure VNC on AWS Ubuntu and connect via SSH tunnel

Label: AWSUbuntuVNCSSHTunnel
849 reading comment(0) Collection Report
Classification:

Install and configure tightvncserver on AWS Ubuntu, and through the SSH tunnel remote desktop connection, record the experimental process.

1, install tightvncserver
Because xfce4 xfce4-goodies has been installed, there is no need to install. The following instructions to install tightvncserver.
Sudo apt-get update
Sudo apt-get install tightvncserver

2, set the vncserver password, login use
If you do not set the user name and password, you need to set up, I have set up in the previous experiments with the Ubuntu and password, so I do not need to set up here. Set user password:Connect AWS EC2 instance Ubuntu remote desktop Linux

Set the vncserver password, password here for a maximum of 8 characters, set the password at the same time, the system on the vncserver were set up.
Ncserver

3, set up the VNC server
VNC is the main server startup settings when executing the instruction, VNC started, automatically start a server routines, use the display port 5901, VNC recognition: 1, similarly newly opened port is: 2, 3, and so on, the use of 5900+x port.
To configure the 5901 settings, first stop the routine running on port 5901,
Vncserver -kill: 1

Configure the xstartup file, first back up the original file to prevent future use,
MV ~/.vnc/xstartup ~/.vnc/xstartup.bak

Create a new xstartup file,
Emacs ~/.vnc/xstartup

Add the following three lines in the file,
# /bin/bash!
Xrdb $HOME/.Xresources
Startxfce4 &

First line instructionXrdb $HOME/.XresourcesTell the GUI framework to read the server.XresourcesFile,.XresourcesIs the user to change the graphical desktop settings, such as terminal color, character pointer style and font, etc..
Second lines of instructions tell the server to start XFCE, through the corresponding graphical interface software management server.

Modify to executable,
Sudo Chmod +x ~/.vnc/xstartup

4, set up the VNC service file
In order to better control the VNC server, it is configured to Ubuntu VCN services, more convenient to carry out start, stop, restart operation.
Create a new service file vncserver,
Sudo Emacs /etc/init.d/vncserver

The first part is to declare some common settings that VNC will use, such as user name and resolution.
# /bin/bash!
PATH= "$PATH:/usr/bin/"
Export USER= "ubuntu"
DISPLAY= "1"
DEPTH= "16"
GEOMETRY= "1024x768"
OPTIONS= "-depth ${DEPTH} ${GEOMETRY}: ${DISPLAY} -geometry -localhost"
/lib/lsb/init-functions

Here use Ubuntu for the user name as well as the resolution of 1024x768, according to the need to change.

Add an instruction to manage the new service, the following code block opens the VNC server using the start keyword, and returns the service being opened,
Case "$1" in
Start)
Log_action_begin_msg "Starting vncserver user'${USER}'on for localhost:${DISPLAY}"
Su ${USER} -c "/usr/bin/vncserver ${OPTIONS}"
;;

The following code blocks use the stop keyword to close the VNC server and stop existing services,
Stop)
Log_action_begin_msg "Stopping vncserver user'${USER}'on for localhost:${DISPLAY}"
Su ${USER} -c /usr/bin/vncserver -kill: ${DISPLAY}"
;;

The last block of code uses the restart keyword to combine the previous stop and start,
Restart)
$0 stop
$0 start
;;
ESAC
Exit 0

Set file to executable,
Sudo Chmod +x /etc/init.d/vncserver

5, remember to set the AWS Ubuntu security group
If you do not use the tunnel, you need to release port 5901 data.

6, through the SSH tunnel test VNC connection

The following is a closed VNC service,
Ubuntu@ip-: sudo service vncserver start ~$
* Starting vncserver user'ubuntu'on for localhost:1...
New'X'is ip-: 1, desktop

Starting applications specified in /home/ubuntu/.vnc/xstartup
Log file is /home/ubuntu/.vnc/ip-: 1.log

Ubuntu@ip-: sudo service vncserver stop ~$
* Stopping vncserver user on localhost:1 Killing process ID Xtightvnc 20143 for
Ubuntu@ip-: ~$

As shown in the following figure:
UltraVNC_Viewer4

Putty settings in the Tennels to add Source 5901 and Destination for localhost:5901 and port point add,

Putty_tunnel

Use SSH to connect to the AWS Ubuntu server, the command line, the connection has been established.

Open UltraVNC Viewer, VNC Server set to: localhost:5901, point Connect,
UltraVNC_Viewer

Will pop up the dialog box to enter the password, the previous set of 8 characters, as shown in the following figure,
UltraVNC_Viewer1

Enter the remote AWS Ubuntu desktop as shown below,
UltraVNC_Viewer2

The VNC server is a waste of resources, as shown below, load average:3.06, 2.85, 2.49
UltraVNC_Viewer3

Reference links:
1,Set_up_an_ssh_tunnel_with_putty
2,How to and Configure on Ubuntu 14.04 VNC
3,How To VNC On Ubuntu 14.04 Server
4,How to VNC on Ubuntu 14.04 Server LTS
5,How To And Configure On Ubuntu 14.04 VNC

Other VNC links:
VNC Reference link:
Https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/System_Administrators_Guide/ch-TigerVNC.html#proc-configuring-vncserver
Http://www.uvnc.com/home.html
Https://www.realvnc.com/products/open/4.1/winvncviewer.html
Http://www.putorius.net/2015/04/how-to-install-vnc-server-in-red-hat-7.html

top
Zero
step on
Zero

Reference knowledge base

Guess you are looking for
View comments
* the above user comments represent their personal views and do not represent the views or positions of the CSDN website
    personal data
    • Visit:175286 times
    • Integral:Three thousand six hundred and seven
    • Grade:
    • Ranking:7289th place
    • Original:199
    • Reprint:0
    • Translation:0
    • Comment:31
    Article classification
    Latest comments
    Personal other non-technical blog