SD Core Solo for Windows WS2.0-0

ssh access

Reaching SD Core Solo for Windows on this computer over ssh, on its own port, with your Windows account name and password.

An ssh sign-in to port 4251 lands inside SD. SD Core Solo for Windows runs an ssh server of its own on port 4251. You sign in with your Windows account name and its Windows password, as you would to any computer; then, instead of a Windows prompt, you get sd-solo, which asks for the SD account password.

ssh -p 4251 you@this-computer
you@this-computer's password:        <- your Windows password, ssh's own check
Password:                            <- SD's account password
:

Your password is not sent in clear text. ssh agrees a key exchange and a cipher with the server first, and the password travels inside that encrypted channel; the server receives it decrypted, as any ssh server does. The first time you connect, ssh shows the server's host key fingerprint: check it against C:\ProgramData\SDCoreSolo\ssh\ssh_host_ed25519_key.pub (ssh-keygen -l -f on that file), because that is what stops someone posing as your computer. The API is different: it uses SCRAM, where the server never receives the password at all.

There is no key to set up first. A key is an optional extra (below), never the only way in. The port is fixed: it is not a setting.

ssh works while nobody is signed in to the computer: the server is started when Windows starts, by its own scheduled task, and SD is started at start-up by its task.

It does not touch port 22. Port 22 is the computer's ordinary ssh port, the one the Windows OpenSSH Server service listens on and the one SD Core (the multi-user product) uses. ssh to 22 goes to whatever answers there; ssh to 4251 goes to SD Core Solo. So SD Core Solo and SD Core can be installed on one computer.

What the installer sets up#

The ssh server the sshd.exe that Microsoft's OpenSSH package installs, started by a scheduled task, SD Core Solo SSH, as SYSTEM, when Windows starts, and again up to three times a minute apart if it stops
Its folder C:\ProgramData\SDCoreSolo\ssh: the server's configuration (sshd_config) and its host key. Only administrators can change it, and the installer reads the permissions back after setting them and stops if anyone else could write there
The key file %USERPROFILE%\SDCoreSolo\ssh\authorized_keys, in your own folder, for the optional keys

The configuration allows only your Windows user, gives that user sd-solo and nothing else, and takes a password or a key:

Port 4251
StrictModes yes
PasswordAuthentication yes
PubkeyAuthentication yes
AllowUsers you
DisableForwarding yes
MaxAuthTries 6
LoginGraceTime 30
ForceCommand "C:\Users\you\SDCoreSolo\usr\bin\sd-solo.exe"

MaxAuthTries 6 and LoginGraceTime 30 are written out, not left to the server's defaults: they are the limits on wrong passwords tried from this computer itself, which the lock-out cannot stop (see the lock-out). Every key a client offers that the server does not know counts as one of the six tries.

Why the server runs as SYSTEM. A server run as an ordinary user can check your Windows password but then cannot start your session: Windows refuses with "a required privilege is not held" (error 1314). The Windows OpenSSH Server service runs as SYSTEM too. Because SYSTEM trusts the configuration, the configuration and host key are in an administrators-only folder, made by the installer's one administrator step, not in your own folder where a program of yours could change what runs as SYSTEM. Your sd-solo.exe still runs as you: the server starts it under your account after you sign in.

Nothing in the Windows OpenSSH Server's own configuration, service or port 22 firewall rule is changed. The OpenSSH package must be installed, because Solo runs the sshd.exe it provides; the Windows service does not have to be running, and need not be set to start.

If there is no OpenSSH package, the installer offers to install Microsoft's OpenSSH server from the release's ssh-server folder. See Installing.

Whether Solo has an ssh server at all is a choice, made when installing — Provide Solo's ssh server where an OpenSSH server is already installed, Install the OpenSSH server where none is, or ssh= in the control file. With it off there is no ssh to SD Core Solo, and nothing on this page applies. The installer has no box for landing in SD: when the server is on, that is what it does. The other choice it asks is who may reach the port (below).

Warnings and things to know#

