Skip to content

No Windows interop when connecting to WSL genie via ssh

Santiago Saavedra edited this page May 20, 2021 · 2 revisions

This problem isn't actually a genie issue, it's because sshd doesn't pass on environment variables to sessions it starts, so when you log in via ssh, various important variables are missing. If you look at it with env, you should see, for example, that the PATH doesn't include the Windows PATH, and most importantly, the WSL_INTEROP variable is missing, so WSL can't find the proper socket to talk to to make interop work.

But all is not lost. To get these back, we detect when we're running under ssh and can then export them from the systemd environment block and import them in the ssh session. Put this at the top of your profile:

if [[ -v SSH_CLIENT ]]; then
  source <(systemctl show-environment | awk '{print "export "$0}')
fi

And you should find that subsequent logins over ssh handle interop correctly.