centos9 stream 安装vncserver
5 d$ r6 |1 W& A! f0 t
0 M. G4 ~5 V% c2 A: t" Q; f: `) W4 G/ N$ ~
# `, n$ t l1 i# l) \' y( x
4 p( ~! w9 w+ X% m& J- Q2 R yum install -y xdpyinfo
. r# a, H1 ~$ Z9 w3 X6 t7 R% r! C' L2 S3 F
2 \4 L4 r8 A3 v" O/ E' Z" k$ I. i( t: \, j, y) f5 j1 G
yum install -y tigervnc tigervnc-server9 M- V6 A' \- c0 [, ]3 C# L
/ z% }% X* B8 U3 J
8 {% G2 G0 w% p0 M* D% Z0 p. ~) J
! E3 P7 e& W! K% z( C! S5 J# W
vncserver e7 E3 {1 v1 j
; H& V/ S+ Q% a |& z# LWARNING: vncserver has been replaced by a systemd unit and is now considered deprecated and removed in upstream.
( S( c; \5 a0 t8 zPlease read /usr/share/doc/tigervnc/HOWTO.md for more information.
9 t5 x$ m6 I9 m8 o/ f9 p& \! |7 P! h, A2 S# z, }
Warning: python-flask:1 is taken because of /tmp/.X1-lock9 `; l3 J8 D3 Z9 o
Remove this file if there is no X server python-flask:1
: Q/ n% s+ o$ R" J1 d
( F7 Q) R, P) f* D( y' y, jYou will require a password to access your desktops.% E! E; \+ P Y$ J: U
' U! l( [$ L! V% f7 A$ x
Password:' `9 |6 x# E5 |1 c# S% K* y1 N
Verify:# f) Z; M6 c' a% O6 l5 \ e8 ]3 h4 Z
Would you like to enter a view-only password (y/n)? y% n' H7 z2 ^0 y- S
Password:7 t5 O3 t% m# |# }+ D
Verify:
+ P* u* A+ d3 |: c9 K' y: }6 {3 x: z6 J2 h
New 'python-flask:2 (root)' desktop is python-flask:2. t% P7 n5 b) @7 n. j0 A g
4 k% e$ `5 E& X& l' Q5 u3 w
Creating default startup script /root/.vnc/xstartup, M& m. Q# ]- \0 R k
Creating default config /root/.vnc/config0 `7 u2 W9 k/ I
Starting applications specified in /root/.vnc/xstartup! ~$ ~: s( [3 l2 E
Log file is /root/.vnc/python-flask:2.log( r6 g5 l6 _2 s* `8 R& K
2 e. F. Z; A! I U修改vncserver.users文件使用如下的命令修改文件
* F0 X2 o Q6 b Gvim /etc/tigervnc/vncserver.users
6 q2 O( H; H; v6 `0 ]$ B* w$ k8 T5 Z2 I9 _- G2 A6 H% x
; e- ^ Z4 `0 a/ Z
# TigerVNC User assignment; r% r/ r" X6 Z% _4 P+ p+ w2 T
#
# n& S6 Z- R, J8 _% H0 M# This file assigns users to specific VNC display numbers.; n3 N" y0 I) S
# The syntax is <display>=<username>. E.g.:
( D: X/ _& @+ k+ J m#
& {- {0 r' H$ s: o! [# :2=andrew
7 f3 z* f# @6 ^2 Q( u# :3=lisa
5 d* ~9 v- H9 ]( [6 a:1=root( ?) a. Z) {! T1 R5 c
:2=devops
. t! @- m7 _- P9 G4 a) ?( N3 W1 X, s
3 i3 @$ o. u% j1 n8 ]* M
7 U5 G- C9 ]* ^2 v1 {4 T6 j. G修改vncserver-config-defaults使用如下的命令修改文件 vim /etc/tigervnc/vncserver-config-defaults session=gnome securitytypes=vncauth,tlsvnc desktop=sandbox geometry=2000x1200 7 D( Q9 G% w; n. _: [
alwaysshared + O& K3 X- M4 W( r) U
其中localhost需要注释掉,否则将不能进行外部访问
8 X" K! y, ]* v! r. I
# n' x* ]$ g# X5 Y9 \( V+ b0 L' V3 E: p$ s! k# v# S5 s {
5 B+ N3 e2 N( z6 Z5 n. Z修改vncserver-config-mandatory使用如下的命令修改文件 vim /etc/tigervnc/vncserver-config-mandatory geometry=2000x1200 securitytypes=vncauth,tlsvnc desktop=sandbox #geometry=2000x1200
! g8 J+ s# V$ s' |: `7 L# ualwaysshared 同理,需要将localhost注释 修改config使用如下的命令修改文件 vim $HOME/.vnc/config session=gnome geometry=1000x1200 ) n, x4 k/ \9 h+ `0 n6 [" s3 }
! A3 B1 Q6 J7 g
复制vncserver@x.service' K( G% F2 V' S0 Q( N6 M
cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service1 T. M) o' p* F# b. T( W' x4 Y
8 T! {7 c5 A# Q$ p2 v
' J9 l1 b6 O- Z
1 b- @! A6 O8 E$ `: o4 {4 h- j, H. J. B! N1 n1 `& L. f
vncpasswd
5 z" _" `2 R. v$ _Password:1 {. u+ t0 X. S- l
Verify:
& M/ i! A( }9 k$ u8 tWould you like to enter a view-only password (y/n)? n
/ X+ P6 z* f$ p! ]$ ?A view-only password is not used5 I; W/ F1 g; }0 j i! ]
5 ~8 ?, b y; n8 O- m3 }: K
0 R# I, J" ?( n8 ?, x: R0 B
9 e+ W. E& b7 C1 P$ G& o
$ a! P+ E) s: @& c[root@python-flask ~]# systemctl restart vncserver@:1" t& C6 e: N( B9 F1 M
[root@python-flask ~]# systemctl status vncserver@:1
7 I8 T+ R0 R' ]# w0 x8 E8 X# p○ vncserver@:1.service - Remote desktop service (VNC)6 k& S n% E1 C7 p" u+ I1 k1 b
Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; preset: disabled)
0 a$ g2 Z8 U4 s* Y" }/ N Active: inactive (dead) since Tue 2024-07-23 17:20:19 CST; 1s ago
3 V7 x# I$ R! }- n+ {5 z7 X Duration: 17ms
0 B3 M; ]2 @8 v$ @( \5 V) X* D Process: 5203 ExecStartPre=/usr/libexec/vncsession-restore :1 (code=exited, status=0/SUCCESS)) q; G: I' u& s* i9 S& o( |5 X9 T
Process: 5214 ExecStart=/usr/libexec/vncsession-start :1 (code=exited, status=0/SUCCESS)' X# _* x1 ?$ ]* r% K+ i
Main PID: 5221 (code=exited, status=0/SUCCESS)% F( W0 A/ j. H9 w: A
CPU: 23ms- T9 _2 w; j' Z, ^7 W; ]
; G, m# h' o G% f, ~* y8 R7月 23 17:20:18 python-flask systemd[1]: Starting Remote desktop service (VNC)..." l$ [% J6 M, n2 |% w
7月 23 17:20:18 python-flask systemd[1]: Started Remote desktop service (VNC).
4 w a/ J) r+ \4 @9 C, K( n* f7月 23 17:20:19 python-flask systemd[1]: vncserver@:1.service: Deactivated successfully.8 u0 m" a& B1 B
: q" I( v& D: r% G$ |
# R8 \# N; O! o* K1 H$ {$ c9 F6 d: X4 c3 b1 ]8 |8 d# x
至此vncserver安装完成。1 v$ n# z. b. ]( V3 t; N; b& i
|