[size=x-large][b]centos7配置vnc [/b]
1.安裝tigervncserver,yum install tigervnc-server tigervnc-server-module
2.拷貝配置檔案cp /lib/systemd/system/[email protected] /etc/systemd/system/vncserver@:1.service
3.進入到配置檔案目錄cd /etc/systemd/system
4.修改配置檔案vim vncserver@:1.service
[unit]
description=remote desktop service (vnc)
after=syslog.target network.target
[service]
type=forking
# clean any existing files in /tmp/.x11-unix environment
execstartpre=/bin/sh -c '/usr/bin/vncserver -kill :1 > /dev/null 2>&1 || :'
execstart=/sbin/runuser -l root -c "/usr/bin/vncserver :1 -geometry 1280x720 -depth 24"
pidfile=/root/.vnc/%h%i.pid
execstop=/bin/sh -c '/usr/bin/vncserver -kill :1 > /dev/null 2>&1 || :'
[install]
wantedby=multi-us
5. 啟用配置檔案 systemctl enable vncserver@:1.service
6. 設定登陸密碼:vncpasswd
7. 啟動vncserver:systemctl start vncserver@:1.service
8 . 啟動狀態檢視:systemctl status vncserver@:1.serviceer.target
9.在iptables中加入對應的埠5901(注意,如果有其他使用者,那麼也需要將埠加上。vnc的埠預設是5900 + n)
# cat /etc/sysconfig/iptables
# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:input accept [0:0]
:forward accept [0:0]
:output accept [0:0]
-a input -m state --state related,established -j accept
-a input -p icmp -j accept
-a input -i lo -j accept
-a input -p tcp -m state --state new -m tcp --dport 22 -j accept
[color=red]-a input -p tcp -m state --state new -m tcp --dport 5901 -j accept[/color]-a input -j reject --reject-with icmp-host-prohibited
-a forward -j reject --reject-with icmp-host-prohibited
commit
:wq! #儲存退出
systemctl restart iptables.service #最後重啟防火牆使配置生效
注意1、如果你不配置和啟用防火牆,此時用vnc viewer連線的話,會報:"connect:connection timed out(10060)"錯誤。
2、本文是以root使用者為例,如果其他使用者也需要登入,那麼,還需要將檔案複製為
1cp /lib/systemd/system/[email protected] /lib/systemd/system/vncserver@:2.service
同時,將檔案內的%i改為2,並建立對應使用者的vncpasswd。
3、vncserver 啟動失敗的一種情況
#vncserver
warning: localhost.localdomain:1 is taken because of /tmp/.x11-unix/x1
remove this file if there is no x server localhost.localdomain:1
warning: localhost.localdomain:2 is taken because of /tmp/.x11-unix/x2
remove this file if there is no x server localhost.localdomain:2
new 'localhost.localdomain:3 (root)' desktop is localhost.localdomain:3
log file is /root/.vnc/localhost.localdomain:3.log
解決辦法:
刪除 / tmp/.x11-unix/的內容[/size]
Centos 7 安裝VNC步驟
先囉嗦一下vnc是什麼 virtual network computing vnc允許linux系統可以類似實現像windows中的遠端桌面訪問那樣訪問linux桌面。本文配置機器是興寧市網路資訊中心的一台centos 7 hp伺服器環境下執行。首先試試伺服器裝了vnc沒 root wic rpm ...
centos7 安裝vnc服務
一,安裝伺服器端 1,新增使用者 useradd vnc passwd vnc2,安裝gnome桌面 yum groupinstall gnome desktop unlink etc systemd system default.target ln sf lib systemd system gr...
Centos 7 安裝VNC步驟
先囉嗦一下vnc是什麼 virtual network computing vnc允許linux系統可以類似實現像windows中的遠端桌面訪問那樣訪問linux桌面。本文配置機器是興寧市網路資訊中心的一台centos 7 hp伺服器環境下執行。首先試試伺服器裝了vnc沒 root wic rpm ...