找回密码
 注册
查看: 27|回复: 1

centos9 stream 安装vncserver

[复制链接]

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
发表于 2024-7-23 17:03:30 | 显示全部楼层 |阅读模式
centos9 stream 安装vncserver1 P. N: K' V0 x# o- t4 I; g

5 ~+ d9 @" |! S- R5 F" _0 u+ K3 i3 N

9 v1 b8 y: Y7 D8 u0 u0 a2 a7 L6 \4 F5 }' i$ ^. W( `) t
yum install -y xdpyinfo
8 \3 W+ C7 i; ~/ P" R' a* f5 R) ^: L% i% U1 |0 O
2 ]" J( K2 \* p3 ]! ]9 n- `7 m
2 C; m  s) D+ ~" o6 ]8 \
yum install -y tigervnc tigervnc-server
2 {1 ^8 ?, L1 O  d
& t9 q" e& u- R% U
) ?4 c- K7 d, ]" t7 N
# n* t, y: G7 y) Dvncserver " R1 J) [1 t" D+ d; J' `( \9 z  a

# G" X5 K- @; K& x, n! mWARNING: vncserver has been replaced by a systemd unit and is now considered deprecated and removed in upstream.# j3 v" b2 R4 s# n* v% b
Please read /usr/share/doc/tigervnc/HOWTO.md for more information.
$ }9 ?! |8 O9 }; j/ J8 w& {5 H$ ~# l! J' T3 [
Warning: python-flask:1 is taken because of /tmp/.X1-lock
5 g8 ~) m6 c  u% j' RRemove this file if there is no X server python-flask:1
2 ^% ^8 r) b" h8 x& A% ^/ d1 \7 m+ a
You will require a password to access your desktops.
6 K1 b$ c+ K$ G* J- A) C- S
- \) u0 P9 s) |" l- Y5 U: hPassword:
( E* w1 s  J+ s+ @9 m( v4 h, jVerify:. g5 H6 Q8 ^( X7 H
Would you like to enter a view-only password (y/n)? y
* @' Q4 P3 q7 ?* _Password:
& n  K2 B' Q, Y; G, ^; {# ?5 MVerify:7 ?# j) T: h  Q. p$ Y

9 c! A5 w0 H$ p. m: ]' LNew 'python-flask:2 (root)' desktop is python-flask:2
9 I' c1 V( X. U; ?/ l6 R
+ ~1 u  Y" \- ^2 z3 A) a$ yCreating default startup script /root/.vnc/xstartup/ r; n7 [4 H5 }) f2 F
Creating default config /root/.vnc/config# _8 P- F8 u# @# w
Starting applications specified in /root/.vnc/xstartup
, `2 p4 R7 L0 R5 XLog file is /root/.vnc/python-flask:2.log
' K! c1 D- I/ r9 u
! U5 c" w/ U8 v! j9 I3 ^修改vncserver.users文件

使用如下的命令修改文件

8 r- b: _8 y" \
vim /etc/tigervnc/vncserver.users
; f0 a3 G2 J* }+ n
, d% w6 A, }. N! _3 d5 f% W
. v  x1 c0 j$ }3 q0 Q4 v8 I. t# TigerVNC User assignment
, v( R" ^8 e; u# M1 O3 q; b#
( q, k: P) I) A: R( h6 @  F( o# This file assigns users to specific VNC display numbers.- B9 L+ K! r6 o7 e, V
# The syntax is <display>=<username>. E.g.:" q" G- b3 h  K% K. w$ {: m0 [
#0 U4 |  ~- D6 I- s' E
# :2=andrew
8 ?& w' w2 M2 i, Z# :3=lisa
& j. i. j/ ]& P8 p' c. M0 E:1=root2 Y! M" g+ X1 q1 V) {; \
:2=devops$ a: l4 `) r9 f1 C- O
; U6 s* M9 V8 Z& `

/ c3 ?, {; ?- O" i修改vncserver-config-defaults

使用如下的命令修改文件

vim /etc/tigervnc/vncserver-config-defaults

session=gnome

securitytypes=vncauth,tlsvnc

desktop=sandbox

geometry=2000x1200


" b5 y; ~+ o/ w! ], P4 l

alwaysshared

5 ?; g& N  x& i/ X3 d3 z! T' p& x
其中localhost需要注释掉,否则将不能进行外部访问
% B( o) d# G, N! e7 x
# e9 [4 ?/ Y7 ^$ o

% r) t; H* y/ \! C% ?4 r" w( h( b# L/ T
修改vncserver-config-mandatory

使用如下的命令修改文件

vim /etc/tigervnc/vncserver-config-mandatory

geometry=2000x1200

securitytypes=vncauth,tlsvnc

desktop=sandbox

#geometry=2000x1200

/ b0 e2 _, v0 h; _# x$ M+ O# b# d" \

alwaysshared

同理,需要将localhost注释

修改config

使用如下的命令修改文件

vim $HOME/.vnc/config

session=gnome

geometry=1000x1200


3 z: V+ _' p. s( H1 ^5 I( ~6 A. v! @* k6 d$ }$ b' d
复制vncserver@x.service
8 T( e: j$ {2 Q' m8 S6 P0 {0 ucp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service1 u2 l4 e, [/ @6 v0 j

2 G+ V9 Z5 W& _& ?( Z: C4 x, W* b  `, ]9 L; W! S. z

0 t+ m3 {5 r  F- d/ E1 d
3 U# G3 z1 |. a. T2 w/ s$ hvncpasswd : i+ x$ F3 s$ i* n
Password:# u. i3 K& x! T" S( P/ u  [; Y# y
Verify:* l% |3 d3 B4 l$ y+ \5 j
Would you like to enter a view-only password (y/n)? n. A9 W7 q! A- s! D# [' p
A view-only password is not used5 i: v! W1 E. K6 Y* v- i

$ E+ ]# W2 o: C( s) N8 c
: y% n! W) O7 h3 n+ L& M# x# I  r1 r0 H$ G5 x7 L' Z$ J6 H
' T% }: c3 Q8 c: @
[root@python-flask ~]# systemctl restart vncserver@:1" y0 T* F7 ]4 h: q% U3 C
[root@python-flask ~]# systemctl status vncserver@:1" H$ |. X: [1 g, F' x0 V" Z
○ vncserver@:1.service - Remote desktop service (VNC)) j- _  {6 c) b$ e
     Loaded: loaded (/etc/systemd/system/vncserver@:1.service; enabled; preset: disabled)
+ \7 ^  y& E& ?  O8 E     Active: inactive (dead) since Tue 2024-07-23 17:20:19 CST; 1s ago
, Y/ {& A$ x/ r4 k4 M* t% n& x   Duration: 17ms
4 Q7 O! K4 _# W0 V* a( Y& e3 ~0 z    Process: 5203 ExecStartPre=/usr/libexec/vncsession-restore :1 (code=exited, status=0/SUCCESS)
  s5 P' X% J8 [; R/ k    Process: 5214 ExecStart=/usr/libexec/vncsession-start :1 (code=exited, status=0/SUCCESS)  q4 e9 O; s' N
   Main PID: 5221 (code=exited, status=0/SUCCESS)3 @; s9 a  G; `( |4 t& p
        CPU: 23ms" B, ^3 o- z" f( ~6 e  P( y1 h
5 H( u3 ?' b1 |. j! c8 [9 m/ ?: J+ E& x
7月 23 17:20:18 python-flask systemd[1]: Starting Remote desktop service (VNC)...
9 Z; h: m' t% R+ W+ O5 k/ t5 `7月 23 17:20:18 python-flask systemd[1]: Started Remote desktop service (VNC).* ~5 f! h4 y. U* [& a! {
7月 23 17:20:19 python-flask systemd[1]: vncserver@:1.service: Deactivated successfully.$ A; o8 r* C4 I: L/ T4 y  M, C$ `/ P
, V! q" v2 a* X0 k; \) @* ?

5 H' R% a1 d1 j8 t% I" \6 S
* z7 \# L7 {6 [6 |/ @$ k1 h/ q至此vncserver安装完成。
0 v; b. w) C4 G+ Q7 d& N

1

主题

0

回帖

12

积分

管理员

积分
12
QQ
 楼主| 发表于 2024-7-23 17:25:59 | 显示全部楼层
[root@python-flask ~]# firewall-cmd --add-port=5900-6000/tcp --permanent
+ x: ?3 [& M5 S  F: Lsuccess
8 d; q1 z% Q, q: j[root@python-flask ~]# firewall-cmd --reload : j5 i% S( y) y3 ?
success5 q0 O$ d( L$ b0 R0 x& Z
您需要登录后才可以回帖 登录 | 注册

本版积分规则

返回首页|Archiver|手机版|小黑屋|易陆发现技术论坛 ( 蜀ICP备2026014127号-1 )

GMT+8, 2026-6-12 00:31 , Processed in 0.014754 second(s), 22 queries .

Powered by Discuz! X5.0

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表