X tips

From YobiWiki
Revision as of 21:32, 24 November 2010 by <bdi>PhilippeTeuwen</bdi> (talk | contribs) (Reverted edits by Etegohy (Talk) to last revision by PhilippeTeuwen)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Converted with HTML::WikiConverter::MediaWiki from my old phpwiki site


X

Si la souris réagit très bizarrement sous X et que le problème disparaît lorsqu'on désactive GPM, essayer ceci: Empêcher GPM de fonctionner avec le X (d'où le conflit) et mettre "repeat_type=" dans /etc/gpm.conf

Remote X

La façon la plus sûre de se connecter à un serveur X distant est via ssh et l'option -Y, et ce. même depuis cygwin:


xinit /usr/bin/xterm -e ssh -Y user@remotehost /etc/X11/Xsession

Remarques:

  • l'option -Y de ssh est relativement récente donc veillez à utiliser la dernière version de ssh, les anciennes ne supportant que l'option -X qui est un peu moins sécurisée (le risque étant que qqn ayant des droits administrateur sur le serveur distant puisse remonter le tunnel ssh, "sniffer" et interagir avec la session X locale!!)
    Pour ceux que ça intéresse, voici un bon article qui explique les faiblesses du ssh -X ainsi qu'une demo
    Apparemment cygwin est incapable d'utiliser correctement cette nouvelle option et l'attaque similaire à celle sur un ssh -X est effective mais bon, en général on n'utilise pas d'applications locales X en même temps que la session distante lorsqu'on est sur une machine Windows...
  • si vous voyez apparaître un
    Warning: No xauth data; using fake authentication data for X11 forwarding.
    alors il vous faut créer un mcookie comme suit:
    xauth add $(echo "${DISPLAY}" | sed 's/.*\(:.*\)/\1/') . $(mcookie)
    et avec un ssh -v -Y vous devriez voir apparaître un:
    debug1: Requesting X11 forwarding with authentication spoofing
  • si vous travaillez à (grande) distance c.-à-d. via modem, vous avez tout intérêt à activer la compression dans ssh en ajoutant l'option -C, cela comprimera toutes les données y compris le X11 et les éventuelles connections TCP/IP.
    xinit /usr/bin/xterm -e ssh -Y -C user@remotehost /etc/X11/Xsession
  • en cas de problème, procéder par étapes:
    • xinit /usr/bin/xterm
    • Dans le xterm: ssh -Y user@remotehost
    • Dans le xterm, une fois sur la machine distante: /etc/X11/Xsession
  • lors de la saisie du mot de passe, vous vous trouvez avec une fenêtre xterm mais sans gestionnaire de fenêtre, il est donc nécessaire pour activer la fenêtre xterm de positionner le curseur de la souris dessus (le fameux mouse focus des vieux Unix)
  • pour lancer la console locale, cela peut-être /usr/bin/xterm ou /usr/X11R6/bin/xterm, essayez d'identifier le chemin correct avec "which xterm".
  • pour lancer le gestionnaire de fenêtre distant, c'est /etc/X11/Xsession sur Debian et /etc/X11/xdm/Xsession sur la RedHat, pour les autres distributions je ne sais pas (il y a toujours bien "twm" mais c'est assez primitif!)
  • s'il ne s'agit que de lancer une seule application distante ou l'autre, il est plus sage de lancer alors le gestionnaire de fenêtres local puis, dans un xterm, utiliser ssh pour lancer soit un xterm, soit directement le programme désiré:
    ssh -Y user@remotehost emacs

X11 à la GNU Screen

Essais:

  • xmove ftp
  • tightvnc
  • guievict
  • freenx vnc
    • freeNX is a remote desktop protocol, like VNC. Unlike VNC, FreeNX compresses at the X protocol level, giving it a much better experience over low-bandwidth (and high bandwidth) line
    • deb http://kanotix.com/files/debian/ ./
    • apt-get install freenx.
    • nxsetup

Cool "xinerama" between different computers

Between 2 linux boxes

  • x2x (from X to X server)

