Refracta Development, Scripts, etc.
Post a reply
fsmithred

- fsmithred
- Posts: 2101
- Joined: Wed Mar 09, 2011 9:13 pm

## x11vnc

Wed Jan 23, 2013 4:41 am

This is a rewrite of the VNC section in the Release Notes. Please don't get the idea that I know what I'm doing. The following has been minimally tested. Maybe we can dress this up a a bit and put it in the howto section.
___ VNC over SSH ___
# (Optional) Add authorization key:
ssh-add /path-to-key/id_rsa
# Start remote vnc server over ssh:
# If user is logged in on the remote host:
ssh -t -L 5900:localhost:5900 [email protected]
'x11vnc -localhost -display :0'
# (Optional, wheezy) - add "-ncache 10" to the x11vnc command in the above lines.
# This may make the display smoother.
'x11vnc -ncache 10 -localhost -display :0'
# If user is not logged in on remote host, something like the following.
# Get the auth file from 'ps ax | grep auth'
ssh -t -L 5900:localhost:5900 [email protected]
'x11vnc -auth /var/run/lightdm/root/:0 -localhost -display :0'
# Or use the vncserv script below. It will find the auth file and use it.
ssh -t -L 5900:localhost:5900 [email protected]
'/usr/local/bin/vncserv'
# In another terminal, connect to the remote desktop:
vncviewer localhost:0
# or maybe:
vncviewer -encodings "copyrect tight hextile" localhost:0
This script goes in /usr/local/bin.
--- CUT ---
#!/usr/bin/env bash
# vncserv
# gdm3 in squeeze
#authfile=$(ps ax |grep auth | awk '/gdm3/ { print $13 }')
# lightdm in wheezy
authfile=$(ps ax |grep auth | awk '/lightdm/ { print $8 }')
x11vnc -ncache 10 -auth $authfile -localhost -display :0
--- CUT ---
___ YET ANOTHER WAY TO DO VNC ___
(This way does not use ssh.)
On the server:
Main menu --> Internet --> X11VNC Server
Click OK (or change the port if you want)
Another window comes up, check the box next to "Accept Connections"
Optionally, you can create a password.
Click Apply or OK
On the client, issue the command:
vncviewer
A small window comes up; enter the name or IP number of the remote server.
OK
=================================
nadir

- nadir
- Posts: 1160
- Joined: Wed Mar 09, 2011 4:18 am
- Location: here

## Re: x11vnc

Wed Jan 23, 2013 3:49 pm

I seldom fool with vnc (and if i use tightvnc and remmina, which both do it magically, that is: i got no idea what is happening).
One question first:
Why vnc over ssh? For security ?
fsmithred

- fsmithred
- Posts: 2101
- Joined: Wed Mar 09, 2011 9:13 pm

## Re: x11vnc

Wed Jan 23, 2013 4:11 pm

Yes, for security. I don't use vnc much, either, but it is a good way to help someone with their computer remotely.
To make it even easier, run this script on the client. You need to have the previous script in /usr/local/bin/vncserv on the server for this to work.

Code:
  `#!/bin/sh
  # vncssh
  # adapted from x11vnc_ssh script at http://www.karlrunge.com/x11vnc/
  # usage: vncssh <host>:<xdisplay>
  # e.g.: vncssh snoopy.peanuts.com:0
  # ([email protected]
  :N or [email protected]
  also work)
  host=`echo $1 | awk -F: '{print $1}'`
  disp=`echo $1 | awk -F: '{print $2}'`
  if [ "x$disp" = "x" ]; then disp=0; fi
  cmd="/usr/local/bin/vncserv"
  enc="copyrect tight zrle hextile zlib corre rre raw"
  ssh -f -t -L 5900:localhost:5900 $host "$cmd"
  sleep 6
  vncviewer -encodings "$enc" localhost:$disp
  exit 0`

fsmithred

- fsmithred
- Posts: 2101
- Joined: Wed Mar 09, 2011 9:13 pm

## Re: x11vnc

Wed Jan 23, 2013 6:37 pm

It gets better...
You can connect with vnc to a server that does not have a desktop running and still get a desktop on the client.
As root:
Install xvfb on the server.
Drop to console and stop lightdm with '(slash)etc/init.d/lightdm stop' or go to runlevel 3 with 'init 3' or boot to text-only.
Start xvfb with the command

Code:
  `Xvfb`

Use the following script as /usr/local/bin/vncserv on the server.

Code:
  `#!/usr/bin/env bash
  # vncserv
  if [[ $DISPLAY ]]; then
  # #gdm3 in squeeze
  # authfile=$(ps ax |grep auth | awk '/gdm3/ { print $13 }')
  # #lightdm in wheezy
  authfile=$(ps ax |grep auth | awk '/lightdm/ { print $8 }')
  x11vnc -auth $authfile -localhost -display :0
  else
  x11vnc -create -env FD_PROG=/usr/bin/xfce4-session \
  -env X11VNC_FINDDISPLAY_ALWAYS_FAILS=1 \
  -env X11VNC_CREATE_GEOM=${1:-1024x768x16} \
  -gone 'killall Xvfb' \
  -bg -nopw
  fi
  exit 0`

Connect from the client (as user) with

Code:
  `vncssh [email protected]
  `

nadir

- nadir
- Posts: 1160
- Joined: Wed Mar 09, 2011 4:18 am
- Location: here

## Re: x11vnc

Thu Jan 24, 2013 5:47 am

