Updated Sunday, January, 24 2013, trying to address all issues raised in the comments below.
I have used Android QuickSSHd in the past to connect my Android devices with my Linux desktop. Since I installed CyanogenMod 10.1 nighty builds on them, none of the known SSH apps seem to work anymore. The Cyanogen wiki has a page about how to setup the Dopbear SSH daemon, but also states that since CynogenMod 9.x it is no longer included.
Apparently the original OpenSSH_6.0p1 is included with Android 4.2.1 (JellyBean) although it is not configured
and support for sftp is missing. Here is what I did to have it up and running.
Download the sftp-server Android binary from this comment on Google code.
On my desktop I created a SSH daemon configuration file
# 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/sshd.pid
Copy the created configuration file and my SSH public key to the Android device in the appropriate directories:
adb root adb remount adb push sshd_config /data/ssh/ adb push ~/.ssh/id_rsa.pub /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
Its time to do a connection-test.
Find out the current IP address of the Android device:
adb shell ip addr show|grep 'inet ' inet 127.0.0.1/8 scope host lo inet 192.168.1.101/24 brd 192.168.1.255 scope global wlan0
Start the SSH daemon in debug mode on the Android device:
adb shell /system/bin/sshd -d
… then connect your SSH and SFTP clients in verbose mode:
ssh -v firstname.lastname@example.org sftp -v email@example.com
If all works out, we tell the Android device to start the SSH-daemon automatically as service on boot. For this we first need to create a service-script called
sshd-start.sh on our Desktop computer:
#!/system/bin/sh umask 077 # DEBUG=1 # # Generate rsa1, rsa, dsa and ecdsa 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 else # don't daemonize - otherwise we can't stop the sshd service /system/bin/sshd -D fi
Let’s install our service script on the Android device:
adb push sshd-start.sh /data/ssh/ adb shell chmod 755 /data/ssh/sshd-start.sh adb shell mkdir -p /data/local/userinit.d adb shell ln -s /data/ssh/sshd-start.sh /data/local/userinit.d/90sshd
Sourcecode for OpenSSH in Android CyanogenMod is found here.