1. 程式人生 > >【引】CentOS 7 安裝配置VNC Server

【引】CentOS 7 安裝配置VNC Server

Hi there, this tutorial is all about how to install or setup VNC Server on your very CentOS 7. This tutorial also works fine in RHEL 7.  In this tutorial, we'll learn what is VNC and how to install or setup VNC Server on CentOS 7.

As we know, most of the time as a system administrator we are managing our servers over the network. It is very rare that we will need to have a physical access to any of our managed servers. In most cases all we need is to SSH remotely to do our administration tasks. In this article we will configure a GUI alternative to a remote access to our CentOS 7 server, which is VNC. VNC allows us to open a remote GUI session to our server and thus providing us with a full graphical interface accessible from any remote location.

VNC server is a Free and Open Source Software which is designed for allowing remote access to the Desktop Environment of the server to the VNC Client whereas  VNC viewer is used on remote computer to connect to the server .

Some Benefits of VNC server are listed below:

  • Remote GUI administration makes work easy & convenient.
  • Clipboard sharing between host CentOS server & VNC-client machine.
  • GUI tools can be installed on the host CentOS server to make the administration more powerful
  • Host CentOS server can be administered through any OS having the VNC-client installed.
  • More reliable over ssh graphics and RDP connections.

So, now lets start our journey towards the installation of VNC Server. We need to follow the steps below to setup and to get a working VNC.

First of all we'll need a working Desktop Environment (X-Windows), if we don't have a working GUI Desktop Environment (X Windows) running, we'll need to install it first.

Note: The commands below must be running under root privilege. To switch to root please execute "sudo -s" under a shell or terminal without quotes("")

1. Installing X-Windows

First of all to install X-Windows we'll need to execute the below commands in a shell or terminal. It will take few minutes to install its packages.

# yum check-update
# yum groupinstall "X Window System"

installing x windows

#yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts

# unlink /etc/systemd/system/default.target
# ln -sf /lib/systemd/system/graphical.target /etc/systemd/system/default.target

configuring graphics

# reboot

After our machine restarts, we'll get a working CentOS 7 Desktop.

Now, we'll install VNC Server on our machine.

2. Installing VNC Server Package

Now, we'll install VNC Server package in our CentOS 7 machine. To install VNC Server, we'll need to execute the following command.

# yum install tigervnc-server -y

vnc server

3. Configuring VNC

Then, we'll need to create a configuration file under /etc/systemd/system/ directory. We can copy the [email protected]:1.service file from example file from /lib/systemd/system/[email protected] 

# cp /lib/systemd/system/[email protected] /etc/systemd/system/[email protected]:1.service

copying vnc server configuration

Now we'll open /etc/systemd/system/[email protected]:1.service in our favorite text editor (here, we're gonna use nano). Then find the below lines of text in that file and replace <USER> with your username. Here, in my case its linoxide so I am replacing <USER> with linoxide and finally looks like below.

ExecStart=/sbin/runuser -l <USER> -c "/usr/bin/vncserver %i"
PIDFile=/home/<USER>/.vnc/%H%i.pid

TO

ExecStart=/sbin/runuser -l linoxide -c "/usr/bin/vncserver %i"
PIDFile=/home/linoxide/.vnc/%H%i.pid

If you are creating for root user then
ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/.vnc/%H%i.pid

configuring user

Now, we'll need to reload our systemd.

# systemctl daemon-reload

Finally, we'll create VNC password for the user . To do so, first you'll need to be sure that you have sudo access to the user, here I will login to user "linoxide" then, execute the following. To login to linoxide we'll run "su linoxide" without quotes .

# su linoxide
$ sudo vncpasswd

setting vnc password

Make sure that you enter passwords more than 6 characters.

4. Enabling and Starting the service

To enable service at startup ( Permanent ) execute the commands shown below.

$ sudo systemctl enable [email protected]:1.service

Then, start the service.

$ sudo systemctl start [email protected]:1.service

5. Allowing Firewalls

We'll need to allow VNC services in Firewall now.

$ sudo firewall-cmd --permanent --add-service vnc-server
$ sudo systemctl restart firewalld.service

allowing firewalld

Now you can able to connect VNC server using IP and Port ( Eg : ip-address:1 )

6. Connecting the machine with VNC Client