Mhhh... for me that works automatic (without ssh though).
I ssh to raspberry.
I run:
tightvnc-server
and no X is running on the raspberry.
I connect from the client with remmina.
If doing "env" from remmina, i get a $DISPLAY, if doing that from ssh, i don't get such.
If i ps and grep for X, i get: 26861 pts/0 S 0:08 Xtightvnc :1 -desktop X -auth ~.Xauthority
I looked at the raspberry wiki, if there are settings which make that automatic, but i can't find any info:
http://elinux.org/index.php?search=VNC& ... l%3ASearch
I looked in inittab and such, but can't find any settings there neither.
I do remember that in the past i never could connect, as the user had to confirm that i am allowed to connect.
fsmithred

- fsmithred
- Posts: 2101
- Joined: Wed Mar 09, 2011 9:13 pm

## Re: x11vnc

Fri Jan 25, 2013 10:58 am

I haven't figured out a way to use the gui remotely, so you don't need someone sitting at the computer to allow you to connect. Instead, you have to connect to the server with ssh and start x11vnc, then run the viewer on the client.
Changing vncserv to test for the authfile works better than testing for $DISPLAY - now it works if the server is sitting at the graphical login screen (xserver running but nobobdy logged in.)
Summary:
If the user is logged in on the remote server, do (on the client):
vncssh [email protected]
If the xserver is running but user is not logged in, do:
vncssh [email protected]
If no xserver is running and xvfb is installed on the server, do:
vncssh [email protected]
One big problem with these scripts is if the display number changes. In that case, you need to run the commands manually. You may also need to kill running instances of x11vnc and/or these scripts on the server. I've had a lot of trouble with this when testing.

Code:
  `#!/usr/bin/env bash
  # vncserv
  # #gdm3 in squeeze
  # authfile=$(ps ax |grep auth | awk '/gdm3/ { print $13 }')
  # #lightdm in wheezy
  authfile=$(ps ax |grep auth | awk '/lightdm/ { print $8 }')
  # Test for authfile instead of DISPLAY, because DISPLAY will be null
  # when lightdm is running and no one is logged in.
  if [[ -n $authfile ]] ; then
  x11vnc -auth $authfile -localhost -display :0
  else
  x11vnc -create -env FD_PROG=/usr/bin/xfce4-session \
  -env X11VNC_FINDDISPLAY_ALWAYS_FAILS=1 \
  -env X11VNC_CREATE_GEOM=${1:-1024x768x16} \
  -gone 'killall Xvfb' \
  -bg -nopw
  fi
  exit 0
  `

nadir

- nadir
- Posts: 1160
- Joined: Wed Mar 09, 2011 4:18 am
- Location: here

## Re: x11vnc

Sat Feb 02, 2013 1:36 pm

Like said above: i barely do vnc. I only test it now and then, am happy if it works, but the got no more interest.
Today i wanted to vnc from raspberry to raspberry.
As it is very low specs i wanted to check if there is another client but remmina (which didn't work last time i did that).
I did apt-cache search vnc, couldn't find anything, went here and found xtightvncviewer (and installed it).
That is very fast. It works. It is nearly as if i were sitting in front of it.
I am amazed.
btw: I still couldn't figure out why for me xtightvnc offers a gui-session remote (however i do it does not matter, starting xtightvncserver will give me a gui if i vnc-connect).
fsmithred

- fsmithred
- Posts: 2101
- Joined: Wed Mar 09, 2011 9:13 pm

## Re: x11vnc

Sun Feb 03, 2013 1:33 pm

> nadir wrote:btw: I still couldn't figure out why for me xtightvnc offers a gui-session remote (however i do it does not matter, starting xtightvncserver will give me a gui if i vnc-connect).

I'm not sure I understand what you mean. Is there an xserver running on the server?
nadir

- nadir
- Posts: 1160
- Joined: Wed Mar 09, 2011 4:18 am
- Location: here

## Re: x11vnc

Sun Feb 03, 2013 2:40 pm

No, there is no xserver running.
I ssh
i "tightvncserver"
i exit ssh and connect with a vnc client to a gui (xfce in this case, not gdm or such, not running at all).
Sorry, i can't explain that clear, because it is voodoo to me.
nadir

- nadir
- Posts: 1160
- Joined: Wed Mar 09, 2011 4:18 am
- Location: here

## Re: x11vnc

Tue Feb 05, 2013 3:22 am

I installed refracta. Then read the release notes. Then wanted to give it a try.
After i figured out that i need ligthdm and a different vnc-server installed,
i tried to get it sorted for tightvncserver.
What works is this:
ssh server-name
tightvncserver
exit
ssh -f -N -L 5901:localhost:5901 server-name
vncviewer (then localhost:1 and password).
Now i got a gui session.
server-name is from ~/.ssh/config
This is ~/.vnc/xstartup:

Code:
  `#!/bin/sh
  xrdb $HOME/.Xresources
  xsetroot -solid grey
  #x-terminal-emulator -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
  #x-window-manager &
  # Fix to make GNOME work
  export XKL_XMODMAP_DISABLE=1
  <skip-slash>etc/X11/Xsession
  `

What i couldn't get working is to start tightvncserver with an ssh command, like
ssh server-name "tightvncserver"
Authentication problem. I looked at the scripts, but couldn't understand.
I will soon install what i need to try the scripts too. All that is-logged-in, is-not-logged-in is a bit confusing to me.
Post a reply
Jump to:

Powered by phpBB © phpBB Group.

phpBB Mobile / SEO by Artodia.