無法擺脫 x11vnc 輸出

無法擺脫 x11vnc 輸出

我使用的是 Ubuntu 系統,該系統的顯示器上設定了觸控螢幕:0。我希望能夠從 Windows 遠端控制該觸控屏,因此我設定了 x11vnc。效果很好。但這是設定:

我有兩個使用者(不包括root)。自動登入觸控螢幕的受限用戶(基本上沒有權限,也沒有密碼),以及一名具有複雜密碼、sudo 權限等的完全配置用戶。為活動狀態),所以我將命令放在x11vnc -loop &文件末尾/home/restricted/.profile。工作正常。但請注意,它必須是後台進程,因為該用戶稍後必須運行其他命令(對人類用戶隱藏)。

我遇到的問題是 x11vnc 的輸出雜訊很大。特別是如果您不使用密碼(我不使用密碼),並且這是一個循環,因此它會不斷重複。通常這不會成為問題,但不僅將輸出重定向到 /dev/null 不起作用(如下所述),而且當我透過 ssh 登入時輸出出現在其他用戶的終端上(這實際上是很煩人,因為我使用該帳戶進行維護,並且當螢幕上充滿了某些後台進程的輸出時,它無法執行任何操作,這是我得到的輸出範例:

--- x11vnc loop: 1 ---

--- x11vnc loop: waiting for: 1551

###############################################################
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
#@                                                           @#
#@  **  WARNING  **  WARNING  **  WARNING  **  WARNING  **   @#
#@                                                           @#
#@        YOU ARE RUNNING X11VNC WITHOUT A PASSWORD!!        @#
#@                                                           @#
#@  This means anyone with network access to this computer   @#
#@  may be able to view and control your desktop.            @#
#@                                                           @#
#@ >>> If you did not mean to do this Press CTRL-C now!! <<< @#
#@                                                           @#
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
#@                                                           @#
#@  You can create an x11vnc password file by running:       @#
#@                                                           @#
#@       x11vnc -storepasswd password /path/to/passfile      @#
#@  or   x11vnc -storepasswd /path/to/passfile               @#
#@  or   x11vnc -storepasswd                                 @#
#@                                                           @#
#@  (the last one will use ~/.vnc/passwd)                    @#
#@                                                           @#
#@  and then starting x11vnc via:                            @#
#@                                                           @#
#@      x11vnc -rfbauth /path/to/passfile                    @#
#@                                                           @#
#@  an existing ~/.vnc/passwd file from another VNC          @#
#@  application will work fine too.                          @#
#@                                                           @#
#@  You can also use the -passwdfile or -passwd options.     @#
#@  (note -passwd is unsafe if local users are not trusted)  @#
#@                                                           @#
#@  Make sure any -rfbauth and -passwdfile password files    @#
#@  cannot be read by untrusted users.                       @#
#@                                                           @#
#@  Use x11vnc -usepw to automatically use your              @#
#@  ~/.vnc/passwd or ~/.vnc/passwdfile password files.       @#
#@  (and prompt you to create ~/.vnc/passwd if neither       @#
#@  file exists.)  Under -usepw, x11vnc will exit if it      @#
#@  cannot find a password to use.                           @#
#@                                                           @#
#@                                                           @#
#@  Even with a password, the subsequent VNC traffic is      @#
#@  sent in the clear.  Consider tunnelling via ssh(1):      @#
#@                                                           @#
#@    http://www.karlrunge.com/x11vnc/#tunnelling            @#
#@                                                           @#
#@  Or using the x11vnc SSL options: -ssl and -stunnel       @#
#@                                                           @#
#@  Please Read the documention for more info about          @#
#@  passwords, security, and encryption.                     @#
#@                                                           @#
#@    http://www.karlrunge.com/x11vnc/faq.html#faq-passwd    @#
#@                                                           @#
#@  To disable this warning use the -nopw option, or put     @#
#@  'nopw' on a line in your ~/.x11vncrc file.               @#
#@                                                           @#
#@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@#
###############################################################
20/05/2016 10:53:18 x11vnc version: 0.9.13 lastmod: 2011-08-10  pid: 1551
20/05/2016 10:53:18 XOpenDisplay("") failed.
20/05/2016 10:53:18 Trying again with XAUTHLOCALHOSTNAME=localhost ...
20/05/2016 10:53:18
20/05/2016 10:53:18 *** XOpenDisplay failed. No -display or DISPLAY.
20/05/2016 10:53:18 *** Trying ":0" in 4 seconds.  Press Ctrl-C to abort.
20/05/2016 10:53:18 *** 1 2 3 4
Invalid MIT-MAGIC-COOKIE-1 key20/05/2016 10:53:22 XOpenDisplay(":0") failed.
20/05/2016 10:53:22 Trying again with XAUTHLOCALHOSTNAME=localhost ...
Invalid MIT-MAGIC-COOKIE-1 key20/05/2016 10:53:22 XOpenDisplay(":0") failed.
20/05/2016 10:53:22 Trying again with unset XAUTHLOCALHOSTNAME ...
Invalid MIT-MAGIC-COOKIE-1 key20/05/2016 10:53:22

20/05/2016 10:53:22 ***************************************
20/05/2016 10:53:22 *** XOpenDisplay failed (:0)

*** x11vnc was unable to open the X DISPLAY: ":0", it cannot continue.
*** There may be "Xlib:" error messages above with details about the failure.

Some tips and guidelines:

** An X server (the one you wish to view) must be running before x11vnc is
   started: x11vnc does not start the X server.  (however, see the -create
   option if that is what you really want).

** You must use -display <disp>, -OR- set and export your $DISPLAY
   environment variable to refer to the display of the desired X server.
 - Usually the display is simply ":0" (in fact x11vnc uses this if you forget
   to specify it), but in some multi-user situations it could be ":1", ":2",
   or even ":137".  Ask your administrator or a guru if you are having
   difficulty determining what your X DISPLAY is.

** Next, you need to have sufficient permissions (Xauthority)
   to connect to the X DISPLAY.   Here are some Tips:

 - Often, you just need to run x11vnc as the user logged into the X session.
   So make sure to be that user when you type x11vnc.
 - Being root is usually not enough because the incorrect MIT-MAGIC-COOKIE
   file may be accessed.  The cookie file contains the secret key that
   allows x11vnc to connect to the desired X DISPLAY.
 - You can explicitly indicate which MIT-MAGIC-COOKIE file should be used
   by the -auth option, e.g.:
       x11vnc -auth /home/someuser/.Xauthority -display :0
       x11vnc -auth /tmp/.gdmzndVlR -display :0
   you must have read permission for the auth file.
   See also '-auth guess' and '-findauth' discussed below.

** If NO ONE is logged into an X session yet, but there is a greeter login
   program like "gdm", "kdm", "xdm", or "dtlogin" running, you will need
   to find and use the raw display manager MIT-MAGIC-COOKIE file.
   Some examples for various display managers:

     gdm:     -auth /var/gdm/:0.Xauth
              -auth /var/lib/gdm/:0.Xauth
     kdm:     -auth /var/lib/kdm/A:0-crWk72
              -auth /var/run/xauth/A:0-crWk72
     xdm:     -auth /var/lib/xdm/authdir/authfiles/A:0-XQvaJk
     dtlogin: -auth /var/dt/A:0-UgaaXa

   Sometimes the command "ps wwwwaux | grep auth" can reveal the file location.

   Starting with x11vnc 0.9.9 you can have it try to guess by using:

              -auth guess

   (see also the x11vnc -findauth option.)

   Only root will have read permission for the file, and so x11vnc must be run
   as root (or copy it).  The random characters in the filenames will of course
   change and the directory the cookie file resides in is system dependent.

See also: http://www.karlrunge.com/x11vnc/faq.html

 --- x11vnc loop: sleeping 2000 ms ---


 --- x11vnc loop: 2 ---

這只是不斷重複。

它對我大喊無法打開顯示屏,但它可以工作。我猜測這是因為受限用戶已經運行了此命令並且連接正常,但現在該用戶也嘗試這樣做,因此無法連線。

為什麼會發生這種情況?我的理解顯然存在一些漏洞。以下是我嘗試過的不同方法:


將輸出重定向到 /dev/null

在同一位置,/home/restricted/.profile我嘗試將現有命令替換x11vnc -loop &x11vnc -loop > /dev/null 2>&1 &.

這具有零影響,輸出仍然在其他用戶的終端上並且(顯然)沒有消失。


使用 nohup 運行指令

再次在 中/home/restricted/.profile,我嘗試將現有命令替換x11vnc -loop &nohup x11vnc -loop &

再一次,這根本沒有任何效果。輸出仍然存在。 Nohup 甚至沒有創建 nohup.out 檔案。至少,我沒找到。

為了完成,我又試了nohup x11vnc -loop > /dev/null 2>&1 &一遍,沒有任何改變。


將 x11vnc 作為守護程式啟動

在這裡,我開始意識到我做錯了什麼。我想,也許是因為/home/restricted/.profile這種東西放錯地方了。因此,我製作了一個在啟動時運行的腳本,並按照框架文件的範例/etc/init.d進行了連結。update-rc.d

x11vnc 再次工作,但輸出出現在我的所有終端上。


在螢幕中啟動 x11vnc

我最後一次嘗試修復這個問題是將命令放入螢幕會話中。 Screen 通常會為我解決這樣的問題...但這次不行。

在 中/home/restricted/.profile,我替換x11vnc -loop &screen -d -R x11vnc x11vnc -loop

這次,x11vnc 不再運作(無法透過 Windows 用戶端連線),但所有終端上仍然有輸出。


再說一遍,顯然我對 x11vnc 或在啟動時產生進程有些不理解。

正如您可能從上面的內容中看出的那樣,我已經進行此故障排除一段時間了,並且在網路上找不到任何與此相關的其他內容。所以這裡的幫助會很棒。提前致謝。

答案1

重定向>&輸出對我有用。

x11vnc -repeat -noxdamage -ncache 10 -forever -loop -rfbauth &> x11vnc.log

相關內容