DexterInd / BrickPi3

The BrickPi3 connects LEGO Mindstorms with the Raspberry Pi.
https://www.dexterindustries.com/brickpi/
Other
122 stars 79 forks source link

Issue with x11-forwarding #71

Closed BrunnerLivio closed 6 years ago

BrunnerLivio commented 7 years ago

When I try to connect to the RaspberryPI with the BrickPI image from you on it, using ssh x.x.x.x -Y, and run scratch, the display won't get forwarded.

I get the error:

...
X11 connection rejected because of wrong authentication
xhost: unable to open display "localhost:10.0"
BrickPi3
X11 connection rejected because of wrong authentication
Unable to access the X Display, is $DISPLAY set properly?
...

After some investigation, we fixed this by editing your scratch-wrapper script in /usr/bin/scratch, by adding -E parameter to the sudo command when starting click_scratch.py so the environment variables get transfered. So the command will be sudo -E python $SCRATCH_PATH/click_scratch.py.

I did not find this script in this repository, so it might be in another? Can you send me the link and I'll create a pull request

@erickeller

CleoQc commented 7 years ago

The file is to be found here: https://github.com/DexterInd/Raspbian_For_Robots/tree/master/Scratch_GUI

Can you tell me more about your setup? I'm curious to know as you seem to be taking a path that we didn't plan for. Thanks!

DexterInd commented 7 years ago

Hey @BrunnerLivio first thanks for offering a pr? We're a little confused by what you're trying to accomplish here: are you trying to initiate Scratch from your ssh connection, and have it open up in LXE on the Pi?

erickeller commented 7 years ago

Basically login in from another PC with X forwarding requires the DISPLAY variable to be set accordingly. When calling scratch this DISPLAY variable will not be set in the sub shell environment meaning you get the error described by Livio.

man sudo
...
     -E, --preserve-env
                 Indicates to the security policy that the user
                 wishes to preserve their existing environment
                 variables.  The security policy may return an
                 error if the user does not have permission to
                 preserve the environment.

This will ensure the DISPLAY environment variable will be available and you will be able to use your application remotely.

@BrunnerLivio will propose the quick fix in a PR.

RobertLucian commented 7 years ago

@erickeller

Can you confirm the following steps in setting up the X11 forwarding:

  1. In /etc/ssh/sshd_config you've set X11Forwarding variable to yes.
  2. Checked with which xauth command to see if xauth package is installed.
  3. Ran xhost + command on Raspberry Pi.
  4. Installed and ran Xming on the client machine.
  5. Enabled X11 in client terminal and set the address to localhost:0.
  6. Used Putty for connecting to the Raspberry Pi.

Cause these steps worked on mine.

Thanks!

erickeller commented 7 years ago

ssh -Y pi@dex01 scratch

Ensure your /etc/ssh/sshd_config on the remote has X11 forwarding enabled...

Cheers

On Mon, Jul 31, 2017, 16:41 Robert Lucian Chiriac notifications@github.com wrote:

@erickeller https://github.com/erickeller

I see what you're trying to do. Can you also tell us what steps have you followed in order to allow connecting to the X11 server?

And also, what terminal are you using on your machine?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/DexterInd/BrickPi3/issues/71#issuecomment-319087646, or mute the thread https://github.com/notifications/unsubscribe-auth/ABOw0rOii2CJuEXKMln_TdsYIDLW4QFUks5sTeeVgaJpZM4Olass .

CleoQc commented 7 years ago

Thanks @erickeller What are you setting your $DISPLAY variable to? Mine still says it's not set.

erickeller commented 7 years ago

The 1st steps look good. On your default install there is for sure xauth installed and you most probably do not need any xhost command.

As for step 4. I am not familiar with running xming on the client machine as I use a Linux client.

Maybe it makes sense to split the instructions depending on the Operation system.

Kind regards

On Mon, Jul 31, 2017, 16:49 Robert Lucian Chiriac notifications@github.com wrote:

@erickeller https://github.com/erickeller

Can you confirm the following steps in setting up for X11 forwarding:

  1. In /etc/ssh/sshd_config you've set X11Forwarding variable to yes.
  2. Checked with which xauth command to see if xauth package is installed.
  3. Ran xhost + command on Raspberry Pi.
  4. Installed and ran Xming on the client machine.
  5. Enabled X11 in client terminal and set the address to localhost:0.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/DexterInd/BrickPi3/issues/71#issuecomment-319090022, or mute the thread https://github.com/notifications/unsubscribe-auth/ABOw0nXmkVWtGZsFwUNB8GSY3zuivycKks5sTelsgaJpZM4Olass .

RobertLucian commented 7 years ago

For me, it didn't work without Xming on my client machine.

It's said that for:

@CleoQc can you also try the steps I've posted? It seems like on yours, it doesn't work yet.