马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?开始注册
x
centos9 stream 安装vncserver7 y( L# j2 x. R# U5 `+ j" `
$ C+ W7 F+ _: s0 i* \
/ W& t" {' w" H7 Y0 b |
9 K A; e* r/ b5 I& I; D# K: U* e4 a8 [$ N- O b7 z4 j$ j1 F
yum install -y xdpyinfo
- Q- d3 s6 e1 U. B L9 ?/ f+ S+ R; j5 u* I
" k, U! N E" W7 l# [0 _% {- I% ]6 H; @! Y+ R, d
yum install -y tigervnc tigervnc-server
) D$ Z" H/ H2 ]: O/ f) B& H( k; N
9 ]1 R) L$ k, C/ e' F' w- S
8 u3 }2 Z2 R5 R0 s
vncserver : R) K4 ?# M! N; i: p
( L9 z( f" M+ C0 p: G
WARNING: vncserver has been replaced by a systemd unit and is now considered deprecated and removed in upstream.. o- k u7 |+ s9 d3 T% A. p& {/ D
Please read /usr/share/doc/tigervnc/HOWTO.md for more information.) b8 o m( m' p, z: E Q
" c5 d8 h# P5 y& A
Warning: python-flask:1 is taken because of /tmp/.X1-lock
/ L. E* Z- [" |$ X* x' E# E+ V9 hRemove this file if there is no X server python-flask:1# { k- h7 g5 A$ A- z8 G
r: `$ r) t( R. _' B4 M; MYou will require a password to access your desktops.7 f" M" E& ~! k4 X9 ~
9 ?7 W5 P3 f8 ^
Password:- C1 J6 y- U+ F5 d6 v
Verify:: G3 v, y v4 i K- U% Z
Would you like to enter a view-only password (y/n)? y
4 }" _6 |" @7 U, r2 V6 w0 @# h. ^8 ]9 fPassword:5 b+ T& U/ E/ T* y
Verify:
7 a$ J, @+ g, c/ g2 A
! [7 Q: O8 U. b6 aNew 'python-flask:2 (root)' desktop is python-flask:2
$ i: ~, e+ k* R5 Y, h0 f% O1 S* e
Creating default startup script /root/.vnc/xstartup
1 u3 W2 [3 ]+ A' c; w2 B$ u: tCreating default config /root/.vnc/config/ q6 l) ~8 S7 d" w) S
Starting applications specified in /root/.vnc/xstartup- n, S* h4 a5 ^: e
Log file is /root/.vnc/python-flask:2.log* S$ f0 y ^0 r0 Z3 O
- |8 t o% u: P# Y" d
修改vncserver.users文件使用如下的命令修改文件
2 q/ [1 ]; K4 ^1 x: j+ `vim /etc/tigervnc/vncserver.users
- k. s8 ~) l, }, l Y" m( J/ [6 `9 O/ y0 m- N! o
/ x& D4 `1 U$ m0 K, c1 J# TigerVNC User assignment
1 ^5 }/ O7 w2 g& v6 q#: i# n" f# b/ z0 J3 h
# This file assigns users to specific VNC display numbers.
* g* K7 \( g8 [# |! f: g7 w% a0 t! P# The syntax is <display>=<username>. E.g.:; w7 h- l+ ?' R+ y% R& d) E! H2 i! S
## k8 U$ h' Y+ _% k U
# :2=andrew# {2 V4 G2 c0 K3 ~; @6 }3 t
# :3=lisa. q/ L0 y6 H* w7 ~: N; N& I
:1=root
7 L) N! M, G2 t:2=devops
2 _ A5 R1 M' H5 a5 N& }
f- C, q0 Y0 J% X! q4 b6 j. H" I
修改vncserver-config-defaults使用如下的命令修改文件 vim /etc/tigervnc/vncserver-config-defaults session=gnome securitytypes=vncauth,tlsvnc desktop=sandbox geometry=2000x1200 7 d- K2 S! c0 E. _. M
alwaysshared
' w7 u) n" D' O8 B9 r其中localhost需要注释掉,否则将不能进行外部访问1 d/ Z: g4 Y0 Z) Z. ^9 K P9 W, d- g
2 p# t* m) z# i( \. m
H) H6 K* O- V4 H/ {! A" Z5 Q3 N2 q5 Z7 [. L
修改vncserver-config-mandatory使用如下的命令修改文件 vim /etc/tigervnc/vncserver-config-mandatory geometry=2000x1200 securitytypes=vncauth,tlsvnc desktop=sandbox #geometry=2000x1200
: l/ b0 W& g+ K2 U6 I" h7 D& |& Palwaysshared 同理,需要将localhost注释 修改config使用如下的命令修改文件 vim $HOME/.vnc/config session=gnome geometry=1000x1200 6 ?+ u9 s; s& a9 k: w+ f* `3 D/ B' \
$ t. v, r# r' B% t: l* h& }1 @( X
复制vncserver@x.service
/ [7 Z# l+ A+ ^& i+ S: Qcp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
$ D, e0 [, c& a+ L( Z8 D& s2 X6 O1 s+ h, H6 F
* k$ K. K! P# H, O4 L4 [9 ]4 c2 P
[$ \) H) m6 @# W9 z; d- b' r
+ h9 B1 B* x5 ~9 n" b' c
vncpasswd
4 c& l; }2 v+ m A% [Password:; Z& l. n! F( E4 F- D% p* N0 _5 D' j
Verify: q" O) Y: ~$ c4 ?2 b4 M4 Y
Would you like to enter a view-only password (y/n)? n
2 u7 k! V6 D, W5 D1 j/ q3 oA view-only password is not used
" w$ Y. h0 b* n, ^) l' L ]' [8 c
9 P3 H3 K( X0 L% ^& i: k- S) z
; _0 C) e$ d; G. t: l: r3 J0 n4 o3 b1 s2 I, J6 w) ~- t% c4 P
[root@python-flask ~]# systemctl restart vncserver@:15 y4 A; J0 ^" G
[root@python-flask ~]# systemctl status vncserver@:14 z B+ E4 [ M; X
○ vncserver@:1.service - Remote desktop service (VNC)
& _. ]$ o |* ~. y5 F Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; preset: disabled)
( `. k, y& t- w6 m Active: inactive (dead) since Tue 2024-07-23 17:20:19 CST; 1s ago; [* h `# c3 L5 Z4 P* r6 R& ~
Duration: 17ms
6 W; I1 O7 Z1 F+ {' y" L) S) t Process: 5203 ExecStartPre=/usr/libexec/vncsession-restore :1 (code=exited, status=0/SUCCESS)
3 r3 C4 H) ]+ A2 ] Process: 5214 ExecStart=/usr/libexec/vncsession-start :1 (code=exited, status=0/SUCCESS)
% E( n6 W- f1 Y, h1 j Main PID: 5221 (code=exited, status=0/SUCCESS)
0 n" Y2 i% m( \' b) Z- F* p CPU: 23ms4 h* |) [; @! u( O
2 t1 h! Q, M n/ j/ y4 D4 Q
7月 23 17:20:18 python-flask systemd[1]: Starting Remote desktop service (VNC)...
' @$ a: m A# ^. U7月 23 17:20:18 python-flask systemd[1]: Started Remote desktop service (VNC).
8 k, {: e7 z- x4 x; h6 z5 L. }7月 23 17:20:19 python-flask systemd[1]: vncserver@:1.service: Deactivated successfully.
5 \3 {7 o Y( N$ i- w' ~' p5 p1 `- I3 N* |- ? c8 E, X
4 d0 d$ z, e j9 K2 Y
8 C7 z7 P; }( t: u; G
至此vncserver安装完成。
; p% G5 W* m- v3 r |