Score:0

Can't run SSH server on WSL Ubuntu after starting Systemd

mw flag

I have Windows 10 Home w/o Hyper-V and Ubuntu running on WSL. In Ubuntu, I had was able to run SSH server with sudo service ssh start.

After that I decided to install k9s from the Snap Store, but Ubuntu on WSL doesn't have Snap Store. To resolve this tried this steps here:

sudo apt-get update && sudo apt-get install -yqq daemonize dbus-user-session fontconfig
sudo daemonize /usr/bin/unshare --fork --pid --mount-proc /lib/systemd/systemd --system-unit=basic.target
exec sudo nsenter -t $(pidof systemd) -a su - $LOGNAME

... but this was unsuccessful. I received some error about hypervisor.

The main problem is that now, when I try to run SSH server with the same command as above, I get the error:

Failed to start ssh.service: transport endpoint is not connected

Please help me recover Ubuntu to a state where I can run SSH again.

Score:0
vn flag

Failed to start ssh.service: transport endpoint is not connected.

You've probably already solved this part, at least, by now. This message is because, once you start Systemd in its own namespace, it's running, whether you are in the namespace or not. This means that the service command is now mapped to systemctl, even though systemctl isn't accessible.

As I mention in this answer:

  • I don't recommend running Systemd this way unless you really know what it is doing behind the scenes, or can figure it out.
  • And after proving to yourself that it's possible, I recommend exiting all WSL instances completely, then doing wsl --shutdown. Otherwise, you will have some things be "broken" until you do.

Once restarting after a wsl --shutdown, Systemd should no longer be running in a separate namespace, and the service command should be back to "normal" (as far as WSL2 is concerned).

After that I decided to install k9s from snap store. but ubuntu doesnt have snap store to resolve this I have used this steps

If your system is able to be upgraded to Windows 11, official support for Systemd is now in beta. See this answer for details on how to enable. The Snap store can be used with this method.

Alex Blade avatar
mw flag
thank you, its helped
Alex Blade avatar
mw flag
so if I understand correct on win10 is not possible to install k9s from snap, am I right?
NotTheDr01ds avatar
vn flag
@AlexBlade Well, it seems *possible*, at least, as others have done it. Personally I would recommend Docker Desktop, which comes with a single-node K8s installation, if that meets your needs. See my [thoughts on the topic](https://stackoverflow.com/a/70936753/11810933). If you really do want to install using Snap, see my [Systemd answer](https://askubuntu.com/a/1379567/1165986) for alternative methods that are more robust under Windows 10 like Genie and Distrod.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.