summaryrefslogtreecommitdiff
path: root/ssh
diff options
context:
space:
mode:
authorJulian Blake Kongslie2020-05-24 23:02:20 -0700
committerJulian Blake Kongslie2020-05-24 23:55:52 -0700
commit2379a457a87afc9507f0f2a9664fcb47006a2aa2 (patch)
treeb2911f06721ce3b2cca269af3b2782747478f527 /ssh
parentInitial commit. (diff)
downloadmagisk-ssh-2379a457a87afc9507f0f2a9664fcb47006a2aa2.tar.xz
Saner environment in SSH sessions, and automatically restart sshd.HEADmain
Diffstat (limited to '')
-rwxr-xr-xssh/run18
-rwxr-xr-xssh/setup-connection19
2 files changed, 37 insertions, 0 deletions
diff --git a/ssh/run b/ssh/run
new file mode 100755
index 0000000..470c91b
--- /dev/null
+++ b/ssh/run
@@ -0,0 +1,18 @@
1#!/system/xbin/bash -l
2
3SSHD="$(which sshd)"
4
5while true; do
6
7 nohup "$SSHD" \
8 -D \
9 -f "$MODDIR"/ssh/sshd_config \
10 -h "$MODDIR"/ssh/ssh_host_rsa_key \
11 -o "AuthorizedKeysFile $MODDIR/ssh/authorized_keys" \
12 -o "ForceCommand $MODDIR/ssh/setup-connection" \
13 > /dev/null &
14 wait
15
16 sleep 1
17
18done
diff --git a/ssh/setup-connection b/ssh/setup-connection
new file mode 100755
index 0000000..b0e59da
--- /dev/null
+++ b/ssh/setup-connection
@@ -0,0 +1,19 @@
1#!/system/xbin/bash
2
3export ANDROID_ASSETS=/system/app
4export ANDROID_BOOTLOGO=1
5export ANDROID_CACHE=/cache
6export ANDROID_DATA=/data
7export ANDROID_ROOT=/system
8export ANDROID_RUNTIME_ROOT=/apex/com.android.runtime
9export ANDROID_STORAGE=/storage
10export ANDROID_TZDATA_ROOT=/apex/com.android.tzdata
11export ASEC_MOUNTPOINT=/mnt/asec
12export DOWNLOAD_CACHE=/data/cache
13export EXTERNAL_STORAGE=/sdcard
14
15if [[ "$SSH_ORIGINAL_COMMAND" == "" ]]; then
16 exec /system/xbin/bash -i
17else
18 exec /system/xbin/bash -c "$SSH_ORIGINAL_COMMAND"
19fi