Finally, we are done installing VNC Server. No, we'll wanna connect the server machine and remotely access it. For that we'll need a VNC Client installed in our computer which will only enable us to remote access the server machine.

remote access vncserver from vncviewer

You can use VNC client like Tightvnc viewer and Realvnc viewer to connect Server.
To connect with additional users create files with different ports, please go to step 3 to configure and add a new user and port, You'll need to create [email protected]:2.service and replace the username in config file and continue the steps by replacing service name for different ports. Please make sure you logged in as that particular user for creating vnc password.

VNC by itself runs on port 5900. Since each user will run their own VNC server, each user will have to connect via a separate port. The addition of a number in the file name tells VNC to run that service as a sub-port of 5900. So in our case, arun's VNC service will run on port 5901 (5900 + 1) and further will run on 5900 + x. Where, x denotes the port specified when creating config file [email protected]:x.service for the further users.

We'll need to know the IP Address and Port of the server to connect with the client. IP addresses are the unique identity number of the machine. Here, my IP address is 96.126.120.92 and port for this user is 1. We can get the public IP address by executing the below command in a shell or terminal of the machine where VNC Server is installed.

# curl -s checkip.dyndns.org|sed -e 's/.*Current IP Address: //' -e 's/<.*$//'

Conclusion

Finally, we installed and configured VNC Server in the machine running CentOS 7 / RHEL 7 (Red Hat Enterprises Linux) . VNC is the most easy FOSS tool for the remote access and also a good alternative to Teamviewer Remote Access. VNC allows a user with VNC client installed to control the machine with VNC Server installed. Here are some commands listed below that are highly useful in VNC . Enjoy !!

Additional Commands :

  •  To stop VNC service .
    # systemctl stop [email protected]:1.service
  •  To disable VNC service from startup.
  • # systemctl disable [email protected]:1.service
  •  To stop firewall.
    # systemctl stop firewalld.service

相關推薦

CentOS 7 安裝配置VNC Server

Hi there, this tutorial is all about how to install or setup VNC Server on your very CentOS 7. This tutorial also works fine in RHEL

Pythonpython2.7 安裝配置OpenCV2

pen 2.4.1 安裝 so文件 strong make lib con ack 環境:Ubuntu16.04 anaconda Python2.7 opencv2.4.13 安裝opencv後 import cv2 遇到錯誤信息: No module named cv2

CentOS 7 安裝配置 VNC 詳解

配置文件 安裝配置 default nom png 配置信息 mina vim 服務啟動 VNC是什麽( Virtual Network Computing)VNC允許Linux系統可以類似實現像Windows中的遠程桌面訪問那樣訪問Linux桌面。本文配置是在CentOS

轉載CentOS 7 安裝 mysql + mysql 常用命令 + docker 執行 mysql

CentOS 7 安裝 mysql 檢測系統是否自帶安裝 mysql rpm -qa | grep mysql 如果你係統有安裝,那可以選擇進行解除安裝 rpm -e mysql  // 普通刪除模式 rpm -e --nodeps mysql 

freeSwitch——centos 7 安裝教程及常見問題

引言   最近公司需要在系統中整合軟電話的功能,之前我們是直接購買的螞蟻電話,在使用了一段時間以後,會有一些問題,比如說穩定性,還有就是一些和我們自己業務相關的需要定製的功能都不能滿足,所以我們需要自己搭建軟電話平臺,在前期調研以後我們選定freeswitch來完成,關於fr

CentOS 7 安裝配置 OpenVPN Server

vpn open 這篇文章描述了如何在CentOS 7 服務器上安裝與配置OpenVPN服務器,以及如何編寫客戶端連接到新建立的OpenVPN服務器上所需的配置文件。目前OpenVPN最新版本為2.4.3(2017年9月)由於OpenVPN Server不在默認源中,所以需要安裝Extra Packa

CentOS 7 安裝配置OpenVPN Server

CentOS 7 安裝配置OpenVPN Server 這篇文章描述瞭如何在CentOS 7 伺服器上安裝與配置OpenVPN伺服器,以及如何編寫客戶端連線到新建立的OpenVPN伺服器上所需的配置檔案。 由於OpenVPN Server不在預設源中,所以需要安裝Extra Pac

Linuxcentos 7 linux系統預設ftp安裝配置和部署(詳細講解)

小生接觸 Linux 系統時間不長,想解決linux系統ftp安裝及部署問題,折騰了大半天,終於弄出來了,將各路 高手的配置方法綜合了一下,如有不對之處,歡迎各位看客指正,感謝! 一、宣告:   本文采用作業系統版本: Centos 7 Linux系統     版本源:C

CentOS 7.0 安裝Redis 3.2.1詳細過程和使用常見問題

nec count ges des useful 內存 warning before outside http://www.linuxidc.com/Linux/2016-09/135071.htm 環境:CentOS 7.0 Redis 3.2.1 Redis的安裝與啟動

前端CentOS 7 系列教程之五: 安裝最新版 nginx 並設置 nginx 代理轉發 node 服務

con config get http ati sha cal 安裝 pre 轉載請註明出處:http://www.cnblogs.com/shamoyuu/p/linux_5.html 進入/usr/local目錄 cd /usr/local 下載最新

LinuxCentOS 7.4 安裝 MySQL 8.0.12 解壓版

style prope error shared false 添加 tab code plain 安裝環境/工具   1、Linux(CentOS 7.4版)   2、mysql-8.0.12-el7-x86_64.tar.gz 安裝步驟   參考:https://dev.

MySQLcentOS安裝配置MySQL

在MySQL的官方網站下載rpm包,地址為https://dev.mysql.com/downloads/repo/yum/ 也可以使用wget來下載 地址可以在網上找   然後輸入rpm -Uvh mysql57-community-release-el7-10.noarch.rpm

LinuxCentOS 7安裝JDK詳細過程

Linux上一般會安裝Open JDK,關於OpenJDK和JDK的區別:http://www.cnblogs.com/sxdcgaq8080/p/7487369.html 下面開始安裝步驟: -----------------------------------

LinuxCentOS 7環境下安裝中文字型庫

JAVA畫圖時常用到Font 類物件 這樣的物件依賴於本地的欄位。新裝的linux沒有安裝欄位庫,和相應的字型。 1、fc-list檢視字型庫 2、yum -y install fontconfig安裝 3、安裝好後/usr/share目錄下多兩個目錄fonts和fo

LinuxCentOS 7最小化安裝後找不到‘ifconfig’命令

“ifconfig”命令用於配置GNU/Linux系統的網路介面。它顯示網路介面卡的詳細資訊,包括IP地址,MAC地址,以及網路介面卡狀態之類。但是,該命令已經過時了,而且在最小化版本的RHEL 7以及它的克隆版本CentOS 7,Oracle Linux 7和Scientific Linux 7中

轉發centos 7開啟FTP以及新增使用者配置許可權,只允許訪問自身目錄,不能跳轉根目錄 linux下ftp配置檔案詳解

1.切換到root使用者 2.檢視是否安裝vsftp,我這個是已經安裝的。 [[email protected] vsftpd]# rpm -qa |grep vsftpd vsftpd-3.0.2-11.el7_2.x86_64 3.如果沒有發現,則安裝。 yum ins

深度學習CentOS 7 安裝GPU版Tensorflow教程(一)

之前一直在玩cpu版的tensorflow,這些天突然心血來潮,想搞個gpu版的tensorflow來嚐嚐鮮,沒想到把所有能夠踩的坑幾乎全部踩了一遍,在這裡把自己踩的坑和一些安裝細節拿出來分享給大家,

CentOS 7 安裝配置分布式文件系統 FastDFS 5.10

fastdfs下載目前作者最後一次releases的時間的17年4月6號,對應的最新版本是5.10,直接在余大的GitHub上下載就可以了: https://github.com/happyfish100/fastdfs/releases如上圖,由於FastDFS是純C語言實現,只支持Linux、FreeBS

Git二、安裝配置

config 查看 projects set col utl font ssl user 一、Git安裝   Linux 1 $ apt-get install libcurl4-gnutls-dev libexpat1-dev gettext 2 libz-dev

CentOS 7 安裝配置 MySQL

provides 小寫 包名 datadir .html ide ini 創建數據庫 fault MySQL是一個關系型數據庫管理系統,由瑞典MySQL AB 公司開發,目前屬於 Oracle 旗下產品。MySQL 是最流行的關系型數據庫管理系統之一,在 WEB 應用方面