Linux学习脚印
2013-09-29 17:25
387 查看
The following simple guide help you to setup the VNC server on RHEL 7/CentOS 7 machines, VNC help to share the desktop with the other machines which has a client installed. VNC server and client are not installed by default, you need to setup the vnc server manually.Before installing the VNC server, let us install Gnome desktop.
Install the tigervnc server and X11 fonts.
Copy the VNC server configuration file to /etc/systemd/system/ for configuring the system service. While copying, you can mention which port it should listen. By default VNC server listens on 5900, but if you setup port-offset for VNC; we can run a service on a sub-port of the default port 5900. For example, if we mention port 5, it will be accessible on 5905. You can connect the VNC server by specifying ipaddress:sub-port (192.168.2.109:5 or 192.168.2.109:5905)
Edit the copied file.
At the end of file, you will find the lines like below.[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’
ExecStart=/sbin/runuser -l <USER> -c “/usr/bin/vncserver %i”
PIDFile=/home/<USER>/.vnc/%H%i.pid
ExecStop=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'[Install]
WantedBy=multi-user.targetReplace <USER> with your real user, in my case i replaced with user called “raj” with the screen size.[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’
ExecStart=/sbin/runuser -l raj -c “/usr/bin/vncserver %i -geometry 1280×1024″
PIDFile=/home/raj/.vnc/%H%i.pid
ExecStop=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'[Install]
WantedBy=multi-user.targetAdd firewall rules to allow the VNC connection, the following rule is set as per the port-offset mentioned in the previous step.
Start VNC server after switching to raj.
Set the password.You will require a password to access your desktops.Password:
Verify:
xauth: file /home/raj/.Xauthority does not existNew ‘localhost.localdomain:1 (raj)’ desktop is server.itzgeek.com:1Creating default startup script /home/raj/.vnc/xstartup
Starting applications specified in /home/raj/.vnc/xstartup
Log file is /home/raj/.vnc/server.itzgeek.com:1.logReload the systemctl daemon as root
Start the VNC service as root.
Enable it on system startup as root.
Take remote desktop.ipaddress:5905 or ipaddress:5
![](http://www.itzgeek.com/wp-content/uploads/2014/07/CentOS-7-VNC-connection.jpg)
CentOS 7 – VNC Connection
You will be asked to enter the password, enter the password that you have created earlier.
![](http://www.itzgeek.com/wp-content/uploads/2014/07/CentOS-7-VNC-Authendication.jpg)
CentOS 7 – VNC Authendication
Now you will get the vnc desktop session.
![](http://www.itzgeek.com/wp-content/uploads/2014/07/CentOS-7-VNC-Desktop.jpg)
CentOS 7 – VNC Desktop
本文出自 “Permanent” 博客,请务必保留此出处http://ericklee.blog.51cto.com/6941516/1625798
[root@server ~]# yum groupinstall "GNOME Desktop" |
[root@server ~]# yum install tigervnc-server xorg-x11-fonts-Type1 |
[root@server ~]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:5.service |
[root@server ~]# vi /etc/systemd/system/vncserver@:5.service |
Description=Remote desktop service (VNC)
After=syslog.target network.target[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’
ExecStart=/sbin/runuser -l <USER> -c “/usr/bin/vncserver %i”
PIDFile=/home/<USER>/.vnc/%H%i.pid
ExecStop=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'[Install]
WantedBy=multi-user.targetReplace <USER> with your real user, in my case i replaced with user called “raj” with the screen size.[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target[Service]
Type=forking
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :’
ExecStart=/sbin/runuser -l raj -c “/usr/bin/vncserver %i -geometry 1280×1024″
PIDFile=/home/raj/.vnc/%H%i.pid
ExecStop=/bin/sh -c ‘/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'[Install]
WantedBy=multi-user.targetAdd firewall rules to allow the VNC connection, the following rule is set as per the port-offset mentioned in the previous step.
[root@server ~]# firewall-cmd --permanent --zone=public --add-port=5905/tcp [root@server ~]# firewall-cmd --reload |
[raj@server ~]$ vncserver |
Verify:
xauth: file /home/raj/.Xauthority does not existNew ‘localhost.localdomain:1 (raj)’ desktop is server.itzgeek.com:1Creating default startup script /home/raj/.vnc/xstartup
Starting applications specified in /home/raj/.vnc/xstartup
Log file is /home/raj/.vnc/server.itzgeek.com:1.logReload the systemctl daemon as root
systemctl daemon-reload |
systemctl start vncserver@:5.service |
systemctl enable vncserver@:5.service |
![](http://www.itzgeek.com/wp-content/uploads/2014/07/CentOS-7-VNC-connection.jpg)
CentOS 7 – VNC Connection
You will be asked to enter the password, enter the password that you have created earlier.
![](http://www.itzgeek.com/wp-content/uploads/2014/07/CentOS-7-VNC-Authendication.jpg)
CentOS 7 – VNC Authendication
Now you will get the vnc desktop session.
![](http://www.itzgeek.com/wp-content/uploads/2014/07/CentOS-7-VNC-Desktop.jpg)
CentOS 7 – VNC Desktop
本文出自 “Permanent” 博客,请务必保留此出处http://ericklee.blog.51cto.com/6941516/1625798
相关文章推荐
- LINUX学习脚印(一)
- linux基础学习之for语句
- 总结四条对学习Linux系统有帮助的方法
- Linux入门学习教程:虚拟机体验之VirtualBox篇
- ARM&LINUX学习笔记(1)
- linux驱动学习-4th
- linux 学习日记一——ubuntu14.04安装
- Linux学习资料-命令重导向
- Linux和bootstrap的学习总结
- 嵌入式Linux驱动学习之路(十六)输入子系统
- linux git学习记录
- 检查 Linux 文件系统中的错误:通过案例学习 FSCK 命令
- Linux LVM学习
- linux命令学习使用记录
- Linux学习--线程控制
- (笔记)学习Linux第一天
- python圣经学习。linux echo的实现方式3
- 嵌入式linux c 学习笔记3-date
- LINUX下USB1.1设备学习小记(1)
- Linux下的I2S驱动学习