zoukankan      html  css  js  c++  java
  • 安装vncserver, vncviewer--远程桌面

     
    1 问题如下
    /etc/sysconfig/vncservers---配置文件作用去掉最后两行的注释
    no route to host
    是防火墙的原因---必须得研究好防火墙
    本地可以vnc,本地可以访问zhanglinux.org:1158/em
    我一直以为是没有路由导致的
    route   add   default   gw   192.168.0.254
    经过一系列的测试发现是防火墙的问题。以后在研究网络问题时,首先要注意防火墙的设置。先取消防火墙的设置,在没有防火墙的基础上,实现连通。之后再设置防火墙。防火墙对于网络的安全控制,以及网络访问上都至关重要。这是个基础性的问题。从今天的实践可以看出,基础的把握能力不够。
    2 软件下载
    windows vnc---http://download.pchome.net/php/tdownload2.php?sid=2603&url=/internet/server/remote/vnc-3.3.7-x86_win32.zip&svr=1&typ=0
    linux vnc--http://mirror.etf.bg.ac.yu/fedora/development/i386/Fedora/RPMS/vnc-4.1.1-34.i386.rpm
    ps: http://rpmfind.net 找需要的包。由于学校的proxy服务器设置老出问题,本来用yum install -y 通用包名--非常方便,不得不用老土的rpm -Uvh , rpm -q 这两条命令都非常重要了。
     
    3 安装: rpm -Uvh *rpm
    注意依赖~~~
    4 在X桌面下设置服务器允许连接,同时可以设置连接密码。
    http://www.linuxsir.org/bbs/showthread.php?t=262457
    上面的问题,我这里是由于firewall导致的---可在X桌面设置防火墙
     
    --------------------具体使用方法------------
    启vncserver: vncserver即可,第一次会提示你输入密码;
    关闭:
    vncserver -kill :桌面号
    或者使用系统自带脚本:
    补充VNCServer的命令行启动、关闭方法:
    1)服务器端启动:
    #vncserver
    $vncserver
    注意到每个用户都可以启动自己的vncserver,每个用户可以启动多个vncserver,用显示端口号:1,:2,:3等等来标识。
    2) 客户端:
    a)在linux下,运行vncviewer命令即可,服务器地址的写法形如192.168.3.119:1
    b)在windows下,运行windows版本的vncviewer即可,用法与linux下相近。
    c)用浏览器(平台无关),作为java applet来实现,以形如http://192.168.3.119:5801的方式来启动
    3) 密码修改:
    第一次启动vncserver会提示输入密码,以后要修改的话,运行:
    #vncpassword
    4) 停止vnc server:
    #vncserver -kill :1
    #vncserver -kill :2
    注意到vncserver只能由启动它的用户来关闭,即时是root也不能关闭其它用户开启的vncserver,除非用kill命令暴力杀死进程。
    5) 指定显示端口号启动VNC server:
    #vncserver :3
    $vncserver :6
    6) 设置VNC server分辨率:
    #vncserver -geometry 800x600
    #vncserver -geometry 640x480
    7) 设置vncserver的色深:
    8位为256色,16位为64k色
    #vncserver -depth 8
    #vncserver -depth 16
    稳定性设置:
    vncserver默认在多个客户机连接同一个vncserver的显示端口时,vncserver端口旧连接,而为新连接服务,可通过-dontdisconnect拒绝新连接请求而保持旧的连接。
    9) 设置vncserver的同一个显示端口可以连接多个客户机
    #vncserver -alwaysshared
     
    10) 默认远程登陆启动的是kde桌面(如果安装系统时安装了的话),如果修改登陆的图形界面?当在oracle用户下面启用vncserver的时候,在oracle用户的家目录下会自动创建一个.vnc的文件夹,在该文件夹下面有一个文件,是xstartup,编辑这个文件,将所有的行都注释掉,然后在最后加一行:
    gnome-session &
    保存文件,重启vncserver,就会发现登陆的图形界面已经变成了你想要的样式了。
    比如:
    服务端
    [root@zhanglinux .vnc]# vncserver :3
     
    You will require a password to access your desktops.
     
    Password:
    Password must be at least 6 characters - try again
    Password:
    Password must be at least 6 characters - try again
    Password:
    Verify:
    New 'zhanglinux.org:3 (root)' desktop is zhanglinux.org:3
     
    Creating default startup script /root/.vnc/xstartup
    Starting applications specified in /root/.vnc/xstartup
    Log file is /root/.vnc/zhanglinux.org:3.log
     
    客户端
    登录时:vncviewer ip:3
    登录之后,查看默认端口5900 对应进程名vnc-serv
    [root@zhanglinux .vnc]# netstat -na | grep 5900
    tcp        0      0 202.116.130.243:5900        202.116.130.241:1729        ESTABLISHED
    退出vncviewer
    [root@zhanglinux .vnc]# netstat -na | grep 5900
    tcp        0      0 0.0.0.0:5900                0.0.0.0:*                   LISTEN
     
    ----------------------------------------------------------------------------
    终于解决了vnc启动时加入服务的问题 [http://bbs.chinaunix.net/viewthread.php?tid=149091]
    我就没做了,个人觉得没多大必要,需要才启动。
    vi /etc/rc.d/init.d/vncserver 服务启动相关设置
    ----------------------------------------------------------------------------
     
    VNC Server配置实例
    1) 配置允许访问的用户
    [root@RHCE ~]# 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:[url]http://www.uk.research.att.com/archive/vnc/sshvnc.html[/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="2:myusername" 
    # VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost"
    # 自己定义部分:运行用户jchen远程访问,分辨率为800*600
    VNCSERVERS="2:jchen" 
    VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd"
    # 自己定义部分:运行用户jackie远程访问,分辨率为1024*768
    VNCSERVERS="3:jackie" 
    VNCSERVERARGS[3]="-geometry 1024x768"
    2) 配置用户VNC访问密码
    [root@RHCE ~]# su - jackie 
    [jackie@RHCE ~]$ mkdir .vnc 
    [jackie@RHCE ~]$ cd .vnc 
    [jackie@RHCE .vnc]$ vncpasswd 
    Password: xxxxxx 
    Verify: xxxxxx
    3) 启动VNC服务
    [root@RHCE ~]# service vncserver start
    4) 配置VNC访问方式
    [root@RHCE ~]# vi /home/jackie/.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 &
    5) 配置iptables允许访问5902端口
    [root@RHCE ~]# iptables -I RH-Firewall-1-INPUT -p tcp --dport 5903 -j ACCEPT 
    [root@RHCE ~]# iptables -I RH-Firewall-1-INPUT -p udp --dport 5903 -j ACCEPT
    6) Windows下测试成功
    image
     
     
     
    服务器端配置如下:
     
    1)第一次启动vncserver
    会提示输入密码:
    管理员帐户:
     
    [root@localhost /]# vncserver
    You will require a password to access your desktops.
    Password:     输入vnc 连接密码
    Verify:       确认vnc密码
    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 /]#su huilin 
    [huilin@localhost /]$ vncserver
    You will require a password to access your desktops.
    Password:      输入vnc 连接密码
    Verify:        确认vnc密码
    xauth:  creating new authority file /home/huilin/.Xauthority
    New 'localhost.localdomain:2 (huilin)' desktop is localhost.localdomain:2
    Creating default startup script /home/huilin/.vnc/xstartup
    Starting applications specified in /home/huilin/.vnc/xstartup
    Log file is /home/huilin/.vnc/localhost.localdomain:2.log
    * 注意到每个用户都可以启动自己的 vncserver,每个用户可以启动多个 vncserver,
      
    用ip加端口号 ip:1,ip:2,ip:3 来标识。vncserver的大部分配置文件及日志文件都在用户home目录下.vnc目录下
    用户可以自定义启动号码如:
    [huilin@localhost /]$ vncserver :2
    A VNC server is already running as :2
    2)配置vnc的配置文件xstartup文件
     
    如果用的是gnome 桌面环境还需要修改
    [root@localhost .vnc]# vi 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" &
    gnome-session gnome
    添加连接时使用 gnome 桌面环境
    twm &
     
    3)在vncserver设置登录用户的信息
    [root@localhost: ~]#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:http://www.uk.research.att.com/archive/vnc/sshvnc.html&gt;.
     
    # 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 2:demo"
    此处添加用户
     
    VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -nohttpd -localhost" 
    #vncserver -geometry 800x600
    设置vncserver的分辨率
    #vncserver -geometry 640x480
    设置vncserver的分辨率
    #vncserver -depth 8
    设置vncserver的色深
    #vncserver -depth 16
    设置vncserver的色深
    4)客户端的连接
    a、在linux下,运行vncviewer命令即可,服务器地址的写法形如192.168.3.119:1
    b、在windows下,运行windows版本的vncviewer即可,用法与linux下相近。
    c、用浏览器(平台无关),作为java applet来实现,以形如http://192.168.3.119:5801的方式来启动
    (vnc 端口从5800 开始依次类推,一般会是5800,5900)
    5)修改密码
    运行vncpasswd即可
    6)停止vncserver
    #vncserver -kill :1
    #vncserver -kill :2
    注意到vncserver只能由启动它的用户来关闭,即时是root也不能关闭其它用户开启的vncserver,
    除非用kill命令暴力杀死进程。
    7)稳定性设置
    vncserver默认在多个客户机连接同一个vncserver的显示端口时,vncserver端口旧连接,而为新连接服务,可通过-dontdisconnect拒绝新连接请求而保持旧的连接。
    8)同一个显示器可以连接多个客户
  • 相关阅读:
    Mysql数据库再度使用
    搭建wamp php环境
    phpMyAdmin
    windows激活全系列
    web常见之音乐播放器
    web常见效果之轮播图
    ASP.NET Web Pages
    Eclipse配置中文(汉化)
    以有涯随无涯
    How to get the edited text from itext in fabricjs
  • 原文地址:https://www.cnblogs.com/lvdongjie/p/9798279.html
Copyright © 2011-2022 走看看