kali linux 安装vnc及配置

主要解决vncserver配置问题,解决vncviewer连接后不显示桌面,灰屏问题
实验环境:
Linux kionf 4.19.0-kali4-amd64 #1 SMP Debian 4.19.28-2kali1 (2019-03-18) x86_64 GNU/Linux

0x00. 安装vncserver

apt-get install vnc4server


0x01. 启动并配置vnc

[email protected]:~/.vnc# vncserver

1. 配置密码,并启动服务

You will require a password to access your desktops.
Password:
Verify:
# 设置登录密码6位及以上
Would you like to enter a view-only password (y/n)? n
# 是否创建只允许观看密码
vncserver: /usr/bin/Xtigervnc did not start up, please look into '/root/.vnc/kionf:1.log' to determine the reason! -2

2. 检查是否启动成功

[email protected]:~/.vnc# netstat -ntlp|grep vnc
tcp 0 0 127.0.0.1:5902 0.0.0.0:* LISTEN 18624/Xtigervnc
tcp6 0 0 ::1:5902 :::* LISTEN 18624/Xtigervnc

3. 配置连接启动桌面文件

vim /$HOME/.vnc/xstartup

xstartup
1
2
3
4
5
6
#!/bin/sh
# Start Gnome 3 Desktop
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
vncconfig -iconic &
dbus-launch --exit-with-session gnome-session &

chmod +x /$HOME/.vnc/xstartup


0x02 客户端连接测试

随便测试
vncviewer 127.0.0.1:5902