
VNC 服务是以用户启动,并配置一个新的密码,然后远端使用 VNC 协议访问。
一、在Linux上安装vncserver
# rpm -qa|grep vnc
# yum -y install tigervnc-server
二、启用vncserver
# vncserver
You will require a password to access your desktops
Password: 这里输入密码
Verify: 这里输入密码
New 'shihuan:1 (root)' desktop is shihuan:1
Creating default startup script /root/vnc/xstartup
Starting applications specified in /root/vnc/xstartup
Log file is /root/vnc/ohs12:1log
# netstat -an|grep 5901
tcp 0 0 0000:5901 0000: LISTEN
# service iptables stop
# chkconfig iptables off
三、重新启动vncserver的方法
# vncserver -kill :1
# vncserver
四、在VNCViewer中连接vncserver
五、重置 VNC 密码
输入一下命令
cd /root/vnc/
rm -rf passwd
输入 vncserver
重新设置密码
1 开启root用户
首先给root用户设置一个密码:
$ sudo passwd root1
2 使用root用户登陆
$ sudo vi /usr/share/lightdm/lightdmconfd/50-ubuntuconf1
在最后增加greeter-show-manual-login=true
保存退出。注销后可看到登陆框已显示,可输入用户名。
使用 VNC 登录云服务器时,输入正确的密码无法登录,会卡在如下图所示界面,稍后会再次提示需要输入账号。
且使用 SSH 远程登录时,会出现报错信息 “Permission denied,please try again”。如下图所示:
可能原因
可能是由于频繁暴力破解导致 /var/log/btmp 日志容量过大。该文件用于记录错误登录的日志,容量过大会导致登录时写入日志异常,造成无法正常登录。如下图所示:
解决思路
参考 处理步骤 查看日志文件 /var/log/btmp 容量是否过大。
核实是否为暴力破解导致,并加固安全策略。
处理步骤
尝试使用 SSH 登录云服务器,详情请参见 使用 SSH 登录 Linux 实例。
登录成功,则执行下一步。
登录失败,则需使用单用户模式,详情请参见 通过控制台进入 Linux 实例单用户模式。
进入 /var/log 查看日志文件 /var/log/btmp 容量。
若日志文件 /var/log/btmp 容量过大,则执行以下命令,对 btmp 日志内容进行清空。清空日志文件后,即可恢复登录。
cat /dev/null > /var/log/btmp
核实帐户锁定是由人为误 *** 作还是暴力破解引起。若是由暴力破解引起,建议选择以下方案加固安全策略:
修改云服务器密码,密码设置为由大写、小写、特殊字符、数字组成的12 - 16位的复杂随机密码。详情请参见 重置实例密码。
删除云服务器中已不再使用的用户。
将 sshd 的默认22端口改为1024 - 65525间的其他非常用端口。详情请参见 修改云服务器远程默认端口。
管理云服务器已关联安全组中的规则,只需放通业务和协议所需端口,不建议放通所有协议及端口。详情请参见 添加安全组规则。
不建议向公网开放核心应用服务端口访问。例如,mysql 及 redis 等。您可将相关端口修改为本地访问或禁止外网访问。
安装云镜、云锁等防护软件,并添加实时告警,以便及时获取异常登录信息。
怎样在 CentOS 70 上安装和配置 VNC 伺服器
1 安装 X-Window 首先我们需要安装 X-Window,在终端中执行下面的命令,安装会花费一点时间。 # yum check-update# yum groupinstall "X Window System" #yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-ce
1 安装 X-Window
首先我们需要安装 X-Window,在终端中执行下面的命令,安装会花费一点时间。
# yum check-update# yum groupinstall "X Window System"
#yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts
### 设定预设启动图形介面# unlink /etc/systemd/system/defaulttarget# ln -sf /lib/systemd/system/graphicaltarget /etc/systemd/system/defaulttarget
# reboot
在伺服器重启之后,我们就有了一个工作著的 CentOS 7 桌面环境了。
现在,我们要在伺服器上安装 VNC 伺服器了。
2 安装 VNC 伺服器
现在要在我们的 CentOS 7 上安装 VNC 伺服器了。我们需要执行下面的命令。
# yum install tigervnc-server -y
3 配置 VNC
然后,我们需要在 /etc/systemd/system/ 目录里建立一个配置档案。我们可以将 /lib/systemd/sytem/vncserver@service 拷贝一份配置档案范例过来。
# cp /lib/systemd/system/vncserver@service /etc/systemd/system/vncserver@:1service
接着我们用自己最喜欢的编辑器(这儿我们用的 nano )开启 /etc/systemd/system/vncserver@:1service ,找到下面这几行,用自己的使用者名称替换掉 。举例来说,我的使用者名称是 linoxide 所以我用 linoxide 来替换掉 :
ExecStart=/ in/runuser -l <USER> -c "/usr/bin/vncserver %i"PIDFile=/home/<USER>/vnc/%H%ipid
替换成
ExecStart=/ in/runuser -l linoxide -c "/usr/bin/vncserver %i"PIDFile=/home/linoxide/vnc/%H%ipid
如果是 root 使用者则
ExecStart=/ in/runuser -l root -c "/usr/bin/vncserver %i"PIDFile=/root/vnc/%H%ipid
好了,下面重启 systemd 。
# systemctl daemon-reload
最后还要设定一下使用者的 VNC 密码。要设定某个使用者的密码,必须要有能通过 sudo 切换到使用者的许可权,这里我用 linoxide 的许可权,执行“su linoxide”就可以了。
1检查VNC客户端和伺服器端是否已经安装
执行如下命令:
[root@localhost ~]# rpm -qa vnc vnc-server
package vnc is not installed
package vnc-server is not installed
表示系统没有安装VNC服务端,那我们就用yum安装VNC服务端。
[root@localhost ~]# yum -y install vnc vnc-server
Loaded plugins: fastestmirror, refresh-packagekit
Loading mirror speeds from cached hostfile
base: mirrors163
extras: mirrors163
updates: mirrors163
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package tigervnci686 0:1090-01020100115svn3945el6 set to be updated
---> Package tigervnc-serveri686 0:1090-01020100115svn3945el6 set to be updated
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================================================
Installing:
tigervnc i686 1090-01020100115svn3945el6 base 252 k
tigervnc-server i686 1090-01020100115svn3945el6 base 11 M
Transaction Summary
=================================================================================================================================================================================
Install 2 Package(s)
Upgrade 0 Package(s)
Total download size: 13 M
Installed size: 36 M
Downloading Packages:
(1/2): tigervnc-1090-01020100115svn3945el6i686rpm | 252 kB 00:00
(2/2): tigervnc-server-1090-01020100115svn3945el6i686rpm | 11 MB 00:00
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 137 kB/s | 13 MB 00:09
Running rpm_check_debug
Running Transaction Test
Transaction Test Sueeded
Running Transaction
Installing : tigervnc-1090-01020100115svn3945el6i686 1/2
Installing : tigervnc-server-1090-01020100115svn3945el6i686 2/2
Installed:
tigervnci686 0:1090-01020100115svn3945el6 tigervnc-serveri686 0:1090-01020100115svn3945el6
Complete!
启动VNC Server服务:使用vncserver命令(在当前使用者主目录下生成vnc资料夹)
[root@localhost ~]# vncserver
You will require a password to aess your desks
Password:
Verify:
xauth: creating new authority file /root/Xauthority
New 'localhostlocaldomain:1 (root)' desk is localhostlocaldomain:1
Creating default startup script /root/vnc/xstartup
Starting applications specified in /root/vnc/xstartup
Log file is /root/vnc/localhostlocaldomain:1log
2 在CentOS系统中将使用者名称加入到配置档案中
编辑vncservers的配置档案
[root@localhost ~]# vi /etc/sysconfig/vncservers
# The VNCSERVERS variable is a list of display:user pairs
#
# Unment 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 neork is
# untrusted! For a secure way of using VNC, see this URL:
# :kbaseredhat/faq/docs/DOC-7028
# 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"
VNCSERVERS="2:root" #使用者名称root
# VNCSERVERARGS[2]="-geometry 800x600 -nolisten tcp -localhost"
VNCSERVERARGS[2]="-geometry 1024x768" #尺寸大小
3设定 root使用者的密码
使用如下命令设定密码:
[root@localhost ~]# vncpasswd
Password:abc123
Verify:abc123
当提示Verify时,再次输入密码确认。
4启动VNC服务
使用如下命令启动VNC SERVER
[root@localhost ~]# / in/service vncserver start
正在启动 VNC 伺服器:2:root
New 'localhostlocaldomain:2 (root)' desk is localhostlocaldomain:2
Starting applications specified in /root/vnc/xstartup
Log file is /root/vnc/localhostlocaldomain:2log
[确定]
[root@localhost ~]#
当显示如下资讯时,表示启动成功
5修改VNC SERVER的视窗治理器
vnc server预设使用的视窗治理器是n,这是一个非常简单的视窗治理器,我们可以改成常用的GNOME或者KDE。
先使用如下命令进入使用者的home目录:cd /vnc
编辑启动项:vi xstartup
按照如下方式修改启动项:
[root@localhost ~]# vi /root/vnc/xstartup
#!/bin/sh
vnonfig -iconic &
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
OS=`uname -s`
if [ $OS = 'Linux' ]; then
case "$WINDOWMANAGER" in
gnome)
if [ -e /etc/SuSE-release ]; then
PATH=$PATH:/opt/gnome/bin
export PATH
fi
;;
esac
fi
if [ -x /etc/X11/xinit/xinitrc ]; then
exec /etc/X11/xinit/xinitrc
fi
if [ -f /etc/X11/xinit/xinitrc ]; then
exec sh /etc/X11/xinit/xinitrc
fi
[ -r $HOME/Xresources ] && xrdb $HOME/Xresources
xsetroot -solid grey
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desk" &
gnome-session & #以GNOME作为VNC的视窗治理器
#startkde #kde desk
#m &
#m # 注掉CentOS系统预设的视窗治理器
6重启VNC SERVER
当CentOS系统提示如下资讯时,表示重启成功
[root@localhost ~]# / in/service vncserver restart
关闭 VNC 伺服器:2:root [确定]
正在启动 VNC 伺服器:2:root
New 'localhostlocaldomain:2 (root)' desk is localhostlocaldomain:2
Starting applications specified in /root/vnc/xstartup
Log file is /root/vnc/localhostlocaldomain:2log
[确定]
检视VNC SERVER 监听的埠:
[root@localhost ~]# stat -antulp |grep 59
tcp 0 0 0000:5901 0000: LISTEN 3162/Xvnc
tcp 0 0 0000:5902 0000: LISTEN 4193/Xvnc
tcp 0 0 0000:59473 0000: LISTEN 1153/rpcstatd
tcp 0 0 :::5989 ::: LISTEN 1501/cimserver
tcp 0 0 :::5900 ::: LISTEN 3123/vino-server
tcp 0 0 ::ffff:1921680124:5900 ::ffff:1921680145:3072 ESTABLISHED 3123/vino-server
防火墙开放的埠:
[root@localhost ~]# / in/iptables -A INPUT -p tcp -m multiport
一些 VNC 伺服器的优点:
远端的图形管理方式让工作变得简单方便。
剪贴簿可以在 CentOS 伺服器主机和 VNC 客户端机器之间共享。
CentOS 伺服器上也可以安装图形工具,让管理能力变得更强大。
只要安装了 VNC 客户端,通过任何作业系统都可以管理 CentOS 伺服器了。
比 ssh 图形转发和 RDP 连线更可靠。
那么,让我们开始安装 VNC 伺服器之旅吧。我们需要按照下面的步骤一步一步来搭建一个可用的 VNC。
首先,我们需要一个可用的桌面环境(X-Window),如果没有的话要先安装一个。
注意:以下命令必须以 root 许可权执行。要切换到 root ,请在终端下执行“sudo -s”,当然不包括双引号(“”)
1 安装 X-Window
首先我们需要安装 X-Window,在终端中执行下面的命令,安装会花费一点时间。
# yum check-update
# yum groupinstall "X Window System"
#yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts
### 设定预设启动图形介面
# unlink /etc/systemd/system/defaulttarget
# ln -sf /lib/systemd/system/graphicaltarget /etc/systemd/system/defaulttarget
# reboot
在伺服器重启之后,我们就有了一个工作著的 CentOS 7 桌面环境了。
现在,我们要在伺服器上安装 VNC 伺服器了。
2 安装 VNC 伺服器
现在要在我们的 CentOS 7 上安装 VNC 伺服器了。我们需要执行下面的命令。
# yum install tigervnc-server -y
首先,我们需要一个可用的桌面环境(X-Window),如果没有的话要先安装一个。
注意:以下命令必须以 root 许可权执行。要切换到 root ,请在终端下执行“sudo -s”,当然不包括双引号(“”)
1 安装 X-Window
首先我们需要安装 X-Window,在终端中执行下面的命令,安装会花费一点时间。
# yum check-update
# yum groupinstall "X Window System"
#yum install gnome-classic-session gnome-terminal nautilus-open-terminal control-center liberation-mono-fonts
### 设定预设启动图形介面
# unlink /etc/systemd/system/defaulttarget
# ln -sf /lib/systemd/system/graphicaltarget /etc/systemd/system/defaulttarget
# reboot
在伺服器重启之后,我们就有了一个工作著的 CentOS 7 桌面环境了。
现在,我们要在伺服器上安装 VNC 伺服器了。
2 安装 VNC 伺服器
现在要在我们的 CentOS 7 上安装 VNC 伺服器了。我们需要执行下面的命令。
# yum install tigervnc-server -y
3 配置 VNC
然后,我们需要在 /etc/systemd/system/ 目录里建立一个配置档案。我们可以将 /lib/systemd/sytem/vncserver@service 拷贝一份配置档案范例过来。
# cp /lib/systemd/system/vncserver@service /etc/systemd/system/vncserver@:1service
接着我们用自己最喜欢的编辑器(这儿我们用的 nano )开启 /etc/systemd/system/vncserver@:1service ,找到下面这几行,用自己的使用者名称替换掉 。举例来说,我的使用者名称是 linoxide 所以我用 linoxide 来替换掉 :
ExecStart=/ in/runuser -l <USER>-c "/usr/bin/vncserver %i"
PIDFile=/home/<USER>/vnc/%H%ipid
替换成
ExecStart=/ in/runuser -l linoxide -c "/usr/bin/vncserver %i"
PIDFile=/home/linoxide/vnc/%H%ipid
如果是 root 使用者则
ExecStart=/ in/runuser -l root -c "/usr/bin/vncserver %i"
PIDFile=/root/vnc/%H%ipid
好了,下面重启 systemd 。
# systemctl daemon-reload
最后还要设定一下使用者的 VNC 密码。要设定某个使用者的密码,必须要有能通过 sudo 切换到使用者的许可权,这里我用 linoxide 的许可权,执行“su linoxide”就可以了。
# su linoxide
$ sudo vncpasswd
确保你输入的密码多于6个字元
4 开启服务
用下面的命令(永久地)开启服务:
$ sudo systemctl enable vncserver@:1service
启动服务。
$ sudo systemctl start vncserver@:1service
5 防火墙设定
我们需要配置防火墙来让 VNC 服务正常工作。
$ sudo firewall-cmd --permanent --add-service vnc-server
$ sudo systemctl restart firewalldservice
现在就可以用 IP 和埠号(LCTT 译注:例如 19216811:1 ,这里的埠不是伺服器的埠,而是视 VNC 连线数的多少从1开始排序)来连线 VNC 伺服器了。
6 用 VNC 客户端连线伺服器
好了,现在已经完成了 VNC 伺服器的安装了。要使用 VNC 连线伺服器,我们还需要一个在本地计算机上安装的仅供连线远端计算机使用的 VNC 客户端。
你可以用像 Tightvnc viewer 和 Realvnc viewer 的客户端来连线到伺服器。
要用更多的使用者连线,需要建立配置档案和埠,请回到第3步,新增一个新的使用者和埠。你需要建立 vncserver@:2service 并替换配置档案里的使用者名称和之后步骤里相应的档名、埠号。请确保你登入 VNC 伺服器用的是你之前配置 VNC 密码的时候使用的那个使用者名称。
VNC 服务本身使用的是5900埠。鉴于有不同的使用者使用 VNC ,每个人的连线都会获得不同的埠。配置档名里面的数字告诉 VNC 伺服器把服务执行在5900的子埠上。在我们这个例子里,第一个 VNC 服务会执行在5901(5900 + 1)埠上,之后的依次增加,执行在5900 + x 号埠上。其中 x 是指之后使用者的配置档名 vncserver@:xservice 里面的 x 。
在建立连线之前,我们需要知道伺服器的 IP 地址和埠。IP 地址是一台计算机在网路中的独特的识别号码。我的伺服器的 IP 地址是9612612092,VNC 使用者埠是1。
执行下面的命令可以获得伺服器的公网 IP 地址(LCTT 译注:如果你的伺服器放在内网或使用动态地址的话,可以这样获得其公网 IP 地址)。
# curl -s checkipdyndns|sed -e 's/Current IP Address: ' -e 's/<$'
1安装 yum install vnc vncserver 2 vim /etc/sysconfig/vncservers 使用vim编辑器开启配置档案,在档案中新增下面两行命令 VNCSERVERS="2:root" --指定远端使用者 2:桌面号,root:使用者 VNCSERVERARGS[2]="-geometry 1024x768" --指定远端桌面解析度 3给你刚刚设定的远端桌面使用者 root 设定密码 vncpasswd 4配置防火墙 vi /etc/sysconfig/iptables 使用vi编辑器开启配置档案,在档案中新增下面一行命令 -A RH-Firewall-l-INPUT -p tcp -m tcp --dport 5900:5903 -j ACCEPT vncserver在呼叫的时候,会根据你的配置来启用server端的监听埠, 埠预设是从5900开始,再加上你的桌面号。 比如你的桌面号为2,则vnc的连线埠号为5900+2=5902 比如你的桌面号为10000,则vnc的连线埠号为5900+10000=15900 重启防火墙 5 修改指令码档案 xstartup,如果找不到此档案,执行service vncserver restart 就可以自动生成 cd ~/vnc/ vi xstartup 使用vi编辑器开启配置档案,并进行下列修改 #xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desk" & --将它注释,加#代表注释 #m & --将它注释 gnome-session & --新增它 6重启伺服器: service vncserver restart 远端登入: vncviewer ip:桌面号 ip和桌面号缺一不可,否则会报:unable connect to socket:(111)错误 / 不是必须的 / 7远端桌面和本地桌面同步 点选系统-》首选项-》远端桌面-》勾选允许其他人检视和控制您的桌面
yum check-update
yum -y install lvm2 device-mapper
yum -y groupinstall GNOME 桌面
yum -y install tigervnc-server tigervnc
reboot
yum check-update
yum -y groupinstall GNOME 桌面
yum -y install tigervnc-server tigervnc
reboot
其他配置问题了
vncserver是使用非常方便和广泛的远程桌面服务,配置也相对简单。
下面记录了在centos系统上进行配置vncserver的过程。
安装
查看centos下是否已经安装了vncserver
rpm -qa |grep vnc
如果未安装vncserver,则进行安装
yum install vnc vncserver
vncserver配置
vnc桌面的启动方式有两种,一种是通过在 /etc/sysconfig/vncservers文件中配置启动,这种方式配置的vnc桌面在服务器启动的时候就被启动,可以直接远程连接;另一种是在机器运行的时候运行vncserver
:桌面号 命令来启动,这种方式启动的vnc桌面在机器重启后失效。
1 使用文件来进行配置
这种方式只能在root用户下执行。
/etc/sysconfig/vncservers的配置:
1
2
3
4
5
# VNCSERVERS="2:myusername"
# VNCSERVERARGS[2]="-geometry 800x600-nolisten tcp -localhost"
VNCSERVERS="1:root 2:jason"
VNCSERVERARGS[1]="-geometry 1600x1000-nolisten tcp -localhost"
VNCSERVERARGS[2]="-geometry 1600x1000-nolisten tcp -localhost"
其中指定了 桌面号:用户名,以及相应的配置信息。
2 使用vncserver命令来配置
这种方式可以在所有用户下进行,每个用户都可以开启多个vnc远程桌面,一个用户的所有vnc桌面都使用相同的密码,但是所有用户的桌面号必须唯一。
1
2
3
4
5
6
7
8
9
usage: vncserver [:] [-name] [-depth ]
[-geometry x]
[-pixelformat rgbNNN|bgrNNN]
[-fp ]
[-fg]
[-autokill]
vncserver -kill
vncserver -list
可以通过vncserver命令新建桌面
vncserver :number 桌面号, -name 桌面名(显示在vncviewer上), -depth 色深, -geometry 桌面大小。
或者删除一个远程桌面
vncserver -kill :桌面号
vnc桌面配置
每个用户的~/vnc目录下都有一个 xstartup配置文件,来配置vnc使用的是 gnome桌面还是kde桌面,还有其他的一些信息。
如果你是gnome桌面,那么你需要修改/root/vnc/xstartup的配置文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh
[ -r /etc/sysconfig/i18n ] && /etc/sysconfig/i18n
export LANG
export SYSFONT
vncconfig -iconic &
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
OS=`uname -s`
if [ $OS = 'Linux' ]; then
case "$WINDOWMANAGER" in
gnome)
if [ -e /etc/SuSE-release ]; then
PATH=$PATH:/opt/gnome/bin
export PATH
fi
;;
esac
fi
if [ -x /etc/X11/xinit/xinitrc ]; then
exec /etc/X11/xinit/xinitrc
fi
if [ -f /etc/X11/xinit/xinitrc ]; then
exec sh /etc/X11/xinit/xinitrc
fi
[ -r $HOME/Xresources ] && xrdb$HOME/Xresources
xsetroot -solid grey
xterm -geometry 80x24+10+10 -ls -title"$VNCDESKTOP Desktop" &
gnome-session gnome #添加这一句是连接时使用gnome 桌面环境
twm &
vncserver的服务端运行
vncserver运行:
service vncserver start
在运行的时候,每个用户都可以通过vncserer命令开多个vnc远程桌面(通过全局的桌面号来进行区分),且一个用户的所有vnc桌面的密码都相同(通过vncpasswd设置)。
每当用户新开一个vnc桌面时,在用户的 ~/vnc 目录下就会有一个对应的 服务器机器名:桌面号pid 的进程文件和服务器机器名:桌面号log 的日志文件。
vnc客户端的连接
a、在linux下,运行vncviewer命令即可,服务器地址的写法形如192168111:1
b、在windows下,运行windows版本的vncviewer即可,用法与linux下相近。
在centos7 下安装配置vncserver
一安装
以root用户运行以下命令来安装vncserver;
yum install tigervnc-server
同样运行以下命令来安装vncviewer;
yum install vnc
停止并禁用防火墙
systemctl stop firewalldservice
systemctl disable firewalldservice
二配置
vncviewer基本上不用配置;
vncserver的配置,创建一个新的配置文件,以开启1号窗口为例(也可以同时开启多个窗口,修改数字即可),方法如下:
cp /lib/systemd/system/vncserver@service/etc/systemd/system/vncserver@:1service
或者再增加一个窗口:
cp /lib/systemd/system/vncserver@service/etc/systemd/system/vncserver@:2service
编辑/lib/systemd/system/vncserver@:1service,设置用户root相关参数,最终内容如下:
[Unit]
Description=Remote desktop service (VNC)
After=syslogtarget networktarget
[Service]
Type=forking
# Clean any existing files in/tmp/X11-unix environment
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%ipid
ExecStop=/bin/sh -c '/usr/bin/vncserver-kill %i > /dev/null 2>&1 || :'
上述内容中最好设置为root用户,否则可能会看到以下报错:
vncserver@:1service - Remote desktopservice (VNC)
Loaded: loaded (/usr/lib/systemd/system/vncserver@:1service; enabled)
Active: failed (Result: exit-code) since Tue 2015-04-14 10:09:24 CST;1min 36s ago
Process: 3258 ExecStart=/sbin/runuser -l sysadmin -c /usr/bin/vncserver%i (code=exited, status=1/FAILURE)
Process: 3254 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i >/dev/null 2>&1 || : (code=exited, status=0/SUCCESS)
Apr 14 10:09:24 F1A-VMHOST-SWPE systemd[1]:Starting Remote desktop service (VNC)
Apr 14 10:09:24 F1A-VMHOST-SWPErunuser[3258]: Password:
Apr 14 10:09:24 F1A-VMHOST-SWPE systemd[1]:vncserver@:1service: control process exited, code=exited status=1
Apr 14 10:09:24 F1A-VMHOST-SWPE systemd[1]:Failed to start Remote desktop service (VNC)
Apr 14 10:09:24 F1A-VMHOST-SWPE systemd[1]:Unit vncserver@:1service entered failed state
Warning: Unit file changed on disk,'systemctl daemon-reload' recommended
三应用
更新systemctl以使其生效;
systemctl daemon-reload
设置vncserver的密码;
vncpasswd root
按提示输入密码以及确认密码
启动该服务用来启用vnc的1号窗口;
systemctl start vncserver@:1service 或者vncserver :1
关闭1号窗口:
systemctl stop vncserver@:1service 或者vncserver -kill:1
设置为开机自动启动;
systemctl enable vncserver@:1service
End
转自 嘉为教育-rhce认证_rhce培训_linux培训_linux认证_linux考证
以上就是关于VNC 服务全部的内容,包括:VNC 服务、我的电脑是win7,虚拟机安装了Ubuntu17.06,请问要如何在图形模式登录进入root账号、vncroot登录无响应等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)