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

explaining all that has been tried and double checked. Set up on local windows machine: Xming installed and running. in ssh_config ForwardX11 is set to yes. In VS code remote connection config the the Forward X11 is set to yes.

explaining all that has been tried and double checked.

Set up on local windows machine:

  • Xming installed and running.

  • in ssh_config ForwardX11 is set to yes.

  • 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]:

  • xauth is installed.

  • 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.

    2

    3 Answers

    Create n new file: touch ~/.Xauthority Log out and back in again with your ssh session. (I'm using MobaXterm) Then it writes the needed.

    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.

    This also happened when I added a new user to remote machine without giving the user a sudo privilege during creation.

    To resolve, I used the root user or a sudo privileged user to assign a sudo privilege to the new user. Exit the new user and ssh again into your server.

    > $ sudo usermod -aG sudo [newUser] 

    ncG1vNJzZmirpJawrLvVnqmfpJ%2Bse6S7zGiorp2jqbawutJobWptaWWDen2OrZ%2BeZaiWwrW0zqugrbFdm7atsYyiqmamn6l6pbvErGSnp6Risrm10q2fnqaTmnq3tcBmo6ibkaF6tL%2FHZpqopp6asLW1zqdknaGjpbmi

     Share!