Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
SSH server on CyanogenMod Smaprtphones
adb root
adb remount
# Create a minimal but safe SSH Daemon configuration
cat <<EndOfSSHDConfigFile > sshd_config
# Minimal OpenSSH daemon configuration for CyanogenMod 10.1+
AuthorizedKeysFile /data/.ssh/authorized_keys
ChallengeResponseAuthentication no
PasswordAuthentication no
PermitRootLogin without-password
Subsystem sftp internal-sftp
pidfile /data/ssh/
# Install on Android device
adb push sshd_config /data/ssh/
# Install personal SSH public key on Android device
adb push ~/.ssh/ /data/.ssh/authorized_keys
# Create host keys and adjust file permissions on the device
adb shell ssh-keygen -A
adb shell chmod 600 /data/.ssh/authorized_keys
adb shell chmod 644 /data/ssh/sshd_config
# Create a service script for the SSH daemon
cat <<EndOfSSHDServiceScript >
# OpenSSH daemon startup script for Android CyanogenMod 10.1+
umask 077
# Generate host keys, if not already existing
ssh-keygen -A
if [ "1" == "$DEBUG" ] ; then
# run sshd in debug mode and capture output to logcat
/system/bin/logwrapper /system/bin/sshd -D -d
# don't daemonize - otherwise we can't stop the sshd service
/system/bin/sshd -D
# Install our service script on the Android device:
adb push /data/ssh/
adb shell chmod 755 /data/ssh/
adb shell mkdir -p /data/local/userinit.d
adb shell ln -s /data/ssh/ /data/local/userinit.d/90sshd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.