Windows 10 Ubuntu Subsystem SSHD Setup.

It is really freaking cool that they've made an ubuntu subsystem for Windows. It makes the machine worth more than just gaming and watching videos.

Unfortunately the terminal used for the bash shell leaves something to be desired.

There is, however, a really nice terminal program for Windows you can download called PuTTY. If you are reading this I will assume you know what that is.

What I Expect You Already Know

I am going to expect that you know a handful of things and will not be covering them. Perhaps later I'll make a page about them but in the mean time if you don't know any of these things you might want to google them to learn about them.

  • How to set up and use ssh keys.
  • How PuTTY or some other terminal ssh program of your choice works.
  • How to install the Ubuntu subsystem to begin with.

Installing And Setting Up The SSH Daemon

Installation

Open your Ubuntu bash shell. The following commands should install everything you need.

sudo apt-get update
sudo apt-get install openssh-server

Setting Up

By default, the sshd config is likely perfect for what you need. The following is a very trimmed down example of what you will want it to look like:

PasswordAuthentication no
ChallengeResponseAuthentication no
UsePAM yes
X11Forwarding yes
PrintMotd no
AcceptEnv LANG LC_*
Subsystem       sftp    /usr/lib/openssh/sftp-server

The important bit in this example is PasswordAuthentication no. This requires anyone connecting to have a valid ssh key.

Here are some optional config lines you may want.

Port 22  # You can set this to a non-standard port. (Advanced)
AddressFamily inet # This forces it to ignore IPV6 connections.
ListenAddress 127.0.0.1 # This tells it to only listen on localhost.

I know some people will only want to allow access on localhost which is why I added that last bit.

Starting SSHD After Every Reboot

There is likely a way to do this so that it gets run at start-up. It hasn't pained me enough to figure it all out so I just restart sshd once per reboot by hand.

Open your Ubuntu bash prompt and run the following.

sudo service ssh restart

If you see no error messages, all is probably good. If you do see error messages you probably messed up your sshd_config so give it a look-over.

Your Windows machine may have a heart attack and throw up all sorts of warnings that some nefarious process started listening on port 22.

Just approve it and allow access through the firewall.

Using SSHD

Open your favorite terminal program such as PuTTY. Set up a session to connect to server 'localhost' with your windows login. If you've set everything up correctly it will plop you into your Ubuntu setup and your life will be totally enriched.

Brief Troubleshooting

Yeah, I'm not here to really hold your hand but here's where to start looking when...

  • your terminal program says it can't connect to port 22 (or other port if you used a different port). Try restarting sshd using the command above and if that doesn't fix it try to find the logs in your bash shell and figure out why everything has gone sideways.
  • your terminal program says authentication failed. Make sure you have loaded your ssh key into your key agent. Make sure the permissions of your .ssh folder and .ssh/authorized_keys files are 700 and 600 respectively.
  • something doesn't work. You can try to contact me and ask me a question. This will work if you know me personally. If not, I will try to help but won't spend a lot of time with being your helpdesk guy. :D

Fin

Hopefully this makes your life so much better. If you have recommendations on changes I should make to this document or if you are less lazy than I and have automated the starting of sshd on boot, then, by all means, let me know and I'll update my documentation.