The .xauthority file is not does not exist;hence via local ssh connection display from the GCP compute engine not working
Asked Answered
T

4

14

explaining all that has been tried and double checked.

Set up on local windows machine:

  1. Xming installed and running.

  2. in ssh_config ForwardX11 is set to yes.

  3. In VS code remote connection config the the Forward X11 is set to yes.

Set up on GCP compute engine with Debian / Linux 9 and 1 GPU[free tier]:

  1. xauth is installed.

  2. In the sshd_config file below is set: X11Forwarding yes X11DisplayOffset 10 X11UseLocalhost no

The sshserver has be restarted to ensure below setting are read . from local workstation I fire gcloud compute ssh --ssh-flag="-X" tensorflow-2-vm(instance name) and the response is :

/usr/bin/xauth: file /home/user/.Xauthority does not exist,

So, I attempted to perform the below on the remote compute engine with instance name - tensorflow-2-vm and user trapti_kalra:

trapti_kalra@tensorflow-2-vm:~$ xauth list
xauth:  file /home/trapti_kalra/.Xauthority does not exist
trapti_kalra@tensorflow-2-vm:~$ mv .Xauthority old.Xauthority
mv: cannot stat '.Xauthority': No such file or directory
trapti_kalra@tensorflow-2-vm:~$ touch ~/.Xauthority
trapti_kalra@tensorflow-2-vm:~$ xauth generate :0 . trusted 
xauth: (argv):1:  unable to open display ":0".
trapti_kalra@tensorflow-2-vm:~$ sudo xauth generate :0 . trusted 
xauth:  file /root/.Xauthority does not exist
xauth: (argv):1:  unable to open display ":0".

so, looks like something is missing, any help will be appreciated. This was working with a EC2 server before I moved to GCP.

Threw answered 4/5, 2020 at 11:1 Comment(2)
This sounds more like a xauth configuration issue. I found one similar discussion thread where xauth wes not creating .Xauthority file. See if that help you.Furie
I was not able to solve this. I think it has to do compatibility in VS Code on local and the VM server on GCP. While X11 is enabled both sides(server and local) the there is a consistent error coming . Otherwise ssh and remote development is working fine- what does not work is the X server is not recognize.Threw
P
35

Create a new file: touch ~/.Xauthority

Log out and back in again with your ssh session. (I'm using MobaXterm) Then it writes the needed.

Plasmosome answered 25/11, 2020 at 9:25 Comment(1)
I confirm this WORKS :)Sudanic
S
8

You logged into your Linux server over ssh and got the following error;

.Xauthority does not exist

Solution : Let's go into the /etc/ssh/sshd_config file and remove the # sign at the beginning of the 3 lines below

X11Forwarding yes
X11DisplayOffset 10
X11UseLocalhost yes

Then systemctl restart sshd

Login again and you will not get the error.

Sleepyhead answered 24/3, 2022 at 8:36 Comment(0)
O
1

There are many solutions to this problem, it can also depend on what machine you originate from. If you come from a Linux box, enabling sshd config options like:

X11Forwarding yes

could be enough.

When you use a Macbook however the scenario is different. In that case, you need to install xQuartz with brew:

brew install xquartz

And after this start it: xQuartz &

After this is done the xQuartz logo appears in your bar and you can right-click the icon and start the terminal from the Applications menu. After you perform this you can run the following:

echo $DISPLAY from this terminal. This should give you the output:

    :0

When you have another terminal such as iTerm, you can export this value in another terminal with export DISPLAY=:0 As long as xQuartz is still running the other terminal should be able to continue to use xQuartz.

After this you can SSH into the remote machine and check if the display variable is set:

$: ssh -Y anldisr@my-remote-machine
$: echo $DISPLAY
localhost:11.0

It took me a hour to figure this out, hope it helps someone. :)

Odalisque answered 22/11, 2022 at 21:43 Comment(0)
R
0

I encountered a similar issue when I attempted to add a new user to a remote machine, but forgot to grant the user sudo privileges during the creation process.

You can resolve the problem by logging in as the root user or a user with sudo privileges and assigning sudo privileges to the new user using the command:

sudo usermod -aG sudo [newUser]

To ensure the changes took effect, log out of the new user account and log back in via SSH to the server.

Remount answered 8/6, 2022 at 8:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.