centos7 vnc oracle,Centos7远程桌面的安装与vnc/vnc-server的设置

一.安装 GNOME-Desktop桌面环境

1、安装 GNOME

# yum -y groups install"GNOME Desktop"

2、完成安装后,使用如下命令启动桌面

# startx

首次启动,进行一些初始设置

选择系统语言

选择键盘类型

添加在线用户(可选)

开始使用

启动后的桌面环境,如下所示:

3a72613dc9f6

二、使用GNOME Shell

CentOS 7的默认GNOME桌面以经典模式开始,但如果您想使用GNOME Shell,请设置如下:

方式一:如果以 startx 命令启动GNOME,设置如下:

#echo"exec gnome-session">> ~/.xinitrc# startx

单击“登录”按钮旁边的按钮。

在列表中选择“GNOME”。(默认为GNOME Classic模式)

3a72613dc9f6

GNOME shell的启动后,如下所示:

3a72613dc9f6

三、安装 TigerVNC Server

1. 安装TigerVNC Server

建议使用非root用户安装,-y代表直接安装

sudo yum install-ytigervnc-server

2. 配置VNC Service

以下方法是新方法,以前是要配置/etc/sysconfig/vncservers,现在第一步是将默认提供的文件复制到/etc/systemd/system,命令如下sudo cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service

注意上述命令参数重的“@:1”,可以将数字1换成30000内的任意数字,“5900+数字”即为程序的显示(监听)端口,如”@:1″表示监听5901端口。

接下来修改该配置文件sudo vim /etc/systemd/system/vncserver@:1.service

将其中替换为你想要的用户名,所有内容如下:# The vncserver service unit file

#

# Quick HowTo:

# 1. Copy this file to /etc/systemd/system/vncserver@.service

# 2. Replace with the actual user name and edit vncserver

#    parameters in the wrapper script located in /usr/bin/vncserver_wrapper

# 3. Run `systemctl daemon-reload`

# 4. Run `systemctl enable vncserver@:.service`

#

# DO NOT RUN THIS SERVICE if your local area network is

# untrusted!  For a secure way of using VNC, you should

# limit connections to the local host and then tunnel from

# the machine you want to view VNC on (host A) to the machine

# whose VNC output you want to view (host B)

#

# [user@hostA ~]$ ssh -v -C -L 590N:localhost:590M hostB

#

# this will open a connection on port 590N of your hostA to hostB's port 590M

# (in fact, it ssh-connects to hostB and then connects to localhost (on hostB).

# See the ssh man page for details on port forwarding)

#

# You can then point a VNC client on hostA at vncdisplay N of localhost and with

# the help of ssh, you end up seeing what hostB makes available on port 590M

#

# 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.

[Unit]

Description=Remote desktop service (VNC)

After=syslog.target network.target

[Service]

Type=simple

# Clean any existing files in /tmp/.X11-unix environment

ExecStartPre=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

ExecStart=/usr/bin/vncserver_wrapper root %i

ExecStop=/bin/sh -c '/usr/bin/vncserver -kill %i > /dev/null 2>&1 || :'

[Install]

WantedBy=multi-user.target

保存文件并退出vim,重新加载配置

sudo systemctl daemon-reload

也可以设置成开机启动

sudo systemctl enable vncserver@:1.service

3 修改防火墙

首先判断firewalld是否启动,输入以下命令判断sudo firewall-cmd --state

如果启动应该输出running

如果是not running,执行下面命令sudo systemctl start firewalld

添加端口号5901-5905sudo firewall-cmd --permanent --zone=public --add-port=5901-5905/tcp

重新加载防火墙sudo firewall-cmd --reload

可以使用下面命令查看端口号是否被加入firewall-cmd --list-all-zones

5. 设置VNC密码

通过ssh,用oracle用户名登录到服务器,执行下面命令vncserver

终端会提示你输入密码,如下You will require a password to access your desktops.

Password:

Verify:

xauth:  file /home/oracle/.Xauthority does not exist

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

Creating default startup script /home/oracle/.vnc/xstartup

Starting applications specified in /home/oracle/.vnc/xstartup

Log file is /home/oracle/.vnc/localhost.localdomain:1.log

如果想修改密码,可以使用vncpasswd。现在已经有一个vnc服务在运行了,但我们需要使用刚刚配置的服务来启动,所以我们需要先杀死刚刚的vnc服务,使用下面命令。vncserver -kill :1

接下来,重启我们配置的服务sudo systemctl daemon-reload

sudo systemctl restart vncserver@:1.service

使用下面命令查看该服务是否正确运行sudo systemctl status vncserver@:1.service -l

如果正确启动,输出应为● vncserver@:2.service - Remote desktop service (VNC)

Loaded: loaded (/etc/systemd/system/vncserver@:2.service; enabled; vendor preset: disabled)

Active: active (running) since 日 2017-07-23 21:55:35 CST; 12h ago

Process: 8720 ExecStart=/usr/sbin/runuser -l oracle -c /usr/bin/vncserver %i -geometry 1280x720 (code=exited, status=0/SUCCESS)

Process: 8716 ExecStartPre=/bin/sh -c /usr/bin/vncserver -kill %i > /dev/null 2>&1 || : (code=exited, status=0/SUCCESS)

Main PID: 8744 (Xvnc)

CGroup: /system.slice/system-vncserver.slice/vncserver@:2.service

‣ 8744 /usr/bin/Xvnc :2 -desktop 127.0.0.1:2 (oracle) -auth /home/oracle/.Xauthority -geometry 1280x720 -rfbwait 30000 -rfbauth /home/oracle/.vnc/passwd -rfbport 5902 -fp catalogue:/etc/X11/fontpath.d -pn

7月 23 21:55:32 127.0.0.1 systemd[1]: Starting Remote desktop service (VNC)...

7月 23 21:55:35 127.0.0.1 systemd[1]: Started Remote desktop service (VNC).

如果想配置多用户同时访问,需要将上面vncserver@:1.service,改为vncserver@:2.service,然后配置其中用户名,再按以上步骤走一遍就可以了

四、客户端连接

服务端配置完毕,接下来用客户端连接。

vnc是免费技术,许多客户端都支持该协议。本文采用App Store上免费的“Remote Desktop – VNC”软件进行连接,打开后软件界面如下:

3a72613dc9f6

在输入框填写服务器地址:vnc://ip:port,其中ip是服务器的ip或域名,port是监听的端口,例如5901。输入后按回车,弹出密码输入框,输入vncpasswd设置的密码。密码正确的话就可以看到服务器的图形桌面。

3a72613dc9f6

按回车键进入登录界面,输入登录用户名和密码进入系统。

3a72613dc9f6

接下来就可以做各种图形操作了。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值