13

I have successfully set up OpenSSH server and client running through the Windows 10 optional features section.
Whenever I am trying to login into the server, I am asked for a password. I have only configured a single password for my Windows 10 PC, and that is the password of my Microsoft account. But, the server denies access with that password. I haven't set up any password for the SSH server yet.
What is the default password for the server?

Here are the contents of the sshd_config file in %PROGRAMDATA%\ssh\ folder :

# This is the sshd server system-wide configuration file.  See
# sshd_config(5) for more information.

# The strategy used for options in the default sshd_config shipped with
# OpenSSH is to specify options with their default value where
# possible, but leave them commented.  Uncommented options override the
# default value.

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

#HostKey __PROGRAMDATA__/ssh/ssh_host_rsa_key
#HostKey __PROGRAMDATA__/ssh/ssh_host_dsa_key
#HostKey __PROGRAMDATA__/ssh/ssh_host_ecdsa_key
#HostKey __PROGRAMDATA__/ssh/ssh_host_ed25519_key

# Ciphers and keying
#RekeyLimit default none

# Logging
#SyslogFacility AUTH
#LogLevel INFO

# Authentication:

#LoginGraceTime 2m
#PermitRootLogin prohibit-password
#StrictModes yes
#MaxAuthTries 6
#MaxSessions 10

#PubkeyAuthentication yes

# The default is to check both .ssh/authorized_keys and .ssh/authorized_keys2
# but this is overridden so installations will only check .ssh/authorized_keys
AuthorizedKeysFile  .ssh/authorized_keys

#AuthorizedPrincipalsFile none

# For this to work you will also need host keys in %programData%/ssh/ssh_known_hosts
#HostbasedAuthentication no
# Change to yes if you don't trust ~/.ssh/known_hosts for
# HostbasedAuthentication
#IgnoreUserKnownHosts no
# Don't read the user's ~/.rhosts and ~/.shosts files
#IgnoreRhosts yes

# To disable tunneled clear text passwords, change to no here!
#PasswordAuthentication yes
#PermitEmptyPasswords no

#AllowAgentForwarding yes
#AllowTcpForwarding yes
#GatewayPorts no
#PermitTTY yes
#PrintMotd yes
#PrintLastLog yes
#TCPKeepAlive yes
#UseLogin no
#PermitUserEnvironment no
#ClientAliveInterval 0
#ClientAliveCountMax 3
#UseDNS no
#PidFile /var/run/sshd.pid
#MaxStartups 10:30:100
#PermitTunnel no
#ChrootDirectory none
#VersionAddendum none

# no default banner path
#Banner none

# override default of no subsystems
Subsystem   sftp    sftp-server.exe

# Example of overriding settings on a per-user basis
#Match User anoncvs
#   AllowTcpForwarding no
#   PermitTTY no
#   ForceCommand cvs server

This is the output of Get-NetFirewallRule -Name *ssh* :

Name                  : OpenSSH-Server-In-TCP
DisplayName           : OpenSSH SSH Server (sshd)
Description           : Inbound rule for OpenSSH SSH Server (sshd)
DisplayGroup          : OpenSSH Server
Group                 : OpenSSH Server
Enabled               : True
Profile               : Any
Platform              : {}
Direction             : Inbound
Action                : Allow
EdgeTraversalPolicy   : Block
LooseSourceMapping    : False
LocalOnlyMapping      : False
Owner                 :
PrimaryStatus         : OK
Status                : The rule was parsed successfully from the store. (65536)
EnforcementStatus     : NotApplicable
PolicyStoreSource     : PersistentStore
PolicyStoreSourceType : Local

Name                  : SshProxy-Service
DisplayName           : SshProxy-Service-Private
Description           : SSH Server Proxy Service
DisplayGroup          : Ssh Server
Group                 : Ssh Server
Enabled               : True
Profile               : Private
Platform              : {}
Direction             : Inbound
Action                : Allow
EdgeTraversalPolicy   : Block
LooseSourceMapping    : False
LocalOnlyMapping      : False
Owner                 :
PrimaryStatus         : OK
Status                : The rule was parsed successfully from the store. (65536)
EnforcementStatus     : NotApplicable
PolicyStoreSource     : PersistentStore
PolicyStoreSourceType : Local

