Centos7安装VNC的配置

tigervnc-server的配置

查看系统中是否有安装过vnc

rpm -qa | grep vnc

安装tigervnc-server

yum -y install tigervnc-server

查看安装包信息

[root@kvmserver images]# rpm -qi tigervnc-server   #查看
Name        : tigervnc-server
Version     : 1.8.0
Release     : 19.el7
Architecture: x86_64
Install Date: 2020年09月22日 星期二 17时04分15秒
Group       : User Interface/X
Size        : 521902
License     : GPLv2+
Signature   : RSA/SHA256, 2020年04月04日 星期六 05时09分34秒, Key ID 24c6a8a7f4a80eb5
Source RPM  : tigervnc-1.8.0-19.el7.src.rpm
Build Date  : 2020年04月01日 星期三 12时46分28秒
Build Host  : x86-01.bsys.centos.org
Relocations : (not relocatable)
Packager    : CentOS BuildSystem <http://bugs.centos.org>
Vendor      : CentOS
URL         : http://www.tigervnc.com
Summary     : A TigerVNC server
Description :
The VNC system allows you to access the same desktop from a wide
variety of platforms.  This package includes set of utilities
which make usage of TigerVNC server more user friendly. It also
contains x0vncserver program which can export your active
X session.

查看安装文件

[root@kvmserver images]# rpm -ql tigervnc-server   #查看安装文件
/etc/sysconfig/vncservers
/usr/bin/vncserver
/usr/bin/vncserver_wrapper
/usr/bin/x0vncserver
/usr/lib/systemd/system/vncserver@.service
/usr/lib/systemd/system/xvnc.socket
/usr/lib/systemd/system/xvnc@.service
/usr/share/man/man1/vncserver.1.gz
/usr/share/man/man1/x0vncserver.1.gz

查看配置文件

[root@kvmserver images]# rpm -qc tigervnc-server     
/etc/sysconfig/vncservers

[root@kvmserver images]# cat /etc/sysconfig/vncservers
# THIS FILE HAS BEEN REPLACED BY /lib/systemd/system/vncserver@.service   #配置文件其实在这

首次设置密码

[root@kvmserver images]# vncserver

You will require a password to access your desktops.

Password:
Verify:
Would you like to enter a view-only password (y/n)? n  问你是不是只读模式,回答n
A view-only password is not used

New 'kvmserver:1 (root)' desktop is kvmserver:1

Creating default startup script /root/.vnc/xstartup
Creating default config /root/.vnc/config
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/kvmserver:1.log

查看进程

[root@kvmserver images]# vncserver -list
TigerVNC server sessions:
X DISPLAY #	PROCESS ID     #进程号
:1		33007

[root@kvmserver images]# ps aux | grep 33007
root      33007  0.4  1.1 196880 43732 pts/0    S    17:15   0:04 /usr/bin/Xvnc :1 -auth /root/.Xauthority -desktop kvmserver:1 (root) -fp catalogue:/etc/X11/fontpath.d -geometry 1024x768 -pn -rfbauth /root/.vnc/passwd -rfbport 5901 -rfbwait 30000
root      34139  0.0  0.0 112828   980 pts/0    R+   17:31   0:00 grep --color=auto 33007

查询端口

[root@kvmserver images]# netstat -anp | grep vnc
tcp        0      0 0.0.0.0:5901            0.0.0.0:*               LISTEN      33007/Xvnc          
tcp        0      0 0.0.0.0:6001            0.0.0.0:*               LISTEN      33007/Xvnc          
tcp        0      0 192.168.1.11:5901       192.168.0.98:14756      ESTABLISHED 33007/Xvnc          
tcp6       0      0 :::5901                 :::*                    LISTEN      33007/Xvnc          
tcp6       0      0 :::6001                 :::*                    LISTEN      33007/Xvnc 

结束进程

建议每次用完结束调进程

kill 33007

设置分辨率

[root@kvmserver images]# vncserver -geometry 1920x1080

New 'kvmserver:2 (root)' desktop is kvmserver:2

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/kvmserver:2.log

防火墙的配置

在这里插入图片描述

临时快速配置

[root@localhost ~]# yum install tigervnc-server -y    #安装
[root@localhost ~]# vncserver    #启动并设置密码

You will require a password to access your desktops.

Password:123456
Verify:123456
Would you like to enter a view-only password (y/n)? n    
xauth:  file /root/.Xauthority does not exist

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

Creating default startup script /root/.vnc/xstartup
Creating default config /root/.vnc/config
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.localdomain:1.log

[root@localhost ~]# vncserver :1 -geometry 1920x1080   #启动当前用户1号窗口,并设置分辨率
A VNC server is already running as :1
  • 0
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
您可以按照以下步骤在 CentOS 7 上安装 VNC: 1. 使用 root 用户登录到 CentOS 7。 2. 确保系统已更新到最新版本,可以运行以下命令来更新软件包: ``` yum update ``` 3. 安装 VNC Server 和图形化界面,可以使用以下命令进行安装: ``` yum groupinstall "GNOME Desktop" "Graphical Administration Tools" ``` 4. 安装 TigerVNC Server 软件包,可以使用以下命令进行安装: ``` yum install tigervnc-server ``` 5. 配置 VNC Server,您需要为每个用户设置一个 VNC 密码。以 root 用户为例,运行以下命令设置密码: ``` vncpasswd ``` 6. 创建并编辑 VNC Server 的配置文件(以 root 用户为例): ``` vi /etc/systemd/system/vncserver@:1.service ``` 在文件中添加以下内容: ``` [Unit] Description=Remote desktop service (VNC) After=syslog.target network.target [Service] Type=forking ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' ExecStart=/sbin/runuser -l root -c "/usr/bin/vncserver %i" PIDFile=/root/.vnc/%H%i.pid ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :' [Install] WantedBy=multi-user.target ``` 7. 保存并退出编辑器。 8. 启动 VNC Server 服务,并将其设置为开机启动: ``` systemctl enable vncserver@:1.service systemctl start vncserver@:1.service ``` 9. 配置防火墙以允许 VNC 连接,运行以下命令: ``` firewall-cmd --permanent --zone=public --add-service=vnc-server firewall-cmd --reload ``` 10. 现在您可以使用 VNC 客户端连接到 CentOS 7 的 VNC 服务器,使用 IP 地址和端口号 `5901`。 请注意,这只是一种基本的安装配置方法,您可能需要根据您的需求进行进一步的定制。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

亦良Cool

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值