我们将为新用户设置 VNC,以 john 的帐户名为例。
- 以 root 身份创建 VNC 用户帐户:
$ su # useradd john # passwd john
- 编辑服务器配置文件 /etc/sysconfig/vncservers ,并在 VNCSERVERS 行添加 john 并设置 VNCSERVERARGS 。
# vi /etc/sysconfig/vncservers VNCSERVERS="1:aa 2:john" VNCSERVERARGS[1]="-geometry 640x480" VNCSERVERARGS[2]="-geometry 640x480"
帐户 john 的屏幕分辨率为 640 x 480。
- 设置用户的 VNC 密码。
将用户切换到每个用户的帐户,如下所述,运行 vncpasswd 命令。
这将为该用户 ID 创建 ~/.vnc 目录:
# su - john $ vncpasswd
$ cd .vnc $ ls passwd $ exit #
- 确认 vncserver 将干净地启动和停止。
通过以 root 用户身份启动和停止 vncserver 来创建 xstartup 脚本。
# service vncserver start # service vncserver stop # chkconfig vncserver on
- 创建 xstartup 脚本。
登录到每个用户并编辑 xstartup 脚本。
$ cd .vnc $ ls mymachine.localnet:1.log passwd xstartup
为 john 编辑 ~/.vnc/xstartup 如下:
#!/bin/sh # Add the following line to ensure you always have an xterm available. ( while true ; do xterm ; done ) & # Uncomment the following two lines for normal desktop: unset SESSION_MANAGER exec /etc/X11/xinit/xinitrc [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey vncconfig -iconic & xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & twm &
- 以 root 身份启动 vncserver。
# service vncserver start
- 用vnc客户端测试每个VNC用户,将[ip_of_vnc_server]替换为vnc服务器的ip地址。
对于帐户约翰:
# vncviewer [ip_of_vnc_server]:2
日期:2020-09-17 00:13:54 来源:oir作者:oir