Between a linux (the one with the keyboard/mouse) and a windows

  • Install a VNC server on the Windows box, e.g. WinVNC
  • On the linux box: x2vnc (from X to VNC server)
    • Example: x2vnc -west (if the Windows screen is on your left) -wheelhack (if the wheel doesn't work properly) -resurface -noblank (pour éviter la mise en veille) -passwd $HOME/.vncpasswd ww.xx.yy.zz:0

Between a windows desktop (the one with the keyboard/mouse) and a linux laptop

  • Install a VNC server on the Windows box, e.g. x11vnc (for VNC server on Linux we need here a VNC server which uses your current X11 session, so vncserver doesn't suit)
    • There is also x0rfbserver but looks there are probs with this one, I didn't try myself
    • x11vnc has moreover a nice option for a smoother interaction with x2vnc to disable all the screen handling:
      x11vnc -nofb
    • I'm using intl qwerty us on both sides and I had to add option -nomodtweak otherwise some shifted chars didn't work properly (?, :, etc)
      And to have dead keys working properly I has to fix the options of Win2VNC to: enable Send dead key KeySym but disable Use Unicode KeySym
      Now it's ok except the "5" of the numeric keyboard of the windows box doesn't work on the linux box
  • On the windows box: Win2VNC (from Windows to VNC server)
    BTW it's easier if the Numlock is set on the linux laptop otherwise there is an invert toggle between windows and linux
  • to disable DPMS and use plain blanking instead on the linux box (DPMS blanking cannot be exited remotely):
    • xset -dpms
    • xset s 600

Between a windows desktop (the one with the keyboard/mouse) and a linux laptop: Variant

  • Win2VNC will be listening for connections
    • win2vnc.exe -listen 5500
  • and x11vnc will connect to the windows box:
    • x11vnc -nofb -nomodtweak -connect ww.xx.yy.zz
  • to find automatically the windows IP, you can do it based on its netbios name:
    • NAME=windows_machine_name
      IP=$(nmblookup $NAME|gawk '/^[0-9]+\./{print $1}')
      x11vnc -nofb -nomodtweak -connect $IP

Synergy2

See also http://synergy2.sourceforge.net/

  • Debian: apt-get install synergy
  • Windows: check on the web page otherwise try download page or directly Belnet mirror
  • With SSH tunneling:
    • install sshd on windows
    • synergy on windows: server/tell screen mercure with win on the left and win with mercure on the right/options advanced: interface loopback
    • on the linux client:
      ssh -f -N -L 24800:localhost:24800 Administrator@$IP
      synergyc localhost
  • Advantages over x2vnc:
    • copy/paste is bidirectional :-)
    • better behaviour of num lock
  • International keyboard!
    • Attention: with x2vnc both sides were with international US keyboards but with synergy, the linux client must be set to normal US, the windows server sends already the full formed char.

VNC viewer via SSH

Installation under Windows

  • ...
  • Give ssh id_rsa.pub to the gateway vnc account
  • while :;do sleep 1; ssh -R5800:localhost:5800 -R5900:localhost:5900 -N vnc@gateway; done

Installation of the Linux client

  • apt-get install xvncviewer
  • Give ssh id_rsa.pub to the gateway vnc account
  • vncpasswd /.ssh/vncpw
    • Enter the Windows VNC server password
  • To launch a second X session with the VNC client:
    • xinit /usr/bin/vncviewer -fullscreen -passwd $HOME"/.ssh/vncpw" -via vnc@gateway 127.0.0.1:0 -- :1
  • To start the VNC client from the current X session:
    • /usr/bin/vncviewer -passwd $HOME"/.ssh/vncpw" -via vnc@gateway 127.0.0.1:0
  • Usage: Press F8

Make it robust under Windows

You can make the invokation a service so, if you took care to tell to the BIOS to recover in case of power failure, the service will start prior to any login

 * instsrv MyVncTunnel "C:\Program Files\Resource Pro Kit\Srvany.exe"
 * Go to Control Panel -> Admin Tools -> Services -> Properties of MyVncTunnel
   and let it run under your ID instead of SYSTEM if needed
 * Edit Registry and locate HKLM\System\CurrentControlSet\Services\MyVncTunnel
 * Create the new key Parameters
 * Create the new string value Application
   with as value the full path to your app or script (.bat is ok)
 * The script could be as simple as
     sh -c "while :;do sleep 1; ssh -R5800:localhost:5800 -R5900:localhost:5900 -N vnc@gateway; done"

Remote Desktop

You can use directly the Remote Desktop stuff pre-installed on Windows XP.

  • Activate it under System properties -> Remote -> Remote Desktop -> Allow users to connect remotely
  • apt-get install rdesktop
  • rdesktop <IP>
  • That's it!
    See man rdesktop for more features like bandwith tricks and amazing audio redirection/disk sharing/printer sharing stuffs!
    • For LAN:
      rdesktop -u <user> -f -x lan -a 24 -r disk:shared=/mnt/shared_winxp <IP>
    • For modem and via ssh tunneling:
      rdesktop -u <user> -x modem -z -C -P -p - -f -r disk:shared=/mnt/shared_winxp localhost
    • When drive was shared as such, you can open it from the pseudo-computer tsclient, here that would be \\tsclient\shared
    • There is a nice front-end to parameter rdesktop if you prefer: apt-get install tsclient
    • RDP is also supported by the KDE Remote Desktop Client
      apt-get install krdc
      krdc is an KDE graphical client for the rfb Protocol, used by VNC, and if rdesktop is installed, krdc can connect to Windows Terminal Servers using RDP.
  • You can use it also through SSH tunnels just as for vnc, the unique port to forward is the TCP port 3389