Skip to content

Commit 261a83c

Browse files
committed
fix(sshd): prefer Termux patched native sshd binary over Nix glibc sshd on Android
1 parent 5583606 commit 261a83c

3 files changed

Lines changed: 25 additions & 5 deletions

File tree

machines/aarch64/android/common.nix

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,11 @@
2727
text = ''
2828
#!/bin/sh
2929
if ! pgrep -x "sshd" > /dev/null; then
30-
${pkgs.openssh}/bin/sshd -f ${config.home.homeDirectory}/.ssh/sshd_config
30+
SSHD_BIN="/data/data/com.termux/files/usr/bin/sshd"
31+
if [ ! -x "$SSHD_BIN" ]; then
32+
SSHD_BIN="${pkgs.openssh}/bin/sshd"
33+
fi
34+
"$SSHD_BIN" -f ${config.home.homeDirectory}/.ssh/sshd_config
3135
fi
3236
'';
3337
executable = true;

machines/aarch64/android/smartphone/default.nix

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,22 @@ in
2727
programs.zsh.initExtra = ''
2828
export PROMPT="%F{yellow}%n%f@%F{green}${hostName}%f:%F{blue}%~%f%# "
2929
if ! pgrep -x "sshd" > /dev/null; then
30-
${pkgs.openssh}/bin/sshd -f ${config.home.homeDirectory}/.ssh/sshd_config
30+
SSHD_BIN="/data/data/com.termux/files/usr/bin/sshd"
31+
if [ ! -x "$SSHD_BIN" ]; then
32+
SSHD_BIN="${pkgs.openssh}/bin/sshd"
33+
fi
34+
"$SSHD_BIN" -f ${config.home.homeDirectory}/.ssh/sshd_config
3135
fi
3236
'';
3337

3438
programs.bash.initExtra = ''
3539
export PS1="\[\033[01;33m\]\u\[\033[00m\]@\[\033[01;32m\]${hostName}\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "
3640
if ! pgrep -x "sshd" > /dev/null; then
37-
${pkgs.openssh}/bin/sshd -f ${config.home.homeDirectory}/.ssh/sshd_config
41+
SSHD_BIN="/data/data/com.termux/files/usr/bin/sshd"
42+
if [ ! -x "$SSHD_BIN" ]; then
43+
SSHD_BIN="${pkgs.openssh}/bin/sshd"
44+
fi
45+
"$SSHD_BIN" -f ${config.home.homeDirectory}/.ssh/sshd_config
3846
fi
3947
'';
4048
}

machines/aarch64/android/tablet/default.nix

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,22 @@ in
2727
programs.zsh.initExtra = ''
2828
export PROMPT="%F{yellow}%n%f@%F{green}${hostName}%f:%F{blue}%~%f%# "
2929
if ! pgrep -x "sshd" > /dev/null; then
30-
${pkgs.openssh}/bin/sshd -f ${config.home.homeDirectory}/.ssh/sshd_config
30+
SSHD_BIN="/data/data/com.termux/files/usr/bin/sshd"
31+
if [ ! -x "$SSHD_BIN" ]; then
32+
SSHD_BIN="${pkgs.openssh}/bin/sshd"
33+
fi
34+
"$SSHD_BIN" -f ${config.home.homeDirectory}/.ssh/sshd_config
3135
fi
3236
'';
3337

3438
programs.bash.initExtra = ''
3539
export PS1="\[\033[01;33m\]\u\[\033[00m\]@\[\033[01;32m\]${hostName}\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ "
3640
if ! pgrep -x "sshd" > /dev/null; then
37-
${pkgs.openssh}/bin/sshd -f ${config.home.homeDirectory}/.ssh/sshd_config
41+
SSHD_BIN="/data/data/com.termux/files/usr/bin/sshd"
42+
if [ ! -x "$SSHD_BIN" ]; then
43+
SSHD_BIN="${pkgs.openssh}/bin/sshd"
44+
fi
45+
"$SSHD_BIN" -f ${config.home.homeDirectory}/.ssh/sshd_config
3846
fi
3947
'';
4048
}

0 commit comments

Comments
 (0)