Ubuntu > VNCサーバの設定
更新日
2020-12-14
広告
VNCサーバをインストールする方法をまとめます。
Ubuntu 20.04へのインストール
まずデスクトップ環境をインストールします。ここではxfce4を使います。$ sudo apt install xfce4 xfce4-goodies次に、VNCサーバ(tightvncserver)をインストールします。
$ sudo apt install tightvncserver設定ファイルは、 ~/.vnc/xstartup にあります。 設定ファイルを編集して、xfce4を実行するようにします。 この設定がないと、VNCクライアントで接続したときに、まともなGUIが表示されません。
#!/bin/bash xrdb $HOME/.Xresources startxfce4 &VNCサーバに接続する際のパスワードを設定します。
$ vncpasswd Using password file /home/hoge/.vnc/passwd VNC directory /home/hoge/.vnc does not exist, creating. Password: Verify: Would you like to enter a view-only password (y/n)? n起動します。":1"というのは、IDのようなものです。
$ vncserver :1Windows 10向けのVNCクライアントとしてUltraVNCを使います。 ポート番号 5901を指定して、VNCサーバのIPアドレスを指定すれば、接続できるはずです。
Ubuntu 16
$ sudo apt-get install vnc4serverとりあえず、一度起動します。
$ vncserverこれで ~/.vnc/xstartup が作成され、vncログイン時のパスワードが登録される。 シャットダウンします。
$ vncserver -kill :1':1'が、VNCサーバのIDです。これはpsコマンドなどで確認できます。
$ ps -aefw | grep vnc hoge 4817 1 0 22:40 pts/2 00:00:00 Xvnc4 :1 -desktop mypc:1次に、解像度などを設定します。 /etc/vnc.conf に以下の変数を設定します。
$geometry = "1280x1024"; $depth = "24";また、gnomeを使えるように、~/.vnc/xstartupを編集します。
# 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 &
'x-window-manager &' をコメントアウトして 'exec gnome-session &' を追加します。 これで、vncクライアントでアクセスしたときに、gnomeを使えます。
以下のように、gnome-terminalを使ったり、gnome-panelを表示したり、カスタマイズ可能です。
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey exec gnome-session & gnome-panel & gnome-settings-daemon & metacity & nautilus -n & gnome-terminal &
Ubuntu 14.04の場合
Ubuntu 14.04で上記の手順でvncをセットアップすると、一部のキーバインディングが変に設定されてしまいます。 具体的には、's'でアプリケーションメニューが開き、'd'でウィンドウが隠されてデスクトップが表示されます。
これだと、おそらくタイピングできないでしょう。 とにかく、なんとかして以下の2行を打てば、ある程度まともな状態になると思います。
$ gsettings set org.gnome.desktop.wm.keybindings panel-main-menu "['<Shift><Alt>F1']" $ gsettings set org.gnome.desktop.wm.keybindings show-desktop "['<Shift><Alt>F2']"
上記コマンドの中にも's'や'd'があります。 ターミナルなどに表示されている's'や'd'をコピー&ペーストするなどして、なんとか入力しましょう。 また、別にShift-Alt-F1以外のキーにバインディングしても構いません。
また、Ubuntuの場合、vnc4serverよりもtightvncserverのほうが良い場合があります。以下でインストールできます。
$ sudo apt-get install tightvncserver
広告
お問い合わせは sweng.tips@gmail.com まで。