CentOS graphical interface and VNC/Xmanager remote access

Article source: Tao Teacher operation notes – wechat official account

In some special work scenarios, such as Oracle operations, it is sometimes more convenient to use a graphical interface to operate Linux than a command line. Both VNC and Xmanager can be remotely connected to Linux and perform graphical operations. Today, I will share how to install a GRAPHICAL interface in Linux and configure the VNC/Xmanager remote desktop.

1. Experimental environment

Install a GRAPHICAL interface on the Linux server and remotely access the Linux server from a Mac/Windows client.

IP The machine The operating system version
192.10.1.8 Linux server CentOS 6.6
192.10.1.2 The client Mac / windows

2. Server

2.1 Configuring domestic YUM /EPEL sources

When installing software, the network speed of foreign YUM source is usually not as fast as that of domestic source. In order to speed up the installation speed, you can use domestic YUM Ali cloud source. [EPEL] (Extra Packages for Enterprise Linux) has been developed by the Fedora community to provide easy installation updates for nginx, HTOP, NCDU, vnstat, etc.

EPEL website: fedoraproject.org/wiki/EPEL/z…

Configure Aliyunyuan:

wget -O /etc/yum.repos.d/CentOS-6-aliyun.repo http://mirrors.aliyun.com/repo/Centos-6.repo
wget -O /etc/yum.repos.d/epel-aliyun.repo http://mirrors.aliyun.com/repo/epel-6.repo
yum clean all
yum makecache
Copy the code

2.2 Checking available Components

Check whether components such as the Desktop can be installed.

Check the installed and uninstalled components of the system
yum grouplist | more   
Installed Groups:
   Additional Development
   Base
...
Available Groups:
   Client management tools
   Debugging Tools
   Desktop
Copy the code

2.3 Installing GRAPHICAL User Interface Software

Install GUI Desktop,X Window System, etc.

Linux is often used to build servers, so basically choose Basic Server, but you can also choose the following:

  • Desktop: a basic Desktop system, including common Desktop software, such as document viewing tools.
  • Minimal Desktop: Minimal Desktop system with less software.
  • Minimal: Basic system, doesn’t contain any optional packages.
  • Basic Server: Platform support for the base system installed, excluding desktops.
  • Database Server: a basic system platform, including MySQL and PostgreSQL databases, without a desktop.
  • Web Server: Basic system platform, plus PHP, Web Server, MySQL and PostgreSQL database client, no desktop.
  • Virtual Host: basic system plus Virtual platform.
  • Software Development Workstation includes many Software packages, including basic systems, virtualization platforms, desktop environments, and Development tools.
yum groupinstall "Desktop"  
yum groupinstall 'X Window System'  
yum groupinstall "Chinese Support"  -y 
yum install xorg-x11-xdm  -y 
Copy the code

Note: If there is no Internet, you can find a machine that can connect to the Internet to put the RPM software package down and transfer it to the machine that is not connected to the Internet to complete the installation. (Help with yum-plugin-downloadonly software). See the problem Handling section of this article for details.

Change the startup level :(optional) if you want to start the server in a graphical user interface (GUI), change the /etc/inittab operating level to 5.

Linux system startup process: www.jianshu.com/p/33437df8c… The Linux operating system has seven running levels: 0: the system is stopped. The default running level cannot be set to 0. Otherwise, the system cannot start normally. 5: X11 console. Enter graphical GUI mode after logging in. 6: The system shuts down and restarts normally

# Change the boot level
$cp /etc/inittab  /etc/inittab.backup # under the backup
$sed -i 's/id:3/id:5/' /etc/inittab
$cat /etc/inittab  
id:5:initdefault:
Copy the code

2.4 Starting the GUI

Enter startx to launch the graphical interface.

startx &
#virt-manager &
Copy the code

3. Log in to the remote desktop using VNC or Xmanager

Xmanager and VNC can both call remote desktops. We only need to install one of these.

Differences between VNC and Xmanager: Both VNC and Xmanager can be remotely connected to UNIX or Linux for graphical operations, but they do not work the same way.

  • VNC remotely connects to the OPERATING system (OS). All operations are performed on the UNIX or Linux host server. Even if the network is disconnected, the operation is not affected.
  • Xmanager guides the UI of the host server to the local PC through the port. If the network is disconnected during the operation, the operation fails. VNC clipboard content cannot cross local and remote (like VMware without VMtools installed), whereas Xmanager can (like VMware with VMtools installed). VNC is only a few hundred K in size, and Xmanager is tens of megabytes in size. VNC under the GPL license, there are several VNC software derivatives: RealVNC: Developed by some members of the VNC team, including a full commercial version and a free version. TightVNC: TightVNC emphasizes bandwidth saving. UltraVNC: The UltraVNC component of TightVNC and performance-enhancing map-mapping drivers, combined with Active Directory and NTLM account and password authentication, are available only in Windows. Vine Viewer: VNC client for MacOSX.

3.1 Logging In to the Remote Desktop Using VNC

VNC consists of two parts: VNCServer and VNCViewer. Vncserver is the server software that provides VNC services, and VNCViewer is the client software that remotely invokes VNC services. That is, vNCViewer can remotely log in to the host where vNCServer resides.

3.1.1 Installing and Configuring the VNCServer

Install and configure VNCServe on the CentOS server. 1) Install the VNCServer software

# Install software
yum install tigervnc  tigervnc-server -y
Configure to boot automatically upon startupChkconfig - level 345 vNCServer onCopy the code

2) Setting the vNCServer password the first time you execute it will ask you to enter the password, at least 6 characters, example password is vncadmin. It will be used in the vNCViewer connection to the server host. Note: You can run the vncpasswd command to change the password later.

$vncserver
You will require a password to access your desktops.
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/DB-132038:1.log
Copy the code

3) Configure the gnOME desktop to use the GNOME desktop, modify the /root/.vn/xstartup file, delete the last TWM & and add the gnOMe-session &

vim /root/.vnc/xstartup
#twm &
gnome-session &
Copy the code

4) Allow root to access the GRAPHICAL user interface (GUI) Allow root to access the GUI and generate a new machine-ID (optional).

Auth required pam_succeed_if.so user! = root quiet
cp /etc/pam.d/gdm /etc/pam.d/gdm.backup
sed -i 's/.*! = root.*/#&/' /etc/pam.d/gdm
cat  /etc/pam.d/gdm 
 #auth required pam_succeed_if.so user ! = root quiet
#dbus-uuidgen >/var/lib/dbus/machine-id
Copy the code

5) launch vncserver service to modify the configuration file: modify the configuration file, / etc/sysconfig/vncservers.

VNCSERVERS="1:root"
# indicates that when the service is started, a VNC service will be configured under the root user and the corresponding port is 1.
vim /etc/sysconfig/vncservers 
VNCSERVERS="1:root"
VNCSERVERS="2:leuser"
Copy the code

Activation:

/etc/init.d/vncserver start
Copy the code

Set the boot automatically:

#chkconfig --add vncserver
$chkconfig --list |grep vnc -i
vncserver       0:off   1:off   2:off   3:off   4:off   5:off   6:off
Configure automatic startup upon startup
$chkconfig --level 345 vncserver on
$chkconfig --list |grep vnc -i    
vncserver       0:off   1:off   2:off   3:on    4:on    5:on    6:off
Copy the code

6) Check the VNC service

$ps aux|grep vnc -i
$netstat- ntlup | grep VNC TCP 0 0 0.0.0.0:0.0.0.0:5902 * 22738 / Xvnc TCP 0 0 0.0.0.0: LISTEN 0.0.0.0:6002 * 22738 / Xvnc LISTENCopy the code

3.1.2 vncviewer login

After installing and configuring vNCServer on the server, we can use vNCViewer to log in to the server.

Install vncviewer

  • Vncviewer software download: www.realvnc.com/en/connect/…

To log in to the remote Server, enter IP address: serial number of vncServers (1:root,2:leuser), enter the VNC password (vncadmin) set in the previous section, and click OK. Note: The value of Username is grey and cannot be specified. In this example, IP:2 is used to log in to user leuser. If IP:1 is used to log in to user root.

# CentOS VNCServer configuration
vim /etc/sysconfig/vncservers 
VNCSERVERS="1:root"
VNCSERVERS="2:leuser"
Copy the code

Effect after successful login:

3.2 Logging In to the Remote Desktop Using Xmanager

  • Software download: www.netsarang.com/zh/all-down…

3.2.1 Server Configuration

1) the configuration Xmanager

cp  /etc/gdm/custom.conf   /etc/gdm/custom.conf.backup
vim /etc/gdm/custom.conf
[daemon]  
  
[security]  
AllowRoot=true  
AllowRemoteRoot=true  Allow root to log in
  
[xdmcp]  
Enable=true  
Port=177  
  
[greeter]  
 
[chooser]  
  
[debug]  
Copy the code

2) modify XDM – config: modify the XDM – config, in front of the shadow “DisplayManager. QuestPort: 0” with an exclamation point.

cp /etc/X11/xdm/xdm-config  /etc/X11/xdm/xdm-config.backup
cat /etc/X11/xdm/xdm-config
! DisplayManager.requestPort:   0
Copy the code

