Linux 配置VNCServer

本文指导如何在Linux上设置VNCServer,包括检查VNCServer安装状态、配置开机自启动、设置用户及密码、定义桌面环境以及调整防火墙规则。通过这些步骤,你将能够实现远程桌面连接。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  • 查看是否安装了VNCServer
rpm -qa | grep vnc

如果没有安装vnc,执行

yum install -y tigervnc-server
  • 配置开机自启动
chkconfig --level 345 vncserver on
  • 配置VNC用户

    在root用用户下执行,vi /etc/sysconfig/vncserver
    内容如下
    # 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 this URL:
    # https://access.redhat.com/knowledge/solutions/7027


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

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


在文件末尾添加
VNCSERVERS=”1:root”
VNCSERVERARGS[1]=”-geometry 1366x768”
如果需要多个用户,在VNCSERVERS后面,用空格进行分割。如
VNCSERVERS=”1:root 2:oracle”,相应的,需要添加VNCSERVERARGS[2]=”-geometry 1366x768” 1366x768值得是vnc屏幕的分辨率


  • 添加VNC用户的密码。如果配置了root的vnc登陆,在root用户下,执行

    vncserver
    输入vnc的密码,vnc用户的密码,这里指的是vnc用户登录的密码,如果配置了多个vnc用户,那么需要分别在对应的用户下面,执行vncserver命令,指定vnc用户的密码.

  • 配置VNC用户登录的桌面环境

    执行完vncserver以后,需要配置vnc用户登陆的桌面环境,vi /root/.vnc/xstartup 在文件末尾,添加 gnome-session & ,指定登陆桌面环境为gnome

  • 配置防火墙

    执行iptables -I INPUT -p tcp --dport 5901 -j ACCEPT,如果配置了多个用户,那么分别执行iptables -I INPUT -p tcp --dport 5902 -j ACCEPT,5901,5902 分别对应1:root,2:oracle…….。 保存防火墙service iptables save


  • 启动vncserver
service vncserver restar
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值