root根用户登录在/root目录下
#rpm
-q vnc vnc-server查询已安装vnc的客户端和服务器端
vnc-4.1.1-36
vnc-server-4.1.1-36
#vi
/etc/sysconfig/vncservers将developer用户名加入vncservers文件中
如下所示:
#
VNCSERVERS="2:myusername"
VNCSERVERS="2:developer"
创建一个vnc的口令
#vncpasswd
Password:
Verify:
启动vnc服务
#sudo
/sbin/service vncserver
start
Starting VNC server:2:developer
[FAILED]
后来改为用户developer,并在/home/developer目录下创建vnc的口令
[developer@developer
~]$vncpasswd
Password:
Verifty:
$ls
-d .vnc
.vnc
$ls
.vnc
passwd
$/sbin/service
vncserver
start
Starting VNC server:2:developer
runuser:cannot set groups:Operation
not permitted [FAILED]
$sudo /sbin/service
vncserver start
developer is not in the sudorers file.This
incident will be reported.
退出仍用root用户
#sudo
/sbin/service vncserver
start
Starting VNC server:2:developer
xauth:creating new authority file
/home/developer/.Authority
New
‘developer.fw:2(developer)‘desktop is developer.fw:2
Creating
default startup script.
/home/developer/.vnc/xstartup
Starting
applications specified in
/home/developer/.vnc/xstartup
Log file
is /home/developer/.vnc/developer.fw:2.log
[OK]
这次成功了.
#cd
.vnc
(/home/developer/下)
#ls
developer.fw:2.log
developer.fw:2.pid
passwd xstartup
#vi
xstartup
下面两行的注释去掉。
unset
SESSION_MANAGER
exec
/etc/X11/xinit/xinitrc
保存退出
重启vncserver
#sudo
/sbin/service vncserver restart
Shutting
down VNC server:2:developer
[OK]
Starting VNC server:2:developer
New
‘developer.fw:2(developer)‘desktop is developer.fw:2
Starting
application specified in
/home/developer/.vnc/xstartup
Log file
is /home/developer/.vnc/developer.fw:2.log
[OK]
在本机上试连接到vncserver
#vncviewer
localhost:2
成功,打开了一个vnc窗口,输入口令,进入。
客户端的配置
如客户端为windows
,用putty或vnc客户端
客户端为linux:
1.vncviewer
localhost:2 在本机执行
2.用ssh
ssh -L
5901:localhost:5901 -l foo myserver
需在sudo vi
/etc/sysconfig/iptables中打开5901端口,
然后重启iptables
sudo
/sbin/service iptables restart
或者直接用ip地址ssh -L
5901:localhost:5901 -l foo 192.168.x.x