Anyone who can reach the port can try passwords for your Windows account, and Windows can then lock you out of it. Wrong passwords count against the account like wrong passwords at the sign-in screen: if the computer has an account lock-out policy (net accounts shows it), repeated wrong tries lock the account, and that includes you. Solo therefore has a lock-out of its own (below), which cuts an address off after three wrong passwords, before that count is reached from one address. That lock covers the addresses of other computers only: wrong passwords tried from this computer itself are held only by the ssh server's own limits, because Windows Firewall does not filter this computer's own address (see the lock-out below). So use local unless other computers need to reach SD, and use a long Windows password. (Windows OpenSSH on port 22 has the same property, and no lock-out of Solo's.)

A Windows account with no password cannot sign in over ssh, because Windows refuses a network sign-in for a blank password by default. Give the account a password first.

Keys, as an optional extra#

A key never replaces the password; it is another way in. The SD Core for Linux server adds its own key on a managed computer, through the API (see Managed mode), and removes it again if it is asked to.

No key works until you add one. Solo's ssh server reads only its own key file, which the installation creates empty, so nobody can sign in with a key you did not put there. A key arrives only when you add it, by editing the file (below) or by the SD Core for Linux server's request through the API, which runs solo-sshkey.ps1 with ADD; a key you set up elsewhere on this computer does not reach Solo.

To sign in from your own computer with a key, add your public key to %USERPROFILE%\SDCoreSolo\ssh\authorized_keys as one line (the file is in your own folder, so no administrator is needed):

ssh-ed25519 AAAA... you@your-computer

The server checks the file's permissions (StrictModes yes) and refuses a key file that anyone but you, SYSTEM and the administrators may write to. A file in your own profile folder has the right permissions as Windows creates it.

Keys from an earlier version are moved. Before this version, SD Core Solo put the server's key in %USERPROFILE%\.ssh\authorized_keys. Installing moves that key into the new file, keeps a copy of your old file beside it as authorized_keys.sdcoresolo-backup, and leaves any key of your own in the old file alone.

The cost: no scp or general sftp, and no Windows prompt#

Your ssh sign-in cannot give you a Windows prompt or a general file copy. The command is forced, so there is no system file-transfer subsystem left to run and no shell. That is the accepted cost of landing in SD.

File transfer is the one way in, and it is closed as delivered. SD has a small sftp server of its own for plain-text files. You use it by typing receive (to bring files in) or send (to take copies of records out) in your own SD session, then connecting an sftp client with the same ssh login. It is off twice as delivered: XFER in sd.conf is 0, and the account's switch is off (set.xfer.access). Turning both on lets a program that knows your Windows password bring text into your account while you wait in receive, and take copies of records out, into one folder each way and nothing else; there is no shell behind it. See Moving Files In and Out in the User documentation.

The cost is inbound only. scp or WinSCP running on this computer, connecting outward, is an ssh client and is not affected. So copy files by pulling them from here.

To reach Windows from an ssh session, use sh inside SD, once the administrator has turned it on (set.os.access sh on) — see Operating system access.

Reaching the computer from the network#

local the listener is 127.0.0.1:4251 and [::1]:4251: ssh -p 4251 you@localhost works, nothing else can connect. Unticked, or ssh=local in the control file
open the listener is 0.0.0.0:4251 (every IPv4 address) and [::1]:4251 (IPv6 for this computer only), and the firewall rule lets other computers in. The box Let other computers on your network connect to this one over ssh (port 4251), or ssh=open
A managed computer needs it open, because the SD Core for Linux server connects from elsewhere. Nothing opens it for you

Two walls, not one. The listen address is the first: for local the server answers on 127.0.0.1 and ::1 only, so another computer finds nothing on port 4251 whatever the firewall says. The firewall rule for port 4251 is the second: limited to 127.0.0.1 for local, any address for open. The listen addresses are the ListenAddress lines of C:\ProgramData\SDCoreSolo\ssh\sshd_config. An upgrade keeps what you had: an ssh server that was open stays open; one from an earlier release that answered every address behind a rule for this computer only answers on 127.0.0.1 and ::1 after it.

Why ::1 in both modes. Windows' ssh client tries localhost at its IPv6 address, ::1, first, and when nothing answers there it gives up without trying 127.0.0.1. So Solo's ssh server listens on ::1 as well, and ssh -p 4251 you@localhost and ssh -p 4251 you@127.0.0.1 both work for local and open. It does not listen on any other IPv6 address, so open lets other computers in over IPv4 only. (SD Core Solo for Linux has no ::1 listener; Linux's ssh client falls back.)

The rule is Solo's own, named SD-Solo-SSH-In-TCP, and creating it needs an administrator: a firewall rule is machine-wide. The uninstaller removes it.

To change it afterwards from SD, after admin: remote.ssh open, remote.ssh local or remote.ssh off (or the S key of tool.remote: the word is chosen from a list that starts on off, and open wants the word open typed, in either case). With no word, remote.ssh reports what is installed. A change asks for the administrator password again and is made by the doors helper the installer set up, from any session and with no elevated window: - off stops Solo's ssh server and keeps its folder and host key; - local or open starts it, and sets it up first, as the installer would, if ssh was not chosen when installing; - a move between local and open writes the new listen address and restarts Solo's ssh server, then sets the firewall rule to match.

The doors helper's trade is described on the API page (09).

Or, from an elevated PowerShell:

powershell -ExecutionPolicy Bypass -File "%USERPROFILE%\SDCoreSolo\solo-ssh-firewall.ps1" -Restrict
powershell -ExecutionPolicy Bypass -File "%USERPROFILE%\SDCoreSolo\solo-ssh-firewall.ps1" -Open
powershell -ExecutionPolicy Bypass -File "%USERPROFILE%\SDCoreSolo\solo-ssh-firewall.ps1" -Show

-Restrict limits the rule to this computer, -Open opens it to any address, -Remove takes it away and -Show reports without changing anything. It exits 0 applied, 1 failed, 2 refused (for example, not elevated). It scopes the rule's remote address rather than disabling it, so the rule reads correctly in wf.msc. It changes the firewall rule only, the second wall: with the server listening on 127.0.0.1, -Open lets nobody else in. To open ssh, use remote.ssh open, which changes both.

The lock-out: three wrong passwords lock the address#

Three wrong Windows passwords from one address within ten minutes lock that address for ten minutes. The connection that made the third wrong try is ended at once, and the lock lifts by itself. This is for the addresses of other computers: a lock on this computer's own address is recorded and listed, but the firewall does not stop it (see the end of this section).

Per address, not per account the lock-out never locks the Windows account, so someone guessing from elsewhere cannot lock you out of your own account with it, and the computer's own ssh server on port 22 is not touched. Windows' own account lock-out policy, if the computer has one, still counts the same wrong passwords against the account (see above); the guard cuts an address off at three, before that count
Only a wrong password counts not a key the server does not know: an ssh client that offers several keys is not punished for it
A sign-in forgets the failures a sign-in from the address clears its count
Who is locked powershell -ExecutionPolicy Bypass -File "%USERPROFILE%\SDCoreSolo\solo-sshguard.ps1" -List lists the addresses, any that have wrong passwords counted and each lock's end time, from an ordinary prompt. -Unlock ADDRESS lets one address back in and -Unlock all every address; -Unlock needs an elevated PowerShell. -List ends SOLO SSH GUARD LOCKED <n> and -Unlock ends SOLO SSH GUARD UNLOCKED <n>
How a scheduled task, SD Core Solo SSH Guard, runs as SYSTEM from Windows start (and again up to three times a minute apart if it stops) and reads Solo's ssh server's lines in the Windows event log, OpenSSH/Operational (Event Viewer: Applications and Services Logs, OpenSSH, Operational), where Solo's ssh server logs at level VERBOSE; those lines can be read by any signed-in user. A connection counts as Solo's only after the ssh server has logged that it arrived on port 4251, so wrong passwords at the computer's own ssh server on port 22 are not counted, and only a line written by Windows' own OpenSSH server process is counted (a line another program writes is dropped). A locked address of another computer gets a Windows Firewall block rule on port 4251, SD-Solo-SSH-Guard-<address>, for ten minutes, and the rule goes when the time is up; the firewall cannot enforce a lock on this computer's own address (below). The address is read from the end of the log line, where the ssh server puts the peer's address, never from the user name a client types. The guard's own log is sshguard.log in C:\ProgramData\SDCoreSolo\ssh, and its state is guard.state: anyone may read them, only an administrator may change them. -List also says what record of the event log the guard has read up to, or NEVER READ if it has read none; the installer fails if the guard has not read the event log once and seen Solo's ssh server start
Where it is set up wherever Solo's ssh server is set up: the installer, an upgrade and remote.ssh local or open. It runs the copy in the administrators-only folder, never the one in your own folder. Turning ssh off or uninstalling takes the task and every lock-out rule away

What it does not stop: wrong passwords tried from this computer (below), a guess spread over many addresses (each gets its three), and connections already open when the lock engages: each of them is cut at its next wrong password, so each gets one more guess. On a network where everyone shares one address (behind one NAT), they share the lock.

On Windows a lock covers the addresses of other computers, not this one. A lock cuts an address off with a Windows Firewall rule, and Windows Firewall does not filter this computer's own address (127.0.0.1 and ::1). After three wrong passwords from this computer the connection is ended, but the lock cannot refuse the next one: wrong passwords tried from this computer are not stopped by a lock. They are held only by the ssh server's own limits, MaxAuthTries 6 (six tries on one connection) and LoginGraceTime 30 (thirty seconds to sign in), which are in the server's configuration (above). -List marks such a lock (this computer: not stopped by the firewall). Someone at the computer is not kept out by the lock; what keeps them out is the Windows password.

What an ssh session is#

It is you: the same account, sduser, and the same rights as a session at the keyboard. SD drops administrator rights for an ssh session as it does for itself, so it runs on an ordinary, unelevated token even when your Windows account is an administrator.

On a computer installed from a control file, before the account password has been chosen at the keyboard, an ssh session is told:

This account has no password yet. Set it at this computer's keyboard first; until then only the global password is accepted.

The user name for a domain user#

The configuration names a local user by the lower-case user name, and a domain user as name@domain. On a domain-joined computer, check that your ssh sign-in lands in SD before relying on it. See Known limits.