码迷,mamicode.com
首页 > 其他好文 > 详细

centos 开启VNC

时间:2016-04-02 12:02:04      阅读:267      评论:0      收藏:0      [点我收藏+]

标签:

安装软件包(有yum源安装的,不采用源码安装)

yum -y install vnc vnc-server

安装成功后,配置如下:

[root@localhost ~]# vncserver 
#设置 VNC密码,输入:(在某用户下输入则登陆用户就是它,如果su imiss切换到imiss用户,输入vncserver则启动的是另一个桌面,同样要设置密码,以后在该账户下启动的vncserver登陆就需要在此用户下设置的密码了。)
You will require a password to access your desktops.

Password:
Password must be at least 6 characters - try again
Password:
Verify:
xauth:  creating new authority file /root/.Xauthority

New localhost.localdomain:1 (root) desktop is localhost.localdomain:1

Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log

[root@localhost ~]# vncpasswd 
Password:
Password must be at least 6 characters - try again
Password:
Verify:
[root@localhost ~]# 

修改配置文件:

vim ~/.vnc/xstartup (最后两行)

#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
gnome-session &

vim  /etc/sysconfig/vncservers  (最后两行)

# VNCSERVERS="2:myusername"
# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"
 VNCSERVERS="1:root"
 VNCSERVERARGS[1]="-geometry 800x600"

vi /etc/sysconfig/iptables (配置防火墙)

-A INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5902 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 5903 -j ACCEPT
#VNC server 监听的端口从 5900 开始,display:1 的监听 5901,display:2 监听 5902,以此类推。CentOS 的防火墙缺省是不允许连接这些端口的,所以需要使用下面的步骤打开防火墙(需要 root 权限):

 

[root@localhost ~]# service iptables restart
iptables: Setting chains to policy ACCEPT: nat mangle filte[  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]
iptables: Applying firewall rules:                         [  OK  ]

启动服务

[root@localhost ~]# chkconfig vncserver on
[root@localhost ~]# service vncserver start
Starting VNC server: 2:root 
New localhost.localdomain:2 (root) desktop is localhost.localdomain:2

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:2.log

                                                           [  OK  ]
[root@localhost ~]#

关闭vnc

vncserver -kill :2
#注意kill后面要有一个空格

连接

技术分享

 

centos 开启VNC

标签:

原文地址:http://www.cnblogs.com/kamil/p/5347057.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!