
正文
centos 开启VNC
提示:扫一扫查出行【扫一扫了解最新限行尾号】
复制提示
安装软件包(有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 characters - try again
Password:
Verify:
xauth: creating new authority file /root/.Xauthority New 'localhost.localdomain:1 (root)' desktop is localhost.localdomain: Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:.log [root@localhost ~]# vncpasswd
Password:
Password must be at least characters - try again
Password:
Verify:
[root@localhost ~]#
修改配置文件:
vim ~/.vnc/xstartup (最后两行)
#xterm -geometry 80x24++ -ls -title "$VNCDESKTOP Desktop" &
#twm &
gnome-session &
vim /etc/sysconfig/vncservers (最后两行)
# VNCSERVERS="2:myusername"
# VNCSERVERARGS[]="-geometry 800x600 -nolisten tcp -localhost"
VNCSERVERS="1:root"
VNCSERVERARGS[]="-geometry 800x600"
vi /etc/sysconfig/iptables (配置防火墙)
-A INPUT -m state --state NEW -m tcp -p tcp --dport -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport -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: :root
New 'localhost.localdomain:2 (root)' desktop is localhost.localdomain: Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:.log [ OK ]
[root@localhost ~]#
关闭vnc
vncserver -kill :
#注意kill后面要有一个空格
连接







