Jumpserver堡垒机使用VNC录入Linux图形界面资产
背景:部分Linux机器,使用者需要图形化界面登录
解决方法:
1、在Linux服务器上安装VNC及必要依赖
[root@localhost ~]# yum install gnome* tigervnc-server tigervnc-server-module -y
2、VNC用户直接使用root
[root@localhost ~]# vncserver #设置VNC登录密码
passwd:
``````
完成后退出即可。
3、用system管理VNC服务
[root@localhost .vnc]# cp /lib/systemd/system/vncserver@.service /etc/systemd/system/vncserver@:1.service
[root@localhost .vnc]# cat /etc/systemd/system/vncserver@:1.service
[Unit]
Description=Remote desktop service (VNC)
After=syslog.target network.target systemd-user-sessions.service[Service]
Type=forking
ExecStartPre=+/usr/libexec/vncsession-restore %i
ExecStart=/usr/libexec/vncsession-start %i
PIDFile=/run/vncsession-%i.pid
SELinuxContext=system_u:system_r:vnc_session_t:s0[Install]
WantedBy=multi-user.target
[root@localhost .vnc]# systemctl daemon-reload
[root@localhost .vnc]# systemctl restart vncserver@\:1
[root@localhost .vnc]# systemctl status vncserver@\:1
● vncserver@:1.service - Remote desktop service (VNC)Loaded: loaded (/etc/systemd/system/vncserver@:1.service; disabled; vendor preset: disabled)Active: active (running) since Wed 2025-08-20 15:09:42 CST; 5s agoProcess: 235396 ExecStart=/usr/libexec/vncsession-start :1 (code=exited, status=0/SUCCESS)Process: 235383 ExecStartPre=/usr/libexec/vncsession-restore :1 (code=exited, status=0/SUCCESS)Main PID: 235403 (vncsession)Tasks: 0 (limit: 408510)Memory: 1.0MCGroup: /system.slice/system-vncserver.slice/vncserver@:1.service‣ 235403 /usr/sbin/vncsession root :1Aug 20 15:09:42 localhost.localdomain systemd[1]: Starting Remote desktop service (VNC)...
Aug 20 15:09:42 localhost.localdomain systemd[1]: Started Remote desktop service (VNC).[root@localhost .vnc]# netstat -lntup |grep vnc
tcp 0 0 0.0.0.0:5901 0.0.0.0:* LISTEN 235424/Xvnc
tcp6 0 0 :::5901 :::* LISTEN 235424/Xvnc
4、堡垒机新建VNC资产
为避免和命令行混淆,可以单独新建一个VNC资产
测试登录: