VNC (Virtual Network Console)是虚拟网络控制台的缩写。它 是一款优秀的远程控制工具软件,由著名的 AT&T 的欧洲研究实验室开发的。VNC 是在基于 UNIX 和 Linux 操作系统的免费的开源软件,远程控制能力强大,高效实用,其性能可以和 Windows 和 MAC 中的任何远程控制软件媲美,本篇文章重点为大家讲解一下Centos中安装vncserver具体方法。
img
本实验中安装的系统没有安装桌面环境,我们需要自己安装,如果已经安装桌面了清跳过这一步。Centos7提供了”Cinnamon Desktop”,”MATE Desktop”,”GNOME Desktop”,”KDE Plasma Workspaces”,”LXQt Desktop”,”Xfce”让我们安装。
下面的命令列出可用环境组:
[root@localhost ~]# yum grouplist
Loaded plugins: fastestmirror
There is no installed groups file.
Maybe run: yum groups mark convert (see man yum)
Loading mirror speeds from cached hostfile
* base: mirrors.tuna.tsinghua.edu.cn
* epel: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Available Environment Groups:
Minimal Install
Compute Node
Infrastructure Server
File and Print Server
Cinnamon Desktop
MATE Desktop
Basic Web Server
Virtualization Host
Server with GUI
GNOME Desktop
KDE Plasma Workspaces
Development and Creative Workstation
Available Groups:
Cinnamon
Compatibility Libraries
Console Internet Tools
Development Tools
Educational Software
Electronic Lab
Fedora Packager
General Purpose Desktop
Graphical Administration Tools
Haskell
LXQt Desktop
Legacy UNIX Compatibility
MATE
Milkymist
Scientific Support
Security Tools
Smart Card Support
System Administration Tools
System Management
TurboGears application framework
Xfce
Done
我们可以选择自己喜欢的桌面环境,在这里选择安装Xfce桌面:
[root@localhost ~]# yum -y install epel-release && yum groupinstall Xfce
创建一个用户
[root@localhost ~]# useradd user1
[root@localhost ~]# echo '123456'|passwd --stdin user1
[root@localhost ~]# usermod -a -G wheel user1
在Centos仓库默认提供的是TigerVNC安装包,我们就安装这个:
[root@localhost ~]# yum -y install tigervnc-server tigervnc-server-module
切换到user1用户,运行vncserver命令创建一个初始配置并设置密码:
[root@localhost ~]# su - user1
[user1@localhost ~]$ vncserver :2
You will require a password to access your desktops.
Password:
Verify:
Would you like to enter a view-only password (y/n)? n
A view-only password is not used
New 'localhost.localdomain:2 (user1)' desktop is localhost.localdomain:2
Starting applications specified in /home/user1/.vnc/xstartup
Log file is /home/user1/.vnc/localhost.localdomain:2.log
然后停止vncserver服务,目的就是创建密码和.vnc下面的文件。
[user1@localhost ~]$ vncserver -kill :2
编辑用户家目录下面的.vnc/xstartup文件
[user1@localhost ~]$ vim ~/.vnc/xstartup
#!/bin/sh
xrdb $HOME/.Xresources
#xsetroot -solid grey
#xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
#twm &
startxfce4 &
如果需要修改屏幕分辨率,可以修改~/.vnc/config文件,取消gemoetry前面的注释。
[user1@localhost ~]$ vim .vnc/config
## Supported server options to pass to vncserver upon invocation can be listed
## in this file. See the following manpages for more: vncserver(1) Xvnc(1).
## Several common ones are shown below. Uncomment and modify to your liking.
##
# securitytypes=vncauth,tlsvnc
# desktop=sandbox
geometry=1920x1080
# localhost
# alwaysshared
Unit文件方便快速的启动,停止,重启服务
[user1@localhost ~]$ sudo cp /usr/lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:2.service
编辑vncserver@:2.service,替换文件里面的为user1用户, Type由默认的forking改为simple
[user1@localhost ~]$ vim /etc/systemd/system/vncserver\@\:2.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target
[Service]
Type=simple
ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
ExecStart=/usr/sbin/runuser -l user1 -c "/usr/bin/vncserver %i"
PIDFile=/home/user1/.vnc/%H%i.pid
ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'
[Install]
WantedBy=multi-user.target
启动vncserver服务
#重新加载管理器配置
[user1@localhost ~]$ sudo systemctl daemon-reload
#启动vncserver
[user1@localhost ~]$ sudo systemctl start vncserver@:2
客户端远程连接测试
在windows10客户端打开VNC Viewer,输入地址和会话端口号:
如果需要将VNC服务器配置为多个用户启动显示,请使用vncserver命令创建初始配置并设置密码,然后使用其他端口创建新的服务文件。
网页标题:Centos中安装vncserver具体方法
网址分享:http://www.shufengxianlan.com/qtweb/news18/335568.html
网站建设、网络推广公司-创新互联,是专注品牌与效果的网站制作,网络营销seo公司;服务项目有等
声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联