Skip to content

LordOS — a free, fast and secure GNU/Linux distribution based on Debian, with its own desktop environment: display server and Wayland compositor in C, a React UI engine on QuickJS, and private native apps.

Settings → Sharing: Remote login (SSH) switch

Federico Pereiradc8f9d819633
diff --git a/apps/settings/Sharing.jsx b/apps/settings/Sharing.jsx
index 69ddcd2..3e8b088 100644
--- a/apps/settings/Sharing.jsx
+++ b/apps/settings/Sharing.jsx
@@ -1,8 +1,9 @@
-// Settings → Sharing: remote desktop (lord-sessiond, docs/REMOTE.md). Off by default;
-// turning it on, choosing who can log in and viewing or cutting connections goes through the
-// administration helper (remote-* actions).
+// Settings → Sharing: remote desktop (lord-sessiond, docs/REMOTE.md) and remote login (SSH).
+// Both are off by default; turning them on, choosing who can log in and viewing or cutting
+// connections goes through the administration helper (remote-* and ssh-* actions). The SSH
+// server is installed, the first time, with the package engine's own pkg-install action.
import {
- View, Text, Button, Toggle, Segmented, useTheme, useLocale, useStore, admin, remote, remoteViewers, useSystemInfo, spacing, typeScale,
+ View, Text, Button, Toggle, Segmented, useTheme, useLocale, useStore, admin, remote, remoteViewers, sshLogin, statusText, useSystemInfo, spacing, typeScale,
} from '@lordos/sdk';
import { useEffect, useState } from 'react';
import { Stack, Section, SettingRow, Note, Message, StatusDot, tint } from './ui.jsx';
@@ -24,6 +25,74 @@ const ago = (sec, tr) => {
return m < 1 ? tr('settings.sharing.justNow') : tr('settings.sharing.minutes', { count: m });
};
+// openssh-sftp-server too: scp and sftp need it (a Recommends the package engine skips).
+const SSH_PACKAGES = 'openssh-server openssh-sftp-server';
+
+function SshSection({ isAdmin, ips, user, hostname }) {
+ const t = useTheme();
+ const { t: tr } = useLocale();
+ const [st, setSt] = useState(() => sshLogin.status());
+ const [busy, setBusy] = useState(null); // null, 'install' or 'apply'
+ const [msg, setMsg] = useState(null);
+ useEffect(() => { const id = setInterval(() => setSt(sshLogin.status()), 2000); return () => clearInterval(id); }, []);
+ const refresh = () => setSt(sshLogin.status());
+ const fail = (e) => setMsg({ ok: false, text: e.message });
+ const install = () => admin.run('pkg-install', SSH_PACKAGES).catch((e) => {
+ if (e.code !== 'pkg.noIndex') throw e; // no package lists yet (fresh install): fetch them once
+ return admin.run('pkg-update').then(() => admin.run('pkg-install', SSH_PACKAGES));
+ });
+ const turn = async (on) => {
+ if (busy || !isAdmin) return;
+ setMsg(null);
+ try {
+ if (on && !sshLogin.status().installed) { setBusy('install'); await install(); }
+ setBusy('apply');
+ const ok = await admin.run('ssh-set', on ? 'on' : 'off');
+ setMsg({ ok: true, text: statusText(ok) });
+ } catch (e) { fail(e); }
+ refresh();
+ setBusy(null);
+ };
+ const allow = (v) => {
+ if (busy || !isAdmin) return;
+ setBusy('apply');
+ setMsg(null);
+ admin.run('ssh-allow', v).then((ok) => setMsg({ ok: true, text: statusText(ok) }), fail).finally(() => { refresh(); setBusy(null); });
+ };
+ const name = user || tr('settings.sharing.sshUserPlaceholder');
+ const targets = [...ips, ...(hostname ? [hostname] : [])];
+ const hint = busy === 'install' ? tr('settings.sharing.sshInstalling') : busy ? tr('settings.sharing.working')
+ : tr(st.installed ? 'settings.sharing.sshHint' : 'settings.sharing.sshHintInstall');
+ return (
+ <>
+ <Section title={tr('settings.sharing.ssh')} footer={tr('settings.sharing.sshSecurity')}>
+ <SettingRow label={tr('settings.sharing.sshToggle')} hint={hint}>
+ <Toggle small on={st.enabled} onChange={turn} />
+ </SettingRow>
+ {st.enabled && (
+ <View style={{ paddingVertical: spacing.m, gap: 6 }}>
+ <Text style={{ fontSize: typeScale.caption, color: t.textDim, textAlign: 'start' }}>{tr('settings.sharing.sshFrom')}</Text>
+ {targets.map((h) => <Text key={h} style={{ fontSize: typeScale.headline, fontWeight: 600, color: t.accent, fontFamily: 'monospace', direction: 'ltr', textAlign: 'start' }}>{`ssh ${name}@${h}`}</Text>)}
+ {!ips.length && <Text style={{ fontSize: typeScale.callout, color: t.textDim, textAlign: 'start' }}>{tr('settings.sharing.noLan')}</Text>}
+ {st.fingerprint ? (
+ <View style={{ marginTop: spacing.xs, gap: 2 }}>
+ <Text style={{ fontSize: typeScale.caption, color: t.textDim, textAlign: 'start' }}>{tr('settings.sharing.sshFingerprint')}</Text>
+ <Text style={{ fontSize: 11, color: t.text, fontFamily: 'monospace', lineHeight: 1.4, direction: 'ltr', textAlign: 'start' }}>{`ED25519 ${st.fingerprint}`}</Text>
+ </View>
+ ) : null}
+ </View>
+ )}
+ <SettingRow label={tr('settings.sharing.who')} hint={tr(st.allow === 'admins' ? 'settings.sharing.sshWhoAdminsHint' : 'settings.sharing.sshWhoAllHint')}>
+ <Segmented small value={st.allow} onChange={allow}
+ options={[['all', tr('settings.sharing.allUsers')], ['admins', tr('settings.sharing.onlyAdmins')]]} />
+ </SettingRow>
+ </Section>
+ {st.enabled && !st.running && !busy && <Note tone="warn">{tr('settings.sharing.sshNotRunning')}</Note>}
+ <Message msg={msg} />
+ </>
+ );
+}
+
export function SharingSettings() {
const t = useTheme();
const { t: tr } = useLocale();
@@ -78,6 +147,7 @@ export function SharingSettings() {
</SettingRow>
))}
</Section>
+ <SshSection isAdmin={isAdmin} ips={ips} user={info.user} hostname={info.hostname} />
</Stack>
);
}
diff --git a/assets/locales/en/errors.json b/assets/locales/en/errors.json
index f620084..335b219 100644
--- a/assets/locales/en/errors.json
+++ b/assets/locales/en/errors.json
@@ -546,5 +546,8 @@
"fw.restricted.files": "{app} is restricted from opening or saving your files (Privacy → App network access)",
"fw.restricted.clipboard": "{app} is restricted from reading the clipboard (Privacy → App network access)",
"fw.restricted.bluetooth": "{app} is restricted from using Bluetooth (Privacy → App network access)",
- "fw.restricted.notifications": "{app} is restricted from showing notifications (Privacy → App network access)"
+ "fw.restricted.notifications": "{app} is restricted from showing notifications (Privacy → App network access)",
+ "ssh.badConfig": "The SSH server configuration is not valid (sshd -t); nothing was changed",
+ "ssh.notInstalled": "The SSH server (openssh-server) is not installed",
+ "ssh.startFailed": "The SSH server did not start (see Logs)"
}
diff --git a/assets/locales/en/settings.json b/assets/locales/en/settings.json
index 1826446..1af155a 100644
--- a/assets/locales/en/settings.json
+++ b/assets/locales/en/settings.json
@@ -62,7 +62,7 @@
"keywords.language": "language region date time zone",
"keywords.network": "wifi ethernet vpn wireguard openvpn ip dns internet",
"keywords.session": "log out quit",
- "keywords.sharing": "remote desktop remote access network lan browser share screen",
+ "keywords.sharing": "remote desktop remote access network lan browser share screen ssh remote login terminal",
"keywords.sound": "volume speakers microphone audio",
"keywords.printers": "printer print scanner scan cups queue airprint",
"keywords.themes": "theme desktop classic",
@@ -251,5 +251,18 @@
"section.cooling": "Cooling",
"keywords.cooling": "fan fans temperature cooling heat noise curve case full speed",
"reduceMotion": "Reduce motion",
- "reduceMotionHint": "Stops decorative animations, like the spinning fan in Cooling."
+ "reduceMotionHint": "Stops decorative animations, like the spinning fan in Cooling.",
+ "sharing.onlyAdmins": "Only administrators",
+ "sharing.ssh": "Remote login (SSH)",
+ "sharing.sshFingerprint": "Host key fingerprint (compare it with the one ssh shows the first time you connect):",
+ "sharing.sshFrom": "From another computer, run in a terminal:",
+ "sharing.sshHint": "Other computers open a terminal on this one with an SSH client, using a username and password of this computer. Once on, it stays on after restarting.",
+ "sharing.sshHintInstall": "Other computers open a terminal on this one with an SSH client, using a username and password of this computer. The SSH server is installed the first time you turn this on (it needs the internet).",
+ "sharing.sshInstalling": "Installing the SSH server…",
+ "sharing.sshNotRunning": "Remote login is turned on but the SSH server is not running. Turn it off and on again, or see Logs.",
+ "sharing.sshSecurity": "Port 22. Passwords travel encrypted. Logging in with a key is safer: copy yours with ssh-copy-id. To use it from the internet, use a VPN.",
+ "sharing.sshToggle": "Allow logins from the network",
+ "sharing.sshUserPlaceholder": "user",
+ "sharing.sshWhoAdminsHint": "Only administrators (the sudo group). Root can never log in.",
+ "sharing.sshWhoAllHint": "Any user of this computer with a password. Root can never log in."
}
diff --git a/assets/locales/en/status.json b/assets/locales/en/status.json
index d5673b6..c6d6945 100644
--- a/assets/locales/en/status.json
+++ b/assets/locales/en/status.json
@@ -116,5 +116,8 @@
"wifi.connecting": "Connecting to {ssid}…",
"wifi.disconnected": "Disconnected",
"wifi.forgotten": "Network forgotten",
- "hw.caseSet": "Case: {case}"
+ "hw.caseSet": "Case: {case}",
+ "ssh.off": "Remote login turned off",
+ "ssh.on": "Remote login turned on",
+ "ssh.saved": "Settings saved"
}
diff --git a/assets/locales/es/errors.json b/assets/locales/es/errors.json
index 997ef90..bd26c13 100644
--- a/assets/locales/es/errors.json
+++ b/assets/locales/es/errors.json
@@ -546,5 +546,8 @@
"fw.restricted.files": "{app} tiene restringido abrir o guardar tus archivos (Privacidad → Red de las apps)",
"fw.restricted.clipboard": "{app} tiene restringido leer el portapapeles (Privacidad → Red de las apps)",
"fw.restricted.bluetooth": "{app} tiene restringido el uso de Bluetooth (Privacidad → Red de las apps)",
- "fw.restricted.notifications": "{app} tiene restringido mostrar notificaciones (Privacidad → Red de las apps)"
+ "fw.restricted.notifications": "{app} tiene restringido mostrar notificaciones (Privacidad → Red de las apps)",
+ "ssh.badConfig": "La configuración del servidor SSH no es válida (sshd -t); no se cambió nada",
+ "ssh.notInstalled": "El servidor SSH (openssh-server) no está instalado",
+ "ssh.startFailed": "El servidor SSH no arrancó (mirá Registros)"
}
diff --git a/assets/locales/es/settings.json b/assets/locales/es/settings.json
index 789feb0..0cc086f 100644
--- a/assets/locales/es/settings.json
+++ b/assets/locales/es/settings.json
@@ -62,7 +62,7 @@
"keywords.language": "idioma región fecha hora zona horaria",
"keywords.network": "wifi ethernet vpn wireguard openvpn ip dns internet",
"keywords.session": "cerrar sesión salir",
- "keywords.sharing": "escritorio remoto acceso remoto red lan navegador compartir pantalla",
+ "keywords.sharing": "escritorio remoto acceso remoto red lan navegador compartir pantalla ssh inicio de sesión remoto terminal",
"keywords.sound": "volumen parlantes micrófono audio",
"keywords.printers": "impresora imprimir escáner escanear cups cola airprint",
"keywords.themes": "tema escritorio clásico",
@@ -251,5 +251,18 @@
"section.cooling": "Refrigeración",
"keywords.cooling": "ventilador ventiladores temperatura refrigeración calor ruido curva caja a tope fan cooling",
"reduceMotion": "Reducir movimiento",
- "reduceMotionHint": "Detiene las animaciones decorativas, como el ventilador que gira en Refrigeración."
+ "reduceMotionHint": "Detiene las animaciones decorativas, como el ventilador que gira en Refrigeración.",
+ "sharing.onlyAdmins": "Solo administradores",
+ "sharing.ssh": "Inicio de sesión remoto (SSH)",
+ "sharing.sshFingerprint": "Huella de la clave del equipo (comparala con la que muestra ssh la primera vez que te conectás):",
+ "sharing.sshFrom": "Desde otra computadora, ejecutá en una terminal:",
+ "sharing.sshHint": "Otras computadoras abren una terminal en esta con un cliente SSH, con un usuario y contraseña de esta computadora. Una vez activado, sigue activo después de reiniciar.",
+ "sharing.sshHintInstall": "Otras computadoras abren una terminal en esta con un cliente SSH, con un usuario y contraseña de esta computadora. El servidor SSH se instala la primera vez que lo activás (necesita internet).",
+ "sharing.sshInstalling": "Instalando el servidor SSH…",
+ "sharing.sshNotRunning": "El inicio de sesión remoto está activado pero el servidor SSH no está funcionando. Apagalo y volvé a encenderlo, o mirá Registros.",
+ "sharing.sshSecurity": "Puerto 22. Las contraseñas viajan cifradas. Entrar con una clave es más seguro: copiá la tuya con ssh-copy-id. Para usarlo desde internet, usá una VPN.",
+ "sharing.sshToggle": "Permitir el inicio de sesión desde la red",
+ "sharing.sshUserPlaceholder": "usuario",
+ "sharing.sshWhoAdminsHint": "Solo administradores (el grupo sudo). Root nunca puede entrar.",
+ "sharing.sshWhoAllHint": "Cualquier usuario de esta computadora con contraseña. Root nunca puede entrar."
}
diff --git a/assets/locales/es/status.json b/assets/locales/es/status.json
index fb0722d..9faf3b9 100644
--- a/assets/locales/es/status.json
+++ b/assets/locales/es/status.json
@@ -116,5 +116,8 @@
"wifi.connecting": "Conectando a {ssid}…",
"wifi.disconnected": "Desconectado",
"wifi.forgotten": "Red olvidada",
- "hw.caseSet": "Caja: {case}"
+ "hw.caseSet": "Caja: {case}",
+ "ssh.off": "Inicio de sesión remoto desactivado",
+ "ssh.on": "Inicio de sesión remoto activado",
+ "ssh.saved": "Ajustes guardados"
}
diff --git a/assets/locales/pt/errors.json b/assets/locales/pt/errors.json
index 00f57c2..c0ec39c 100644
--- a/assets/locales/pt/errors.json
+++ b/assets/locales/pt/errors.json
@@ -546,5 +546,8 @@
"fw.restricted.files": "{app} está impedido de abrir ou salvar seus arquivos (Privacidade → Rede dos apps)",
"fw.restricted.clipboard": "{app} está impedido de ler a área de transferência (Privacidade → Rede dos apps)",
"fw.restricted.bluetooth": "{app} está impedido de usar Bluetooth (Privacidade → Rede dos apps)",
- "fw.restricted.notifications": "{app} está impedido de mostrar notificações (Privacidade → Rede dos apps)"
+ "fw.restricted.notifications": "{app} está impedido de mostrar notificações (Privacidade → Rede dos apps)",
+ "ssh.badConfig": "A configuração do servidor SSH não é válida (sshd -t); nada foi alterado",
+ "ssh.notInstalled": "O servidor SSH (openssh-server) não está instalado",
+ "ssh.startFailed": "O servidor SSH não iniciou (veja Registros)"
}
diff --git a/assets/locales/pt/settings.json b/assets/locales/pt/settings.json
index 7508f66..335f1d1 100644
--- a/assets/locales/pt/settings.json
+++ b/assets/locales/pt/settings.json
@@ -62,7 +62,7 @@
"keywords.language": "idioma região data hora fuso",
"keywords.network": "wifi ethernet vpn wireguard openvpn ip dns internet",
"keywords.session": "sair encerrar sessão",
- "keywords.sharing": "área de trabalho remota acesso remoto rede lan navegador compartilhar tela",
+ "keywords.sharing": "área de trabalho remota acesso remoto rede lan navegador compartilhar tela ssh login remoto terminal",
"keywords.sound": "volume alto-falantes microfone áudio",
"keywords.printers": "impressora imprimir scanner digitalizar cups fila airprint",
"keywords.themes": "tema área de trabalho clássico",
@@ -251,5 +251,18 @@
"section.cooling": "Resfriamento",
"keywords.cooling": "ventoinha ventoinhas temperatura resfriamento calor ruído curva gabinete máxima fan cooling",
"reduceMotion": "Reduzir movimento",
- "reduceMotionHint": "Para as animações decorativas, como a ventoinha girando em Resfriamento."
+ "reduceMotionHint": "Para as animações decorativas, como a ventoinha girando em Resfriamento.",
+ "sharing.onlyAdmins": "Somente administradores",
+ "sharing.ssh": "Login remoto (SSH)",
+ "sharing.sshFingerprint": "Impressão digital da chave do computador (compare com a que o ssh mostra na primeira conexão):",
+ "sharing.sshFrom": "De outro computador, execute em um terminal:",
+ "sharing.sshHint": "Outros computadores abrem um terminal neste com um cliente SSH, usando um usuário e senha deste computador. Depois de ativado, continua ativo após reiniciar.",
+ "sharing.sshHintInstall": "Outros computadores abrem um terminal neste com um cliente SSH, usando um usuário e senha deste computador. O servidor SSH é instalado na primeira vez que você o ativa (precisa de internet).",
+ "sharing.sshInstalling": "Instalando o servidor SSH…",
+ "sharing.sshNotRunning": "O login remoto está ativado, mas o servidor SSH não está em execução. Desative e ative de novo, ou veja Registros.",
+ "sharing.sshSecurity": "Porta 22. As senhas viajam criptografadas. Entrar com uma chave é mais seguro: copie a sua com ssh-copy-id. Para usar pela internet, use uma VPN.",
+ "sharing.sshToggle": "Permitir login pela rede",
+ "sharing.sshUserPlaceholder": "usuário",
+ "sharing.sshWhoAdminsHint": "Somente administradores (o grupo sudo). O root nunca pode entrar.",
+ "sharing.sshWhoAllHint": "Qualquer usuário deste computador com senha. O root nunca pode entrar."
}
diff --git a/assets/locales/pt/status.json b/assets/locales/pt/status.json
index 4d094cf..398472f 100644
--- a/assets/locales/pt/status.json
+++ b/assets/locales/pt/status.json
@@ -116,5 +116,8 @@
"wifi.connecting": "Conectando a {ssid}…",
"wifi.disconnected": "Desconectado",
"wifi.forgotten": "Rede esquecida",
- "hw.caseSet": "Gabinete: {case}"
+ "hw.caseSet": "Gabinete: {case}",
+ "ssh.off": "Login remoto desativado",
+ "ssh.on": "Login remoto ativado",
+ "ssh.saved": "Configurações salvas"
}
diff --git a/sdk/index.js b/sdk/index.js
index 8a0b4a4..da97d93 100644
--- a/sdk/index.js
+++ b/sdk/index.js
@@ -20,7 +20,7 @@ import { ImeOverlay } from './ime.js';
import { ClipboardPanel, ClipboardToast, clipboard as clipboardApi } from './clipboard.js';
import { SpotlightPanel } from './spotlight.js';
import { RemoteBadge } from './remote.js';
-export { remote, remoteViewers } from './remote.js';
+export { remote, remoteViewers, sshLogin } from './remote.js';
export { perms, permsRev, requestPermission, markDeviceUse, useIndicators, PrivacyIndicators, PermissionPrompt, registerPrivacySection, privacySections, PERMISSIONS, onPermissionRevoked, micStart, micStop, micLevel } from './privacy.js';
import { PermissionPrompt } from './privacy.js';
import { Powerbox } from './powerbox.jsx';
diff --git a/sdk/remote.js b/sdk/remote.js
index 3371979..2e2b6f4 100644
--- a/sdk/remote.js
+++ b/sdk/remote.js
@@ -6,6 +6,7 @@
//
// useStore(remoteViewers) → [{ ip, user }]
// remote.status() → { enabled, installed, port, allow, fingerprint, clients: [...], sessions: [...], monitor }
+// sshLogin.status() → { installed, enabled, running, allow: 'all'|'admins', fingerprint } (remote login, SSH)
import { createElement as h } from 'react';
import { View, Text } from '@lordos/runtime';
import { createStore, useStore } from './store.js';
@@ -41,6 +42,16 @@ export const remote = {
},
};
+// Remote login (SSH): read-only state; changes go through the ssh-set / ssh-allow admin actions.
+export const sshLogin = {
+ available: () => typeof lord.ssh !== 'undefined',
+ status() {
+ if (typeof lord.ssh === 'undefined') return { installed: false, enabled: false, running: false, allow: 'all', fingerprint: '' };
+ const s = lord.ssh.status();
+ return { installed: !!s.installed, enabled: !!s.enabled, running: !!s.running, allow: s.allow === 'admins' ? 'admins' : 'all', fingerprint: s.fingerprint || '' };
+ },
+};
+
export function RemoteBadge() {
const list = useStore(remoteViewers);
if (!list.length) return null;