[Nexus 4 Original Android Development] UnitedOceanic:
ok i try to keep it as noob friendly as i can :cool:

first we need some directories with the right permissions, we use the terminal emulator with root rights.

step 1:

open up the terminal and type these commands

su
mkdir -p /data/ssh/empty
chmod 700 /data/ssh
chmod 700 /data/ssh/empty

step 2:

now we need to generate the ssh keys and set the permissions on the keys

ssh-keygen -t dsa -f /data/ssh/ssh_host_dsa_key -N ""
chmod 600 /data/ssh/ssh_host_dsa_key
ssh-keygen -t rsa -f /data/ssh/ssh_host_rsa_key -N ""
chmod 600 /data/ssh/ssh_host_rsa_key

step 3:

now we create the key for the client authentication

mkdir -p /data/.ssh
chmod 700 /data/.ssh
ssh-keygen -t rsa -f /data/.ssh/id_rsa
chmod 600 /data/.ssh/id_rsa
cat /data/.ssh/id_rsa.pub > /data/.ssh/authorized_keys
chmod 600 /data/.ssh/authorized_keys
cp /data/.ssh/authorized_keys /data/ssh/authorized_keys
chmod 600 /data/ssh/authorized_keys

step 4:

now we need to edit the ssh config file to our needs and copy it to data so it will survive a rom update

cp /system/etc/ssh/sshd_config /data/ssh/sshd_config
chmod 600 /data/ssh/sshd_config

you could use vi or nano to edit the config file, i did it with droidedit pro, you could copy it to the sdcard first edit it with any text editor and copy it back. just be sure to set the permissions.

step 5:

we need to edit this lines:

line 39:

#PermitRootLogin yes

change to:

PermitRootLogin yes

line 45

#PubkeyAuthentication yes

change to:

PubkeyAuthentication yes

line 62

#PasswordAuthentication yes

change to:

PasswordAuthentication no

line 63

#PermitEmptyPasswords no

change to:

PermitEmptyPasswords no

line 66

#ChallengeResponseAuthentication yes

change to:

ChallengeResponseAuthentication no

line 114

Subsystem sftp /usr/libexec/sftp-server

change to:

Subsystem sftp internal-sftp

step 6:

start the ssh server

we can use this command in the terminal to start the ssh server:

/system/bin/sshd -f /data/ssh/sshd_config -D

or we use the start-ssh command/script in the terminal to do this we need to edit a line so it works with our configuration

line 35

/system/bin/sshd -f /system/etc/ssh/sshd_config -D

change to:

/system/bin/sshd -f /data/ssh/sshd_config -D

step 7:

copy the /data/.ssh/id_rsa file to the device you use to connect to your android

this is how i connect from my ubuntu laptop to my android:

i copied the id_rsa file to /home/<my_user>/.ssh/id_rsa

set the permissions to 600

my nexus 4 has the following IP in my network 192.168.0.100

so finally this is how i connect to the Nexus4

ssh root@192.168.0.100

as far as i know if you want too use putty on a windows os you will need to convert the key file with puttygen

Here is a prof screenshot :cowboy:

i always have the message on both server and client

void endpwent()(3) is not implemented on Android

i have no idea what it means but everything is fine

for now i have added "/system/bin/sshd -f /system/etc/ssh/sshd_config -D" to my default "at home" profile in tasker

when my screen is off connecting and typing is a bit sluggish

if you have a problem,

start the ssh server with "/system/bin/sshd -f /system/etc/ssh/sshd_config -D -d" this will enable the debug mode

and the client with "ssh -v root@192.168.0.100"

most importantly check for typos and the permission if you have errors.

good luck :good::good: