Linux 开启VNC远程管理服务的图形界面操作(解决灰(2)

[root@PC-223-CE ~]# vi /etc/sysconfig/vncservers
# The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the lines below to start a VNC server on display :2
# as my 'myusername' (adjust this to your own).  You will also
# need to set a VNC password; run 'man vncpasswd' to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted!  For a secure way of using VNC, see
# <URL:>.

# VNCSERVERS="2:myusername"
# VNCSERVERARGS[2]="-geometry 800x600"
VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 800x600 -alwaysshared -depth 24"
~

[root@PC-223-CE ~]# vi /root/.vnc/xstartup
#!/bin/sh

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
xrdb $HOME/.Xresources
# [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
# [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
# vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
# twm &
gnome-session &
~

更改完后保存,重新启动VNC即可

3.多个用户登录

linux的VNC可以实现多个用户同时链接.方法如下

su 用户名

vncserver        (这里就是第二个用户了)

第三个用户是

su 用户名

vncserver

添加完后需要在/etc/sysconfig/vncserver里面添加这个用户,不然就会出现登录后都是灰色的

另外还需要 修改用户目录下的.vnc/xstartup文件

例:我的电脑上已经有一个root用户,此时我还需要ocmSUSEr这个用户可以VNC登录

[root@linuxidc~]# su ocmsuser
[ocmsuser@linuxidcroot]$ vncserver

You will require a password to access your desktops.

Password:
Verify:

New 'ywei:2 (ocmsuser)' desktop is ywei:2

Creating default startup script /home/ocmsuser/.vnc/xstartup
Starting applications specified in /home/ocmsuser/.vnc/xstartup
Log file is /home/ocmsuser/.vnc/ywei:2.log

[ocmsuser@linuxidcroot]$ su - root
Password:

[root@linuxidc~]# vi /etc/sysconfig/vncservers

The VNCSERVERS variable is a list of display:user pairs.
#
# Uncomment the lines below to start a VNC server on display :2
# as my 'myusername' (adjust this to your own).  You will also
# need to set a VNC password; run 'man vncpasswd' to see how
# to do that.
#
# DO NOT RUN THIS SERVICE if your local area network is
# untrusted!  For a secure way of using VNC, see
# <URL:>.

# Use "-nolisten tcp" to prevent X connections to your VNC server via TCP.

# Use "-nohttpd" to prevent web-based VNC clients connecting.

# Use "-localhost" to prevent remote VNC clients connecting except when
# doing so through a secure tunnel.  See the "-via" option in the
# `man vncviewer' manual page.

VNCSERVERS="1:root"
VNCSERVERARGS[1]="-geometry 1280x800 -alwaysshared -depth 24"
VNCSERVERS="2:ocmsuser"
VNCSERVERARGS[2]="-geometry 1280x800 -alwaysshared -depth 24"
~

[root@linuxidc~]# cat /root/.vnc/xstartup
#!/bin/sh

# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &
[root@linuxidc~]# cat /home/ocmsuser/.vnc/xstartup
#!/bin/sh

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
twm &
[root@linuxidc~]# cp /home/ocmsuser/.vnc/xstartup /home/ocmsuser/.vnc/xstartup.bak
[root@linuxidc~]# cp /root/.vnc/xstartup /home/ocmsuser/.vnc/xstartup
cp: overwrite `/home/ocmsuser/.vnc/xstartup'? yes
[root@linuxidc~]# service vncserver restart
Shutting down VNC server: 2:ocmsuser [  OK  ]
Starting VNC server: 2:ocmsuser
New 'ywei:2 (ocmsuser)' desktop is ywei:2

Starting applications specified in /home/ocmsuser/.vnc/xstartup
Log file is /home/ocmsuser/.vnc/ywei:2.log

[  OK  ]
[root@linuxidc~]#

CentOS 6.5 安装VNC Server实现图形化访问 

VNC的安装配置

CentOS 6.3安装和配置VNC

Linux下强制不检测依赖安装VNC

CentOS6 VNC服务安装配置

CentOS下VNC配置和安装 

VNC远程控制安装和设置

Windows通过VNC访问Ubuntu 

Windows远程桌面访问Ubuntu 12.04 之安装VNC

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/58c3af366233eb3c04a4f2331c1c609c.html