centos9 stream 安装vncserver
% _, z! S- ?; r% U/ T0 [
9 S4 Y: a5 x) l# |/ ~ Y7 N; Y# A' ]! v1 U4 u8 [8 r, s v
% F) \) N/ O# O. X' x
6 i8 d( Q0 y* V& S4 L yum install -y xdpyinfo1 |' J; ?6 f2 G& [$ @7 `
9 Y% Q- O/ Q- z- P3 g5 E. Z
) B2 d! Y# Y+ I1 T C
, g; \% l1 d7 C" R yum install -y tigervnc tigervnc-server8 N/ Q `( w9 j6 W+ k
2 f* I: [0 f A) b g
1 Y2 G- r. g; {' W. @1 H# v
B4 u6 ^2 E* ^
vncserver
+ ~; r6 x6 `, p1 ~: l# s$ X2 G- k I* _( u; g( l3 q% Q7 ?
WARNING: vncserver has been replaced by a systemd unit and is now considered deprecated and removed in upstream.3 B7 h# g6 N9 A6 x% j2 v; n2 L
Please read /usr/share/doc/tigervnc/HOWTO.md for more information.4 X! E! d6 j* p/ s) I
0 b' k- _; W; N
Warning: python-flask:1 is taken because of /tmp/.X1-lock8 A; [1 r" V" {, r
Remove this file if there is no X server python-flask:17 D# `/ g% v; g9 H5 X
* {1 Y% [) n8 n( J- ?* c$ E: N
You will require a password to access your desktops.. G4 W( N( g8 {3 L! r7 e8 r1 F7 J8 _' J
8 P, G: B1 F$ d2 B) R2 _# ZPassword: f" ?8 a3 g) t: ?$ e
Verify:
7 n) [4 W, T' q1 Y2 f( @) U* I0 V4 hWould you like to enter a view-only password (y/n)? y
+ P0 O: @" [5 q; Q8 @Password:
. ~! x1 b" d% ~' z% C0 HVerify:
' B$ i& W8 M- ~0 G2 y& C- v8 x7 n$ g; o7 w. I
New 'python-flask:2 (root)' desktop is python-flask:2. X: [ A1 h9 D+ L$ h, t
( D. W. w+ t# S5 Z9 J) F
Creating default startup script /root/.vnc/xstartup+ x5 @- Z1 C( N8 `; M- I
Creating default config /root/.vnc/config
S( I. I- k% {$ J' qStarting applications specified in /root/.vnc/xstartup
' W6 S$ l# g7 w( ]! Z3 j% {" d$ JLog file is /root/.vnc/python-flask:2.log
8 i" i; l. V& z& u5 X. \+ v+ z6 q& f$ m. @4 s# ~
修改vncserver.users文件使用如下的命令修改文件
W# \7 z. }% n0 N6 S1 Z- cvim /etc/tigervnc/vncserver.users
2 p; `' `$ p2 n2 A4 ]; S$ \$ x7 O7 s6 p# i$ Y
) ?6 D, `0 S! i) T# V" J
# TigerVNC User assignment. G1 s2 z9 d3 }: _* o% s, O) Q
#
3 w3 ]# b0 q; F; o( t# This file assigns users to specific VNC display numbers.( j0 x/ q: K4 A% I& U
# The syntax is <display>=<username>. E.g.:! r; r6 C6 H3 ~: X$ ^
#* ~& J3 s) o% |, |1 U
# :2=andrew: L) |( B# U# D0 r2 P
# :3=lisa
- l) ~( {6 }1 i0 o% y: F:1=root9 \ B0 V* m- W6 ?" g l
:2=devops8 k* ?, S4 D! k2 i x$ A
% T3 g' D/ B- r% l$ T o
/ _( s3 b8 N5 H: ~* r, b6 |0 b修改vncserver-config-defaults使用如下的命令修改文件 vim /etc/tigervnc/vncserver-config-defaults session=gnome securitytypes=vncauth,tlsvnc desktop=sandbox geometry=2000x1200 : p$ A+ D: ?* n5 L5 T7 f& Z
alwaysshared & @" f/ Z! d; d) x
其中localhost需要注释掉,否则将不能进行外部访问
# R, Z. c) u, j
p4 G0 l( d% p6 r/ x5 R
, G7 v8 o4 ` ]4 N6 Z
0 K d' @. q# [% P$ J修改vncserver-config-mandatory使用如下的命令修改文件 vim /etc/tigervnc/vncserver-config-mandatory geometry=2000x1200 securitytypes=vncauth,tlsvnc desktop=sandbox #geometry=2000x1200 % V& ^- F5 X5 `2 I7 s
alwaysshared 同理,需要将localhost注释 修改config使用如下的命令修改文件 vim $HOME/.vnc/config session=gnome geometry=1000x1200
0 p: c/ L$ W* e. E$ E; P
! y+ k& h7 B. _! @6 |0 d) K% O复制vncserver@x.service# o- t; n/ D* R+ W; `; ?
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service; B2 S" Y6 x2 ]# P/ b l8 u
7 C7 r9 @6 Y' w
- U' ` ] }% Q }0 }# C
4 l7 a ?0 l$ w$ V1 I, g& l8 s' P0 A
vncpasswd ) W7 \ j( |" l9 t/ R- L; X
Password:
; K+ Z3 H( F# x% ZVerify:
" g; c! A" m/ k# M& ~Would you like to enter a view-only password (y/n)? n/ {+ n5 o* }0 M
A view-only password is not used
- \$ W ]% T1 V& Y# w
. I+ D; x) I* y7 j0 q
8 v0 A- Z$ Y6 f, q; B8 I D" e5 O$ [# g
' y; j6 i) ]& H. r7 ][root@python-flask ~]# systemctl restart vncserver@:12 y% R, O" k* j/ v6 q
[root@python-flask ~]# systemctl status vncserver@:1
! z8 n$ B2 ~$ p: ^7 @- H5 Z○ vncserver@:1.service - Remote desktop service (VNC)
0 [# y' }% C# j% P+ o Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; preset: disabled)
0 t7 D7 `/ Q" U0 E7 p6 L Active: inactive (dead) since Tue 2024-07-23 17:20:19 CST; 1s ago
- F- z3 H2 O, g Duration: 17ms& |1 {7 j O$ r! c4 ]
Process: 5203 ExecStartPre=/usr/libexec/vncsession-restore :1 (code=exited, status=0/SUCCESS)
7 a! t$ q+ F$ H H1 u4 @ Process: 5214 ExecStart=/usr/libexec/vncsession-start :1 (code=exited, status=0/SUCCESS)) W7 Y+ M" _: U; u) t' I9 H5 @6 V
Main PID: 5221 (code=exited, status=0/SUCCESS)3 g1 O. B' d! S
CPU: 23ms U- Q2 S8 U+ K
% k" _: C2 |- m, A9 |' a }# Q6 V5 h& D7月 23 17:20:18 python-flask systemd[1]: Starting Remote desktop service (VNC)...5 L, \4 r4 F8 }4 s i
7月 23 17:20:18 python-flask systemd[1]: Started Remote desktop service (VNC).
) V5 ]! j% E6 w2 r" Q7月 23 17:20:19 python-flask systemd[1]: vncserver@:1.service: Deactivated successfully.
4 @' X4 ? x% X
! J O# e0 z+ }) X; z& A9 B7 C" \9 C! c' @- N
3 d6 g9 x) f/ k
至此vncserver安装完成。
% {+ o8 ]6 b, j' D/ W |