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.
4
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;
Solution :
Let’s go into the /etc/ssh/sshd_config file and remove the # sign at the beginning of the 3 lines below
Then
systemctl restart sshd
Login again and you will not get the error.
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:
To ensure the changes took effect, log out of the new user account and log back in via SSH to the server.
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:
could be enough.
When you use a Macbook however the scenario is different. In that case, you need to install xQuartz with brew:
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: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:
It took me a hour to figure this out, hope it helps someone. 🙂