转载出处:http://blog.sina.com.cn/s/blog_6347780c0102v6ce.html
Centos7与Centos6.x有了很大的不同。
为了给一台服务器装上远程桌面,走了不少弯路。写这篇博文,纯粹为了记录,以后如果遇到相同问题,可以追溯。
1、假定你的系统没有安装vnc的任何软件,那么,首先安装vnc
| yum |
2、Centos7之前的系统,如果安装vnc一般都需要配置
|
[root@localhost
#
|
但是,如上所述,Centos7需要配置的文件在
|
[root@localhost
-rw-r--r--.
|
3、文件内有如下提示
|
#
#
#
#
#
#
|
4、复制一份文件,并改名为vncserver@:1.service
| [root@localhost |
5、将文件中的用你当前的用户替换,将%i替换为1
|
[Unit]
Description=Remote
After=syslog.target
[Service]
Type=forking
#
ExecStartPre=/bin/sh
ExecStart=/sbin/runuser
PIDFile=/root/.vnc/%H%i.pid
ExecStop=/bin/sh
[Install]
WantedBy=multi-user.target
|
6、更新systemctl
| systemctl |
7、设置为自动启动
| systemctl |
8、启动vnc服务
| systemctl |
9、在iptables中加入对应的端口5901(注意,如果有其他用户,那么也需要将端口加上。vnc的端口默认是5900 + n)
|
[root@localhost
#
#
#
*filter
:INPUT
:FORWARD
:OUTPUT
-A
-A
-A
-A
-A
-A
-A
COMMIT
|
注意:
1、如果你不配置和启用防火墙,此时用VNC Viewer连接的话,会报:"connect:Connection timed out(10060)"错误。
2、本文是以root用户为例,如果其他用户也需要登录,那么,还需要将文件复制为
| cp |
同时,将文件内的%i改为2,并建立对应用户的vncpasswd。
3、你可以通过UltraVNC,TigerVNC或者RealVNC Viewer进行访问,我在win7下使用这3中工具均能连接
关闭防火墙和SELinux后,仍然报错,最后通过修改vnc配置文件:type=simple后问题解决
本文出自 “Chase” 博客,请务必保留此出处http://uchase.blog.51cto.com/880483/1545357