Xaccess vim /etc/x11/xdm.xaccess #any host can get a login window Uncomment the beginning of this line find the line “#any indirect host can get a Chooser” and uncomment the beginning of this line.

$vim /etc/X11/xdm/Xaccess 
*                                       #any host can get a login window
*               CHOOSER BROADCAST       #any indirect host can get a chooser
$cat /etc/X11/xdm/Xaccess  |grep -v '^ #'|grep -v '^ $'
Copy the code

4) Modify prefdm.conf modify the /etc/init/prefdm.conf file. Add exec /etc/x11/prefdm -nodaemon and add exec /usr/sbin/gdm

vim /etc/init/prefdm.conf
respawn limit10, 120#exec /etc/X11/prefdm -nodaemon
exec /usr/sbin/gdm
Copy the code

5) Close the firewall:

$iptables -L
#service iptables stop
$iptables  -A  INPUT  -p udp -s 0/0 -d 0/0 --dport 177 -j ACCEPT
Copy the code

6) Restart the Linux server. Restart the Linux server and run reboot Now.

reboot now
Copy the code

7) Check XDMCP service: Since XDMCP service uses UDP177 port by default, check whether XDMCP service has been started.

lsof -i:177
netstat    -antpu   |   grep 177
Copy the code

3.2.2 Configuring the Xbrowser Client

Install Xbrowser client software:

  • Software download: www.netsarang.com/zh/all-down…

Remote Login: Open Xmanager and click Xbrowser. (It is recommended to turn off the firewall on the local computer before remotely logging in using Xmanager.)

  • Method 1: Call in Xshell and set session properties. As shown in the following figure, select “Forward X11 to connect to (X):” on the “Tunnel” option.

  • Method 2: Use Xstart to log in to the remote desktop. Enter the host, username and authentication are required, the protocol must be SSH, the key is to fill in the command (see the table below), after filling in, you can click “Run”.

The following three commands are used to log in to the remote desktop: 1> gnOMe-session call gnOME desktop 2> startkde call KDE desktop 3> /usr/bin/xterm-ls-display $display Call terminal window The third one is actually the following, which is essentially a terminal window. If /usr/bin/xterm: DISPLAY is not set is displayed, you can set xhost + or export DISPLAY=192.168.2.1:0.0 on the terminal. 192.168.2.1 indicates the client address.

In a real production environment, it is often not necessary to log on to a remote desktop and simply call the application, for example, to install Oracle and run the./runInstaller.

4. Configure X11 forwarding for Xshell and SecureCRT

Reference: [Putty, Xshell, SecureCRT] local X11 forwarding images displayed blog.csdn.net/u010472607/…

4.1 SecureCRT Configures X11 to forward images

  • STEP 1: Select Session Options.
  • STEP 2: Select Remote/X11 and select Forward X11

4.2 Xshell configures X11 to forward images

Select the attributes of the corresponding session, select [Tunnel], and select the following option on the right. The X DISPLAY does not need to be modified.

5. Problem solving

5.1 Installing desktop software on Machines Without Internet Access

The machine does not have the Internet, you can find a machine that can connect to the Internet to put the RPM software package down and transfer it to the machine that is not connected to the Internet to complete the installation. (Help with yum-plugin-downloadonly software). Download software:

$yum install yum-plugin-downloadonly
$mkdir /root/rpm
Download all the required RPM packages
yum --downloadonly --downloaddir=/root/rpm groupinstall  "Desktop" -y
yum --downloadonly --downloaddir=/root/rpm groupinstall  "X Window System" -y
yum --downloadonly --downloaddir=/root/rpm groupinstall  "Chinese Support" -y
yum --downloadonly --downloaddir=/root/rpm  install xorg-x11-xdm  -y
Copy the code

Transfer software: use NC to transfer software between two servers. Tao teacher operation notes – NC transfer files

# Do not connect to extranet machine A
nc -l 1234 | tar xzvf - >rpm
Machine B has downloaded RPM softwareThe tar CZVF - RPM | target nc machine 1234 ACopy the code

Complete installation:

Go to /root/rpm to download the software
cd rpm RPM package directory (Desktop, etc.)
yum install  *.rpm
Copy the code

Reference:

  • Mirrors.163.com/.help/cento…
  • www.netsarang.com/zh/all-down…
  • Login using Xmanager and VNC remote desktop www.cnblogs.com/ivictor/p/4…
  • VNC viewer MAC mac.orsoon.com/Mac/153107….
  • Xshell, SecureCRT blog.csdn.net/u010472607/ X11 forwarding images…