背景
毎回vncserver経由でGUIアクセスするときに手間取って色々なパッケージをインストールしてしまうのでメモしておく。
以下環境情報。
- ubuntu: 12.04
Desktop環境のインストール
以下のコマンドでgnome-coreをインストールする。
$ sudo apt-get update
$ sudo apt-get install gnome-core
gdmを起動してやる。
$ sudo service gdm status
gdm stop/waiting
$ sudo service gdm start
gdm start/running, process 28703
$
インストール中にdisplay managerの選択画面が表示されるので、gdmを選択する。
$ sudo apt-get install ubuntu-desktop
vncserverのインストール、設定
まずは以下のコマンドでvncserverをインストールする。
$ sudo apt-get install vnc4server
いったん起動して各種設定ファイルを作成する。
$ vncserver :1
You will require a password to access your desktops.
Password:
Verify:
xauth: file /${HOME}/.Xauthority does not exist
New '$(hostname):1 (root)' desktop is $(hostname):1
Creating default startup script /${HOME}/.vnc/xstartup
Starting applications specified in /${HOME}/.vnc/xstartup
Log file is /${HOME}/.vnc/$(hostname):1.log
$
Passwordは8文字以内で記入する必要があり、9文字以降は切り捨てされて登録される。
上記コマンドで~/.vnc/xstartupが作成される。
とりあえずvncserverを停止する。
$ vncserver -kill :1
作成された~/.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 &
exec gnome-session &
再度vncserverを起動。
$ vncserver :1
:1は画面番号を表し、デフォルトだとport:5901を表す。
接続してみる
いちいちportを開けるのは面倒なのでssh tunnelでアクセスする。
以下のコマンドで張れる。
$ ssh -fNL 3456:localhost:5901 ${user}@${ip_addr} -p ${port}
上記を設定することで、localhost:3456でvncserverにアクセスすることができる。
MACを使っている人は、トップバーの 移動 > サーバへ接続でサーバへ接続画面が表示され、サーバアドレスにvnc://localhost:3456を指定してやるとアクセスできるはず。
先ほど入力したパスワードを指定。
すると・・・ubuntu-desktopが表示される!・・・はず。

これでもう迷わないと思う。
おしまい。



