• Linux xhost VNC 配置总结


    1. 安装命令

    [root@bonnie]# yum -y install vnc vnc-server

    2. 配置文件说明

    [root@bonnie]# 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>.

    # 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”

    ———————————————————————————————————————————

    将最后两行配置信息取消注释,添加系统账号

    VNCSERVERS="1:root 2:etl"

    VNCSERVERARGS[1]="-geometry 1024x768 -nolisten tcp -nohttpd "

    VNCSERVERARGS[2]="-geometry 1024x768 -nolisten tcp -nohttpd "

    VNCSERVERS 是用来设定可以使用VNC的服务器账号,可以设定多个,例如上面root、etl,但是中间要用空格隔开。使用VNCVIEWER登录时,192.168.48.128:1表示是以root账号登录,以此类推。

    关于参数配置说明:

    1:-geometry 表示桌面分辨率,默认为1024x768,所以上面的1024x768也可以不写。

    2:-nohttpd  表示不监听HTTP端口(58xx)。

    3:-nolisten tcp 表示不监听TCP端口(60xx)

    4:-localhost 只运行从本机访问。

    5:AlwaysShared 默认只允许一个VNCVIEWER连接,此参数表示同一个显示端口允许多用户同时登录.

    6:-depth  表示色深,参数有8,16,24,32.

    7: SecurityTypes None 登录不需要密码认证VncAuth默认值,要密码认证。

    3. 设置VNC用户密码

    如果此时不设置VNC用户密码,启动vncserver服务,则会报如下错误:

    [root@bonnie ~]# service vncserver start

    Starting VNC server: 1:root [FAILED]

    [root@bonnie /]# vncpasswd

    Password:

    Verify:

    [root@bonnie /]# su - etl

    [etl@bonnie ~]$ vncpasswd

    Password:

    Verify:

    [etl@bonnie ~]$

    4. 启动vncserver服务

    [root@bonnie ~]# service vncserver start

    Starting VNC server: 1:root

    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

    2:etl

    New 'localhost.localdomain:2 (etl)' desktop is localhost.localdomain:2

    Creating default startup script /home/etl/.vnc/xstartup

    Starting applications specified in /home/etl/.vnc/xstartup

    Log file is /home/etl/.vnc/localhost.localdomain:2.log

    [  OK  ]

    VNC会在用户根目录($HOME)下的”.vnc"文件夹下生成一系列文件。其中passwd为vnc用户密码文件,由vncpasswd生成。其他的都由vnc初次启动时生成,xstartup为VNC客户端连接时启动的脚本

    5. 配置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 &

    切换到etl账号,依法炮制

    [root@bonnie ~]# su - etl

    [etl@bonnie ~]$ vi /home/etl/.vnc/xstartup

    [root@bonnie ~]# service vncserver restart

    Shutting down VNC server: 1:root 2:etl [  OK  ]

    Starting VNC server: 1:root

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

    Starting applications specified in /root/.vnc/xstartup

    Log file is /root/.vnc/localhost.localdomain:1.log

    2:etl

    New 'localhost.localdomain:2 (etl)' desktop is localhost.localdomain:2

    Starting applications specified in /home/etl/.vnc/xstartup

    Log file is /home/etl/.vnc/localhost.localdomain:2.log

    [  OK  ]

    chkconfig vncserver on

  • 相关阅读:
    java之正则表达式
    mysql之自定义函数
    mysql之replace into与 insert into duplicat key for update
    mysql之命令行导入导出
    Echarts修改legend样式
    ubuntu出现 E: Sub-process /usr/bin/dpkg returned an error code
    ubuntu总是提是E: 不能满足依赖关系。不妨试一下 -f 选项
    ubuntu安装和查看已安装软件
    放爬虫nginx
    nginx日志切割
  • 原文地址:https://www.cnblogs.com/bonnienote/p/6472919.html
Copyright © 2020-2023  润新知