Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 959
Trapti Kalra Avatar asked Dec 01 '25 10:12

Trapti Kalra


2 Answers

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.

like image 143
Karel Avatar answered Dec 02 '25 23:12

Karel


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.

like image 44
Hasan Yilmaz Avatar answered Dec 03 '25 01:12

Hasan Yilmaz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!