SD Core for Linux LC2.0-0

ssh access

How people reach SD on this machine over ssh, and the one thing it costs you.

An account has ssh access only if SDSYS gave it — ssh or both at create.account, or modify.account name ssh later; a new account has none. Without it the account is refused at the ssh door, with a message that says SD is not available to it over ssh. SDSYS is different: its two remote doors, ssh and the API, are shut as delivered, are not among the account words, and are opened only by the administrator (remote.sdsys; see SDSYS's remote door below). This page covers the ssh route; API access covers the other.

Unlike SD Core for Windows, an ordinary account is not denied a local login at this machine. SD's switches govern what a session inside SD can reach, and being at the console is being on the machine as that Linux user — see Security and the operating system. An ssh session, by contrast, is forced into sd, so ssh by itself gives an account SD and nothing else: no shell, unless SDSYS has also turned sh-on on for it.

How it is done#

One rule, on the ssh server, not per account:

Match Group sdusers,!sdsys User *,!root
    ForceCommand /usr/local/bin/sd
Match User sdsys
    DenyUsers sdsys

Every sdusers member is ForceCommand'd into sd the instant they connect over ssh — they never reach a shell that way, whatever the connection is asked to run. root is the exception: it is a member of sdusers (the installer adds it), but SD's rules leave it alone, so whether root may sign in over ssh is decided by the ssh server's own settings (PermitRootLogin), exactly as before SD was installed. sdsys is refused a network login outright, before authentication even matters, until the administrator opens that door (then it gets its own arm, with the password alone): there is no session for ForceCommand to apply to.

The block holds one more rule, for key sign-in: Match Group sdsshnokey User *,!root,!sdsys with PubkeyAuthentication no, written ahead of the two sdusers rules.

Signing in with a password, and with a key#

A Linux user that create.account makes signs in over ssh with its password, and only if its account has the ssh route. It cannot sign in with a key, as delivered. A key is a second way in that the account's password does not control, so SD leaves it shut until SDSYS opens it, account by account:

modify.account fred ssh-key-on
modify.account fred ssh-key-off
create.account user fred ssh ssh-key-on

Opening it means that whoever holds a private key for that user signs in without the password, and nothing in SD can tell who holds a copy; leaving it off is the tighter choice. The gate pages show where each account stands: the administrator's gate matrix has a column for it (turning it on asks for the account's name to be typed), and every account's own What this account may do page shows its own state.

The Administrator set's Accounts and Security chapter has the whole of it.

This is applied once, to the ssh server, regardless of the two questions the installer asked. Whether remote ssh access is turned on only decides whether sshd is enabled at boot and reachable from other computers (see Installing SD Core for Linux); the boundary above is written to sshd_config either way, so ssh localhost is confined the same as a connection from anywhere else.

An ssh session lands inside SD#

That applies to everyone who can reach ssh at all, except sdsys — see SDSYS's remote door below.

The cost: scp and sftp stop working inbound, over ssh#

scp, rsync and a general sftp session cannot push a file to this machine over ssh, for anybody who is ForceCommand'd into sd. The command is forced, so there is no system file-transfer subsystem left to run. This is the accepted cost of the boundary above.

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, and an account uses it by typing receive (to bring files in) or send (to take copies of records out) in its own SD session, then connecting an sftp client with the same ssh login. It is off twice as delivered: the system switch XFER in sd.conf is 0, and every account's xfer-on switch is off. The administrator turns on both, deliberately. Turning it on lets that person bring text into their own account from another machine and take copies of the account's records out, into one directory each way and nothing else; there is no shell behind it. See File transfer in the Administrator set and Moving Files In and Out in the User set.

The cost is inbound, over ssh, only. scp or rsync run on this machine, connecting outward, makes it the client — sshd_config's ForceCommand is never consulted for an outbound connection. And an account can also simply log in at the machine directly to move a file, or reach it through SD's own file access (an editor, or an API client) rather than needing a separate remote-desktop product.

Reaching the machine from the network#

Whether remote ssh access is turned on is a plain yes/no from the installer, defaulting to no (see Installing SD Core for Linux). Answering yes enables sshd at boot and adds a firewall rule for 22/tcp (ufw, or firewalld where that is the firewall in use); answering no leaves sshd and the firewall exactly as the box already had them — the installer does not narrow an existing, wider rule on your behalf. Change it afterward with remote.ssh on/off — see Administrator commands.

Connecting to SD on your own machine is unaffected either way. ssh localhost needs no firewall rule for loopback traffic and works whether or not remote access is turned on. A local-only installation is served entirely by ssh localhost.

What ssh confinement does not mean#

The ForceCommand rule controls what an ssh connection may run, not where an account may otherwise log in. Confining a session to SD over ssh is this page's rule; once inside SD, sh, OS.EXECUTE and the rest of the operating-system reach are the account's own sh-on and os-on switches, off until SDSYS turns them on. See Security and the operating system.

And ssh confinement does not give accounts isolation from each other's data. Every SD process opens the database under the invoking user's own Linux identity, so everyone who uses SD needs file access to the tree and can, in principle, read another account's directory from outside SD if the file permissions allow it. See Security.

SDSYS's remote door#

SDSYS cannot ssh in until the administrator has opened that door. Until then Match User sdsys denies it outright, at the ssh server, before authentication starts — there is no session for ForceCommand to ever apply to. Once the administrator has opened it (remote.sdsys ssh on, or remote.sdsys on; the Administrator documents, "Remote Administration over ssh", say how, and what it risks), an ssh sign-in as sdsys asks for the password, which is then all that guards it, and lands in an SD session with no shell behind it. Opening it means that nothing but that password stands between the network and the administrator, so open it only on a machine whose sdsys password is long and used nowhere else, and shut it again (remote.sdsys ssh off) when it is not needed. The API door is a separate one with its own switch, also shut as delivered (remote.sdsys api on address); on this machine SDSYS reaches the API through the local Unix socket from a process running as sdsys — see API access.

Nothing changes for ordinary accounts. Every account create.account makes reaches ssh from wherever sdusers membership allows, whether or not the Linux account behind it happens to also be in sudo or wheel — group membership outside sdusers has never been what SD asks about.

Where administration happens#

At this machine's own console — a real login as sdsys, its own password, either physically at the keyboard or through a desktop-sharing view of it (VNC, TeamViewer), which counts as local because it is a local session from the machine's own point of view — or, once the administrator has opened the door with remote.sdsys ssh on, over ssh with sdsys's password.

Why#

This is a deliberate policy choice, not a technical limitation the way it is on some ports: SDSYS is checked against the kernel's own audit loginuid, set once by a real login and unforgeable by sudo, su, or a service account, so su sdsys and sudo -u sdsys from somebody else's session are refused whatever the ssh settings are. A real ssh sign-in as sdsys is a real login (sshd sets the record), so it passes that check; what guards it is the password. See Accounts.

If you rely on remote administration#

It works once the administrator has opened the door (remote.sdsys ssh on), and not before. Until then use the console, or a service- or session-based remote desktop, logged in as sdsys. An account that needs ordinary, non-administrative work from another machine was never an administration question — give that account the ssh route (modify.account name ssh) and it can connect.

Scheduled tasks are affected too. A cron job or a systemd timer has no terminal login either, so nothing can become SDSYS to run one. Work that must run as SDSYS is set up with set.job, which hands it to systemd; see the Administrator documents, "Scheduled Jobs". A command for an ordinary account is listed in the SD system file batch.jobs, run from an ordinary account — see Scheduled jobs.