2021-05-12 14:32:11
CentOS安裝使用VNC進行遠端桌面登入
以下介紹在CentOS 7下安裝vncserver並使用vnc-viewer進行登入(使用root許可權):
1、執行命令yum install tigervnc-server安裝vncserver;
2、執行命令yum install vnc安裝vnc;//感覺不安裝也可以,安裝一下也很快,不要在意這些細節
3、執行命令yum groupinstall "X Window System"安裝X-Window;//之前安裝發現經常無法啟動vncserver,後面通過網上查資料介紹可以安裝X-Window解決這個 問題
4、安裝中文字元以解決介面中文亂碼的問題:yum install dejavu-lgc-sans-fonts、yum groupinstall "Fonts" -y
5、禁用防火牆,如果已經禁用防火牆可以跳過這一步:systemctl stop firewalld.service、systemctl disable firewalld.service
6、設定vncserver:
拷貝建立一個新的組態檔,以開啟1號視窗為例,如果需要開啟多個則建立多個組態檔即可:
[root@localhost ~]# cp /lib/systemd/system/vncserver@.service /lib/systemd/system/vncserver@:1.service
修改組態檔內容
[root@localhost ~]# vi /lib/systemd/system/vncserver@:1.service
# The vncserver service unit file
#
# Quick HowTo:
# 1. Copy this file to /etc/systemd/system/vncserver@.service
# 2. Replace <USER> with the actual user name and edit vncserver
# parameters appropriately
# ("User=<USER>" and "/home/<USER>/.vnc/%H%i.pid")
# 3. Run `systemctl daemon-reload`
# 4. Run `systemctl enable vncserver@:<display>.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=forking
User=root
# Clean any existing files in /tmp/.X11-unix environment
ExecStartPre=-/usr/bin/vncserver -kill %i
ExecStart=/usr/bin/vncserver %i
PIDFile=/root/.vnc/%H%i.pid
ExecStop=-/usr/bin/vncserver -kill %i
[Install]
WantedBy=multi-user.target
7、執行命令systemctl daemon-reload更新systemctl;
8、執行命令vncpasswd root設定vncserver的密碼;
9、執行命令systemctl start vncserver@:1.service(可以執行systemctl enable vncserver@:1.service命令設定為預設啟動服務);//啟動不了則重新啟動一下系統或則檢視啟動紀錄檔
10、重新啟動系統後使用VNC-Viewer連線:192.168.10.100:1,輸入設定的密碼即可登入。
CentOS 6.7下VNC安裝 http://www.linuxidc.com/Linux/2017-09/146884.htm
CentOS 7 安裝設定 VNC 詳解 http://www.linuxidc.com/Linux/2017-05/143324.htm
CentOS7.1安裝VNC,讓Win7遠端桌面Linux http://www.linuxidc.com/Linux/2017-05/143346.htm
CentOS下VNC連線黑畫面問題解決 http://www.linuxidc.com/Linux/2017-01/139995.htm
Ubuntu下安裝設定VNC遠端工具 http://www.linuxidc.com/Linux/2017-03/141936.htm
本文永久更新連結地址:http://www.linuxidc.com/Linux/2017-09/146980.htm
相關文章