CentOS7.6服務器部署VNC

CentOS7.6服務器部署VNC

2019年04月22日 16:50:39 sukysun125 閱讀數 268linux

 

CentOS7.6服務器部署VNC

 

安裝vnc服務器

[root@localhost ~]# yum install tigervnc-server
  • 1

開啓vnc

[root@localhost ~]# 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
xauth:  file /root/.Xauthority does not exist

New 'localhost.VD:1 (root)' desktop is localhost.VD: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.VD:1.log
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

開啓遠程端口

[root@localhost ~]# vncserver :1

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

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/localhost.VD:1.log
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

查看服務器ip

[root@localhost ~]# ifconfig | grep inet
        inet 10.10.41.43  netmask 255.255.252.0  broadcast 10.10.43.255
        inet6 2400:dd01:1001:1040:3b37:b445:ad5b:ad2f  prefixlen 64  scopeid 0x0<global>
        inet6 fe80::bdd8:8bd:8871:f736  prefixlen 64  scopeid 0x20<link>
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

關閉防火牆和selinux

1. 關閉防火牆vim

將firewalld服務設置爲disable服務器

[root@localhost ~]# systemctl disable firewalld.service
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
  • 1
  • 2
  • 3

查看狀態,成功關閉app

[root@localhost ~]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: inactive (dead)
     Docs: man:firewalld(1)

Apr 22 10:06:35 localhost.VD systemd[1]: Starting firewalld - dynamic firewall daemon...
Apr 22 10:06:37 localhost.VD systemd[1]: Started firewalld - dynamic firewall daemon.
Apr 22 15:31:38 localhost.VD systemd[1]: Stopping firewalld - dynamic firewall daemon...
Apr 22 15:31:39 localhost.VD systemd[1]: Stopped firewalld - dynamic firewall daemon.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

2. 關閉selinuxui

  • 臨時修改
[root@localhost ~]# setenforce 0
  • 1
  • 永久修改,下次開機生效
[root@localhost ~]# vim /etc/selinux/config 

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled				//開啓時顯示爲enforcing,將其改成disabled
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 查看狀態,成功關閉
[root@localhost ~]# getenforce
Permissive
  • 1
  • 2

遠程訪問

打開vnc-viewer,輸入須要訪問的ip和端口號便可進行訪問,本文中使用的ip爲:10.10.41.43::5901spa

相關文章
相關標籤/搜索