I'm in Cyanogenmod 13 and I'm having troubles getting ssh working properly.

With AuthorizedKeysFile commented in the sshd_config file, I get a weird path in logcat:

Could not open authorized keys '//.ssh/authorized_keys': No such file or directory

I set AuthorizedKeysFile and the server seems to work with no more problems.

Still I cannot get the client working:

root@i9300:/ # ssh
Could not create directory '/.ssh'.
The authenticity of host ' (' can't be established.
ECDSA key fingerprint is SHA256:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)? yes
Failed to add the host to the list of known hosts (/.ssh/known_hosts).
Permission denied (publickey).

As you can see ssh is trying to create the directory /, and we all know that it is not possible.
All of this led me to the conclusion that there might be something wrong with the environment variable HOME.

Another piece of information:

root@i9300:/ # echo $HOME
root@i9300:/ # su shell
shell@i9300:/ $ echo $HOME

Many thanks in advance for your help!

  • Try storing the identity file somewhere in /sdcard/ and use -i IDENTITY_FILE and provide config using -F. $HOME is perfectly fine. Permissions on /data are beyond the privilege shell user can have.
    – Firelord
    Commented Jan 9, 2016 at 18:55
  • Thanks @Firelord, it works! ssh -i /data/.ssh/id_rsa does the job. I'd be very happy if someone could tell me where a template for ssh_config file is, it doesn't seem to exist. The problem of creating /.ssh/known_hosts remains. I managed a workaround creating the symlink /.ssh -> /data/.ssh/. It is not possible to create it by shell/script because I get error Read-only file system (even with /system mounted rw). I did manage with CMFileManager, and I wish I knew how it has done it!! /.ssh will disappear at every boot and I'd like to create a script to sort this out
    – Claudio
    Commented Jan 12, 2016 at 21:01

1 Answer 1


Here is a solid workaround which requires a bit of work if you are not accustomed with the subject:
Edit BOOT partition.

In the BOOT partition (boot.img) are stored all the files that will be loaded in / at boot.
I added a symlink in it:

.ssh -> /data/.ssh

Here are two very helpful tutorials that will get you going:
HOWTO: Unpack, Edit, and Repack Boot Images
Android boot.img manipulation

a little hint:
Do edit the ramdisk in your Android device.
I spent three days in frustration trying to do so in my pc, I guess is a matter of "endianness".

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .