LoginSignup
49

More than 5 years have passed since last update.

ubuntu + gnome + vncserverでのGUI環境

Posted at

背景

毎回vncserver経由でGUIアクセスするときに手間取って色々なパッケージをインストールしてしまうのでメモしておく。

以下環境情報。

  • ubuntu: 12.04

Desktop環境のインストール

以下のコマンドでgnome-coreをインストールする。

install_gnome
$ sudo apt-get update
$ sudo apt-get install gnome-core

gdmを起動してやる。

start_gdm
$ sudo service gdm status
gdm stop/waiting
$ sudo service gdm start
gdm start/running, process 28703
$

インストール中にdisplay managerの選択画面が表示されるので、gdmを選択する。

install_ubuntu_desktop
$ sudo apt-get install ubuntu-desktop

ubuntu-desktop-1.png

ubuntu-desktop-2.png

vncserverのインストール、設定

まずは以下のコマンドでvncserverをインストールする。

install_vnc4server
$ sudo apt-get install vnc4server

いったん起動して各種設定ファイルを作成する。

start_vncserver
$ 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を停止する。

kill_vncserver
$ vncserver -kill :1

作成された~/.vnc/xstartupを以下のように編集する。

~/.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を起動。

start_vncserver
$ vncserver :1

:1は画面番号を表し、デフォルトだとport:5901を表す。

接続してみる

いちいちportを開けるのは面倒なのでssh tunnelでアクセスする。
以下のコマンドで張れる。

ssh_tunnel
$ ssh -fNL 3456:localhost:5901 ${user}@${ip_addr} -p ${port}

上記を設定することで、localhost:3456vncserverにアクセスすることができる。

MACを使っている人は、トップバーの 移動 > サーバへ接続サーバへ接続画面が表示され、サーバアドレスvnc://localhost:3456を指定してやるとアクセスできるはず。

スクリーンショット 2014-08-22 13.52.48.png

先ほど入力したパスワードを指定。

スクリーンショット 2014-08-22 13.52.53.png

すると・・・ubuntu-desktopが表示される!・・・はず。
スクリーンショット 2014-08-22 14.16.19.png

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

おしまい。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
49