wiki:TipAndDoc/network/vnc

Version 23 (modified by mitty, 12 years ago) (diff)

--

vncserver

xstartup

  • ~/.vnc/xstartup
    • .vnc/xstartup

      old new  
      77[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup 
      88[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources 
      99xsetroot -solid grey 
      10 vncconfig -iconic & 
      11 x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & 
      12 x-window-manager & 
       10# vncconfig -iconic & 
       11# x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" & 
       12# x-window-manager & 
       13exec gnome-session & 
    • デフォルトは/usr/bin/vnc4server(perl script)から生成される
  • $ vncserver :1 -geometry 800x600 -depth 24 -localhost -nolisten tcp
    • Log Outすると……
  • gnomeからログアウトしても自動で再起動する

{{{#! #!/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 &

PIDFILE="$HOME/.vnc/*${DISPLAY}.pid"

while : do

[ -r $PIDFILE ]
break

PID=cat $PIDFILE

ps $PID > /dev/null 2>&1
break

gnome-session

done }}}

  • 単純にwhile true gnome-sessionだと、vncserver -killしたあとでwait無しの無限ループに入って暴走する
  • ログアウトしてもgnome-screensaverなどのプロセスが残るが、vncserver -kill後に「gnome-screensaver: Fatal IO error 11 (Resource temporarily unavailable) on X server :1.0.」などで死ぬ

x11vnc

  • 「caught XIO error」というエラーとともに勝手にログアウト(Xのセッションからも)することがあるが、詳細不明
  • ~/.x11vncrc
    display :0 # This will do in most single user machine
    rfbauth .vnc/passwd # password file
    rfbport 5900 # Use this default port
    forever # Without this x11vnc will die after serving one connection.
    localhost # Only accept local connections. This makes your x11vnc secure along with SSH.
    
  • x11vnc -storepasswd で作られるパスワードファイルは先頭8文字しか見ない模様
    • -rw------- 1 mitty mitty 8 Feb 17 00:04 .vnc/passwd
  • ssh 越しにx11vnc serverの起動には成功せず(原理的に出来ない?)
    • sudo x11vncで起動すればよい
    • 「alias sudo='sudo -H '」している場合は、以下のようにする
      sudo x11vnc -rc ~/.x11vncrc
      
    • see also ssh
  • xfceの Settings -> Session and Startup の Application Autostart に 「/usr/bin/x11vnc」で登録すると良い
  • ps wwwwaux | grep auth
    root      1106  0.0  3.4 119100 17436 tty7     Ss+  Mar06   0:05 /usr/bin/X :0 -nr -verbose -auth /var/run/gdm/auth-for-gdm-bcQe9Q/database -nolisten tcp vt7
    
    • Xfce4 の例
    • -display :0 -auth guess で自動的に見つけてくれる模様

vnc with xinetd

  1. $ sudo aptitude install -R xinetd
  2. $ sudo vim /etc/xinetd.d/x11vnc
    • source:lab/trunk/TipAndDoc/xinetd.d/x11vnc
    • attachment:x11vnc.log <- /var/log/x11vnc.log
      • session毎に上書きされる模様(最新の接続情報しか残らない)
    • この設定では、xinetdとx11vncの両方で、localhost以外からの接続を拒否しているが、それでもxinetdへのセッションそのものは確立するため、iptablesでポートごと塞ぐのがmore better

Attachments (4)

Download all attachments as: .zip