SSH into Bash on Ubuntu on Windows 10 – Step-by-Step Guide

bashsshwindows 10windows-10-v1607windows-subsystem-for-linux

I have Windows 10 Anniversary Edition with "Bash on Ubuntu on Windows" installed and working. I'd like to be able to SSH into this Ubuntu instance, but although I have openssh-server installed and configured (and listening on port 2200), when I try to ssh to "localhost:2200", it tells me "Server unexpectedly closed network connection".

Has anyone been able to successfully accomplish this?

enter image description here

Best Answer

I got it to work; here's how.

Uninstalled ssh-server, reinstalled it and made sure it's started with

sudo service ssh --full-restart

Make sure you turned off root access and added another user in the config file.

I was able to connect to the subsystem on 127.0.0.1:22 as expected.  I hope this will help you.

Here's a screenshot.

  1. sudo apt-get purge openssh-server
  2. sudo apt-get install openssh-server
  3. sudo nano /etc/ssh/sshd_config and disallow root login by setting PermitRootLogin no
  4. Then add a line beneath it that says:

    AllowUsers yourusername

    and make sure PasswordAuthentication is set to yes if you want to login using a password.

  5. Disable privilege separation by adding/modifying : UsePrivilegeSeparation no

  6. sudo service ssh --full-restart

  7. Connect to your Linux subsystem from Windows using a ssh client like PuTTY.

Related Question