Name                  : SshProxy-Service-Domain
DisplayName           : SshProxy-Service-Domain
Description           : SSH Server Proxy Service
DisplayGroup          : Ssh Server
Group                 : Ssh Server
Enabled               : True
Profile               : Domain
Platform              : {}
Direction             : Inbound
Action                : Allow
EdgeTraversalPolicy   : Block
LooseSourceMapping    : False
LocalOnlyMapping      : False
Owner                 :
PrimaryStatus         : OK
Status                : The rule was parsed successfully from the store. (65536)
EnforcementStatus     : NotApplicable
PolicyStoreSource     : PersistentStore
PolicyStoreSourceType : Local

Output of [System.Security.Principal.WindowsIdentity]::GetCurrent().Name :

<my_name>\USER
2
  • 2
    There isn't a default password. You can only access the machine using an account that exists on the machine with OpenSSH Server installed on it.
    – Ramhound
    Commented Feb 3, 2020 at 18:12
  • 1
    SSHing via a password isn't that secure - generate a PKI key pair via ssh-keygen, encrypt the private key with a passphrase, add it to your user's ~\.ssh\authorized_keys, and use it to login.
    – JW0914
    Commented Sep 6, 2021 at 17:03

5 Answers 5

7

I haven't set up any password for the SSH server yet. What is the default password for the server?

There isn't one.

Whenever I am trying to login into the server, I am asked for a password. I have only configured a single password for my Windows 10 PC, and that is the password of my Microsoft account. But, the server denies access with that password.

You are attempting to connect with the incorrect username. You should be using ssh Machine_Name\Username@localhost to connect to the server.

Why do I need to give the \USER part?

You have to explicitly indicate which username you want to use in order to connect to the OpenSSH Server. You also indicated you used the syntax, ssh <my_name>@localhost, which indicates the username was the name of your machine instead of your actual username.

Since <my_name> isn't an actual username on the machine, the password authentication was failing, you actually have to use Username and explicitly indicate it's on the machine Machine_Name\Username.

The output of [System.Security.Principal.WindowsIdentity]::GetCurrent().Name will indicate what should be used.

0
5

Another reason why it may not accept a valid username and password is if the configured shell is wrong.

You can check which it is with

reg query HKLM\SOFTWARE\OpenSSH /v DefaultShell

To set it to Powershell, if you have it in the default directory:

reg add HKLM\SOFTWARE\OpenSSH /v DefaultShell /d C:\Windows\system32\WindowsPowerShell\v1.0\powershell.exe
5
  • 1
    This was my problem, but I actually need pwsh.exe to be the default shell as gitlab requests for my VM. Do you know a way? Commented Aug 6, 2022 at 21:45
  • @GuerlandoOCs: Have you tried the "reg add ..." command with the path to your "pwsh.exe" instead of the path to powershell.exe? (using quotes if your path contains spaces of course)
    – mivk
    Commented Aug 6, 2022 at 22:05
  • you mean New-ItemProperty -Path "HKLM:\SOFTWARE\OpenSSH" -Name DefaultShell -Value "$PSHOME\pwsh.exe" -PropertyType String -Force right? That's what I did, as docs.gitlab.com/runner/executors/… says Commented Aug 6, 2022 at 22:07
  • Maybe you need to check the value of your $PSHOME variable? Is it the path to where you installed pwsh.exe?
    – mivk
    Commented Aug 6, 2022 at 22:11
  • This was my issue as well! Needs to be upvoted
    – Nomnom
    Commented Aug 19, 2022 at 16:38
5
  1. Write whoami in the cmd, It will give you a text, copy the whole text, by whole I mean the whole. For this example, let's say I got nick\hp as my output.

  2. Now in cmd, type ssh nick\hp@localhost, and press Enter.

  3. It is going to ask for a password, enter the password of your Microsoft account here. And you will successfully ssh in.

0

I opened power shell with Admin rights.

Then followed this to Install OpenSSH using PowerShell

The next step is to Start and configure OpenSSH Server

Now run the following command to get the user name

[System.Security.Principal.WindowsIdentity]::GetCurrent().Name

I got MYMACHINENAME\AdminUser. Here MYMACHINENAME is the device or machine name of my windows 10 machine. AdminUser is the Administrator user name by which I launched the power shell in Admin mode.

Now run the command ssh MYMACHINENAME\AdminUser@localhost. You will be asked for a password. Give your AdminUser password.

Now you should be in as explained here.

-1

I had a similar issue. ssh login was working normally until one day. Not sure what exactly happened. I might have tried to share a windows folder via samba and thereby screw up some openssh settings. Anyways here the solution:

Create a new windows user

That's it. I can login normally with the new account. Seems like the ssh password for the old account changed without me doing anything.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .