VNC连接远程Ubuntu设置

一.windows 远程软件VNCViewer

这个不多说: 下载地址:http://www.realvnc.com/download/viewer/

 

二.安装 vnc-server

红帽的rpm系安装使用 

yum install tigervnc-server

debian 的deb系安装使用

apt-get install vnc4server

再次安装失败, 提示:

404  Not Found [IP: 112.124.140.210 80]
Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/main/libx/libx11/libx11-xcb1_1.4.99.1-0ubuntu2.2_amd64.deb  404  Not Found [IP: 112.124.140.210 80]
Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/main/libx/libxfixes/libxfixes3_5.0-4ubuntu4.2_amd64.deb  404  Not Found [IP: 112.124.140.210 80]
Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/main/libx/libxi/libxi6_1.7.1.901-1ubuntu1~precise1_amd64.deb  404  Not Found [IP: 112.124.140.210 80]
Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/main/libx/libxv/libxv1_1.0.6-2ubuntu0.1_amd64.deb  404  Not Found [IP: 112.124.140.210 80]
Failed to fetch http://cn.archive.ubuntu.com/ubuntu/pool/main/x/x11-utils/x11-utils_7.6+4ubuntu0.1_amd64.deb  404  Not Found [IP: 112.124.140.210 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

提示让apt-get update , update后

apt-get install vnc4server 

就ok了。

 

 

三. 修改VNC Password

vncpasswd

Password: ******
Verify:*****

如果输入vncpasswd 提示 : bash: vncpasswd: 未找到命令, 估计用的是yum 的  yum install vnc-server    记得是tigervnc-server哦。

 

四.启动VNC server

vncserver

提示:

xauth:  file /root/.Xauthority does not exist
New 'AYbZ:1 (root)' desktop is AYbZ:1
Creating default startup script /root/.vnc/xstartup
Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/AYbZ:1.log

五.连接vnc

客户端连接vnc 使用端口为:1 每启动一次vncserver 相应的:端口就会变化一次

在这里,我们看到的是一个Linux命令行窗口

六.修改显示界面

我们打开/root/.vnc/xstartup

vim /root/.vnc/xstartup
#!/bin/sh

# 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 &
x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
x-window-manager &

我们需要将最后一行“x-window-manager &”改为我们自己的Ubuntu图形界面服务, Ubuntu有gnome、KDE、Unity等桌面环境。
如果是gnome桌面,改成gnome-session &
如果是KDE桌面,改成startkde &
如果是Unity桌面,首先去 /usr/share/gnome-session/sessions/下看桌面session的名称,如果是ubuntu-2d,则将最后一行改为:
export STARTUP="/usr/bin/gnome-session --session=ubuntu-2d"
$STARTUP

------------------------

在这里,一大波问题来袭

修改最后一行为:gnome-session & 

重启vnc:

vncserver -kill :1
vncserver

vnc还显示命令行窗口

好,我们知道,有可能是没有安装桌面环境。方法安装:

第一步:安装x-windows的基础

apt-get install x-window-system-core

第二步:安装登录管理器

apt-get install gdm

第三步:安装桌面

apt-get install ubuntu-desktop

重启vnc:

vncserver -kill :1
vncserver

依旧显示命令行窗口

这次已经gnome桌面环境,依旧这样是为什么呢?记得在启动vncservier时生成个日志.log文件。

查看日志文件

cat root/.vnc/AYbZ\:1.log 

显示如下错误:

error opening security policy file /etc/X11/xserver/SecurityPolicy
Could not init font path element /usr/X11R6/lib/X11/fonts/Type1/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/Speedo/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/misc/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/75dpi/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/100dpi/, removing from list!
Could not init font path element /usr/share/fonts/X11/75dpi/, removing from list!
Could not init font path element /usr/share/fonts/X11/100dpi/, removing from list!

我们安装字体便是

apt-get  install xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic

安装完成时候,重启vncserver,再次查看log日志文件

Could not init font path element /usr/X11R6/lib/X11/fonts/Type1/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/Speedo/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/misc/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/75dpi/, removing from list!
Could not init font path element /usr/X11R6/lib/X11/fonts/100dpi/, removing from list!

/usr/share/fonts/X11目录下有字体文件了,但/usr/X11R6/lib 目录还是不存在字体

我们可以让X11R6里面软链接到share/fonts字体目录中

mkdir -r  /usr/X11R6/lib   # 没有X11R6/lib 目录
cd /usr/X11R6/lib/
ln -s /usr/share/fonts/X11 X11

再次重启vncserver

OK!

 

 

 

补充

在内存寸土寸金的服务器端,桌面环境占用越少越好。Ubuntu-desktop至少400MB。发现了好用的xfce,安装好仅占用180MB内存。

apt-get install xfce4

编辑~/.vnc/xstartup,添加:

sesion-manager & xfdesktop & xfce4-panel &
xfce4-menu-plugin &
xfsettingsd &
xfconfd &
xfwm4 &

 

设置vnc分辨率大小

vncserver -geometry 1440x900

 

通过ssh端口转发加密VNC连接

VNC直接连接服务器,在一网段的计算机有可能用wireshark/sniffer窃听到用户名和密码,可以通过SSH进行加密端口映射来保证传输用户名和密码的时候也是加密

ssl -L 参数: -L 远程端口:本地IP:本地端口  远程user@远程IP
ssh -L 5901:localhost:5901 useroot@120.55.65.20*

客户端:

vncviewer localhost:1

 

通过wireshark可以看到用SSH协议进行了加密传输。

转载于:https://www.cnblogs.com/dcb3688/p/4607962.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值