eddik 发表于 2018-5-12 12:24:18

RedHat5.4 VNC 配置

  RedHat5.4 VNC 配置
  1.查看VNC是否已经安装:
# rpm -q vnc vnc-server
  package vnc is not installed
  vnc-server-4.1.2-14.el5_3.1
  2.把用户名加入到配置文件中:
# 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 &quot;-nolisten tcp&quot; to prevent X connections to your VNC server via TCP.
  # Use &quot;-nohttpd&quot; to prevent web-based VNC clients connecting.
  # Use &quot;-localhost&quot; to prevent remote VNC clients connecting except when
  # doing so through a secure tunnel. See the &quot;-via&quot; option in the
  # `man vncviewer' manual page.
  # VNCSERVERS=&quot;2:myusername&quot;
  # VNCSERVERARGS=&quot;-geometry 800x600 -nolisten tcp -nohttpd -localhost&quot;
  VNCSERVERS=&quot;1:root&quot; #新增部分
  3.防火墙端口设置
  在使用防火墙的情况下来连接到一个远程系统,需要打开端口5901,然后重启iptables服务。
# vi /etc/sysconfig/iptables
  # Firewall configuration written by system-config-securitylevel
  # Manual customization of this file is not recommended.
  *filter
  :INPUT ACCEPT
  :FORWARD ACCEPT
  :OUTPUT ACCEPT
  :RH-Firewall-1-INPUT -
  -A INPUT -j RH-Firewall-1-INPUT
  -A FORWARD -j RH-Firewall-1-INPUT
  -A RH-Firewall-1-INPUT -i lo -j ACCEPT
  -A RH-Firewall-1-INPUT -p icmp --icmp-type any -j ACCEPT
  -A RH-Firewall-1-INPUT -p 50 -j ACCEPT
  -A RH-Firewall-1-INPUT -p 51 -j ACCEPT
  -A RH-Firewall-1-INPUT -p udp --dport 5353 -d 224.0.0.251 -j ACCEPT
  -A RH-Firewall-1-INPUT -p udp -m udp --dport 631 -j ACCEPT
  -A RH-Firewall-1-INPUT -p tcp -m tcp --dport 631 -j ACCEPT
  -A RH-Firewall-1-INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 21 -j ACCEPT
  -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
  -A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 137 -j ACCEPT
  -A RH-Firewall-1-INPUT -m state --state NEW -m udp -p udp --dport 138 -j ACCEPT
  -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 139 -j ACCEPT
  -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 445 -j ACCEPT
  -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 23 -j ACCEPT
  -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
  -A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5901 -j ACCEPT #新增部分
  -A RH-Firewall-1-INPUT -j REJECT --reject-with icmp-host-prohibited
  COMMIT
  4.重启iptables服务
# /sbin/service iptables restart
  清除防火墙规则: [确定]
  把 chains 设置为 ACCEPT 策略:nat filter [确定]
  正在卸载 Iiptables 模块: [确定]
  应用 iptables 防火墙规则: [确定]
  载入额外 iptables 模块:ip_conntrack_netbios_ns ip_conntrac[确定]
  5.启动vncserver,这时候通过VNC Viewer只能看到终端窗口
# vncserver
  You will require a password to access your desktops.
  Password: #123456
  Verify: #123456
  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
  5.设置图形界面登录
# vi /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 &quot;$VNCDESKTOP Desktop&quot; &
  #twm & #注释掉
  gnome-session & #新增
  6.重启vncserver
# service vncserver restart
  关闭 VNC 服务器:1:root [确定]
  启动 VNC 服务器:1:root xauth: creating new authority file /root/.Xauthority
  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
[确定]
#
  7.这时再通过客户端就可以登录图形界面了
页: [1]
查看完整版本: RedHat5.4 VNC 配置