1

I'm trying to set up an ssh server on my windows 10 machine through WSL (I'm using WSL 1 if this makes a difference), running ubuntu.

So I followed this tutorial. Basically I installed open-ssh from the command line, and I created a new user by adding AllowUsers <yourusername> in /etc/ssh/sshd_config. I also made sure the firewall was allowing connections to port 22.

Then I went to my other laptop (the one I'm trying to ssh from), which is a mac, and typed ssh 192.168.X.X which is my windows' machine private ip (it's static btw). Both my windows machine (the ssh server), and my mac machine (the ssh client) are on the same network, which is why I'm sshing using a private ip.

For some reason I'm asked to input a password, but I don't know what password I should use. I tried my windows machine login password, as well as my WSL admin password (the one I use when executing sudo commands). Both didn't work. I'm pretty sure this is something obvious because I haven't found any solution on this online, so it must be something really stupid that doesn't even need to be asked...

I also tried ssh <yourusername>@192.168.X.X where <yourusername> is the one I added in /etc/ssh/sshd_config, but I was also required to input a password.

Edit:

I tried ssh localhost but got

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY! Someone could be eavesdropping on you right now (man-in-the-middle attack)! It is also possible that a host key has just been changed. The fingerprint for the ECDSA key sent by the remote host is SHA256:xxxxx.

Please contact your system administrator. Add correct host key in /home/user/.ssh/known_hosts to get rid of this message. Offending ECDSA key in /home/user/.ssh/known_hosts:1 remove with: ssh-keygen -f "/home/user/.ssh/known_hosts" -R "localhost" ECDSA host key for localhost has changed and you have requested strict checking. Host key verification failed.

(I put xxx instead of the fingerprint and user instead of my username for privacy). I also stopped my ssh server and closed my open port because I'm worried something bad is happening, which is really weird.

9
  • Does no one here know? I'd assume that this would be some little mistake I'm doing with setting the server, and not something difficult. Mar 11 at 18:54
  • As a first troubleshooting step, from WSL, try ssh localhost and see if you can access it there with your WSL user's password. What happens? Mar 12 at 0:02
  • Okay this is really weird. I tried ssh localhost but got Mar 12 at 0:07
  • Your comment didn't quite come through - Perhaps it was in angled brackets? Usually better to edit the new information into the question anyway, though. Mar 12 at 0:12
  • Yeah I'm sorry it was too long so I edited the post. I don't know what is happening... Mar 12 at 0:15

1 Answer 1

0

Based on the comments and chat, we determined that the Windows OpenSSH server was also running. Since it also defaults to port 22, the one that was running in WSL/Ubuntu wasn't able to bind to that port.

So when you ssh'd from the Mac to your "WSL", it was really connecting to the Windows SSH server. It was expecting the Windows username and password.

Since you had your WSL username in the Mac's ssh_config, and that username doesn't exist under Windows, it was denying all passwords. It wasn't really that the password wasn't correct as much as the username.

The solution, since this is WSL1, was fairly straightforward -- Just:

sudo vi /etc/ssh/sshd_config
# Uncomment the Port and change it to 2222 or another unused port
# Save and exit
sudo service ssh restart

And we confirmed this with ssh -p 2222 localhost.

After that, it also worked from the Mac using the proper port number.

2
  • Thank you so much!!! (can't upvote your answer due to low reputation). Mar 12 at 1:13
  • @MoonlessNightss No worries - The accept is good, and I think your upvote will take effect when you get to 20 rep. Glad I could help! Mar 12 at 1:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.