0

I made a script (name : "recordVideo") that launch recordMyDesktop to capture a window. this script is on a computer-1. With computer-2 I want to launch the script with ssh. Here is my script on computer-1 :

#!/bin/sh
cd /home/ivtuser/Bureau/
recordmydesktop --no-sound --delay 3 --windowid &(xwininfo -name "NAME_OF_WINDOW" | sed -n 's/.*Window id: \([0-9a-fx]\+\).*/\1/p')

I have set my parameters for ssh in ssh_config :

ForwardX11 yes

and sshd_config :

X11Forwarding yes

And Xauth is installed on my PC. I tried to launch in local mode for my test with ssh with this command :

$ ssh -X localhost
password: XXX
$ recordVideo

And here is my problem, recordmydesktop stop with the response :

X Error: BadAccess (attempt to access private resource denied)

How can I fix this. I'm lost Thanks

tutur29
  • 105
  • 1
  • 10
  • does the same script work from computer 1, without ssh? If it doesn't, then its a user permission issue, most probably the user you are sshing into doesn't have adequate permissions on the device. – Anshul Goyal Jul 22 '14 at 09:39
  • are you using with script with proper superuser privilages... – shiv garg Jul 22 '14 at 09:45
  • what happens when you run `ssh -X computer-1 xterm` or `ssh -X computer-1 xdpyinfo`? – Aaron Digulla Jul 22 '14 at 09:50
  • @mu & shiv garg : I can run my script on the computer without the superuser privilages and it works. I have the problem only when using ssh. – tutur29 Jul 22 '14 at 09:56
  • @Aaron Digulla : for the moment I tested only with one computer, running ssh in localhost. I don't have yet the 2 computers where it will be installed. – tutur29 Jul 22 '14 at 09:58
  • This might fail when the user that started X and the user who runs the script are different. X tries to make it hard for people to spy on a remote desktop. – Aaron Digulla Jul 22 '14 at 10:00

1 Answers1

0

There are two solutions:

  1. SUID
  2. SSH as root

The first one is hard to get right without exposing your computer to security risks.

The second solution uses ssh root@computer-1 /path/to/recordVideo to log in as root and run the script as root.

Also make sure the $DISPLAY variable is correctly set. ssh -X should do that for you or you need to specify the option -display LOCAL:0.0 to all commands which connect to the X server (where LOCAL is the IP address or DNS name of the computer that you're sitting in front of).

Aaron Digulla
  • 321,842
  • 108
  • 597
  • 820
  • I tried ssh in root mode, and I have exactly the same issue. – tutur29 Jul 22 '14 at 10:02
  • Also make sure that `$DISPLAY` is set correctly on the remote side. – Aaron Digulla Jul 22 '14 at 10:10
  • I tried ForwardX11Trusted yes : same problem I don't understand your "$DISPLAY" thing. How can I check it ? – tutur29 Jul 22 '14 at 10:55
  • The `$DISPLAY` variable tells the X client to which server it should talk to. In your case, you want to connect to the X server running on computer-2. But `ssh` prepares everything so that the client connects to X on the computer where you run `ssh`. You really need two computers to test this. How about setting up a virtual machine? – Aaron Digulla Jul 22 '14 at 11:11
  • Ok, I'll test it as soon as possible with the two computers. I didn't think about a VM, if it's simple to set up, I should try it. thank you, I'll let you know the results. – tutur29 Jul 22 '14 at 11:47
  • You were wright with your last answer, I tested with two computers, adding to my script the DISPLAY variable and it works. `recordmydesktop --no-sound --delay 3 --windowid &(xwininfo -name "NAME_OF_WINDOW" -display NAME_COMPUTER:0.0 | sed -n 's/.*Window id: \([0-9a-fx]\+\).*/\1/p') --display NAME_COMPUTER:0.0` – tutur29 Aug 21 '14 at 07:26