ssh tunneling应用案例-AWS EC2 vnc图形化桌面的支持

通常地,不管是AWS EC2仍是阿里云的云主机,linux系统默认都只提供ssh登陆方式。若是你是一个技术控,很是但愿把图形化界面给折腾出来,这其中就不需有vnc server的支持,除此以外,还涉及到如vnc client如何和vnc server通讯的问题。 有两个方案: html

1. 手工在安全组中开放更多的端口linux

2. 经过ssh隧道来桥接vnc client和server的通讯链路ubuntu

具体地,须要如下的步骤windows

1. 建立好aws ec2或者阿里云主机安全

2. 在windows客户端上安装Realvncssh

3. ssh到ec2上执行如下命令(以ubutu为例子)安装vncserver及其依赖的组件post

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install ubuntu-desktop gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal xfce4 vnc4server

4.启动vncserver,输入vnc password阿里云

随后编辑~/.vnc/xstartup文件并替换为如下内容:spa

#!/bin/sh
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc
unset DBUS_SESSION_BUS_ADDRESS
startxfce4 &
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
gnome-panel &
gnome-settings-daemon &
metacity &
nautilus &
gnome-terminal &

5. 重点来了,开启ssh的端口forwardingcode

ssh -L 5902:localhost:5902 -i amazon.pem ubuntu@ec2–5290172228.compute-1.amazonaws.com

再启动vncserver

vncserver -geometry 1340x750

须要注意的是,1340x750是指的个人windows桌面次寸。随后

6.使用Realvnc来链接localhost:5902而且输入上面已经设置过的pasword.(there is a correlation between them (eg. display 1 = vnc port 5901, 6001 and display 2 = vnc port 5902 etc)

 

https://medium.com/@Arafat./graphical-user-interface-using-vnc-with-amazon-ec2-instances-549d9c0969c5

 

转载于:https://www.cnblogs.com/kidsitcn/p/11120667.html