mirror of
https://github.com/oqyude/nixos.git
synced 2026-08-08 23:53:11 +03:00
sshd setup for termux
This commit is contained in:
@@ -31,6 +31,11 @@ let
|
|||||||
# (default is bashInteractive)
|
# (default is bashInteractive)
|
||||||
user.shell = "${pkgs.zsh}/bin/zsh";
|
user.shell = "${pkgs.zsh}/bin/zsh";
|
||||||
|
|
||||||
|
# SSH user (matches `User oqyude` in the client's ~/.ssh/config).
|
||||||
|
# Default is "nix-on-droid"; home stays at the read-only
|
||||||
|
# /data/data/com.termux.nix/files/home either way.
|
||||||
|
user.userName = "oqyude";
|
||||||
|
|
||||||
# Minimal termux settings (nix-on-droid options only:
|
# Minimal termux settings (nix-on-droid options only:
|
||||||
# environment.*, nix.*, time.*, user.*, system.*, android-integration.*)
|
# environment.*, nix.*, time.*, user.*, system.*, android-integration.*)
|
||||||
|
|
||||||
|
|||||||
+10
-2
@@ -51,11 +51,18 @@
|
|||||||
TUCKR_HOME = "$HOME/Storage/dotfiles";
|
TUCKR_HOME = "$HOME/Storage/dotfiles";
|
||||||
EDITOR = "fresh";
|
EDITOR = "fresh";
|
||||||
};
|
};
|
||||||
file.".nanorc".text = ''
|
file = {
|
||||||
|
".nanorc".text = ''
|
||||||
set nowrap
|
set nowrap
|
||||||
set tabstospaces
|
set tabstospaces
|
||||||
set tabsize 2
|
set tabsize 2
|
||||||
'';
|
'';
|
||||||
|
# Authorized keys for sshd (see modules/termux/default.nix).
|
||||||
|
# Declarative for now — the Store/.ssh symlink scheme is postponed.
|
||||||
|
".ssh/authorized_keys".text = ''
|
||||||
|
ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKduJia+unaQQdN6X5syaHvnpIutO+yZwvfiCP4qKQ/P
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
programs = {
|
programs = {
|
||||||
# ---- Shell: zsh ----
|
# ---- Shell: zsh ----
|
||||||
@@ -68,7 +75,7 @@
|
|||||||
enable = true;
|
enable = true;
|
||||||
theme = "robbyrussell";
|
theme = "robbyrussell";
|
||||||
};
|
};
|
||||||
loginExtra = "clear && fastfetch";
|
loginExtra = "clear && fastfetch && cd ~/.config/nix-on-droid";
|
||||||
initContent = ''
|
initContent = ''
|
||||||
beet-p() {
|
beet-p() {
|
||||||
local base="${config.home.homeDirectory}/.config/beets/My"
|
local base="${config.home.homeDirectory}/.config/beets/My"
|
||||||
@@ -99,6 +106,7 @@
|
|||||||
z-proxy = "export ALL_PROXY=socks5://localhost:10808";
|
z-proxy = "export ALL_PROXY=socks5://localhost:10808";
|
||||||
zh-proxy = "export HTTPS_PROXY=http://localhost:10808 && export HTTP_PROXY=http://localhost:10808";
|
zh-proxy = "export HTTPS_PROXY=http://localhost:10808 && export HTTP_PROXY=http://localhost:10808";
|
||||||
nix-dir = "cd ~/.config/nix-on-droid";
|
nix-dir = "cd ~/.config/nix-on-droid";
|
||||||
|
q-ssh = "sshd-start";
|
||||||
|
|
||||||
# beets
|
# beets
|
||||||
beet-ima = "beet im ./ -A";
|
beet-ima = "beet im ./ -A";
|
||||||
|
|||||||
@@ -1,9 +1,42 @@
|
|||||||
{
|
{
|
||||||
|
config,
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
let
|
||||||
|
sshdDir = "${config.user.home}/sshd";
|
||||||
|
sshdTmpDir = "${config.user.home}/sshd-tmp";
|
||||||
|
port = 8022;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
# imports = [
|
# Minimal sshd server for LAN access (e.g. `ssh epral` from other hosts).
|
||||||
# ];
|
# nix-on-droid has no systemd: sshd is started manually via `sshd-start`
|
||||||
|
# (or from Termux:Boot / a session). The host key is generated once on the
|
||||||
|
# first activation and kept in ~/sshd (NOT /etc — it is rebuilt on every
|
||||||
|
# activation).
|
||||||
|
environment.etc."ssh/sshd_config".text = ''
|
||||||
|
HostKey ${sshdDir}/ssh_host_ed25519_key
|
||||||
|
Port ${toString port}
|
||||||
|
PasswordAuthentication no
|
||||||
|
AllowUsers ${config.user.userName}
|
||||||
|
'';
|
||||||
|
|
||||||
|
# Generate the host key on first activation (idempotent).
|
||||||
|
build.activation.sshd = ''
|
||||||
|
if [[ ! -d "${sshdDir}" ]]; then
|
||||||
|
$DRY_RUN_CMD rm -rf "${sshdTmpDir}"
|
||||||
|
$DRY_RUN_CMD mkdir -p "${sshdTmpDir}"
|
||||||
|
$VERBOSE_ECHO "Generating sshd host key..."
|
||||||
|
$DRY_RUN_CMD ${pkgs.openssh}/bin/ssh-keygen -t ed25519 -f "${sshdTmpDir}/ssh_host_ed25519_key" -N ""
|
||||||
|
$DRY_RUN_CMD mv "${sshdTmpDir}" "${sshdDir}"
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
|
||||||
|
environment.packages = [
|
||||||
|
(pkgs.writeScriptBin "sshd-start" ''
|
||||||
|
#!${pkgs.runtimeShell}
|
||||||
|
exec ${pkgs.openssh}/bin/sshd -f /etc/ssh/sshd_config -D "$@"
|
||||||
|
'')
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user