Cannot add host to "known_hosts" in Android I'm connecting from my Android handset to my NAS, using SSH.
The private key was generated on my PC and then placed in the sd card folder of the phone.
So I'm using the identity flag to tell ssh where to find the key file, so

ssh -i /storage/sdcard/key -p 1000 admin@192.168.10.10


Every time I try to connect I get the message that "the authenticity of host can't be established". So I am asked whether I want to continue connecting and I have to manually say "yes" every time.

For some the host cannot be added to known_hosts and so I get asked every time to confirm manually. I tried to find ".ssh" on my device but I can't find it.

Failed to add the host to the list of known hosts (/data/.ssh/known_hosts)


Can someone please help?

Thanks.

EDIT: I have manually created /data/.ssh/known_hosts but the problem persists
The reason could be insufficient permissions. An app cannot simply chose to create a directory below /data (other than its own, /data/&lt;package_name&gt;, which is already created by the Android system when the app is being installed). So this was why it failed in the first place.

Even after you used your "root powers" to create the /data/.ssh directory, and put a (most likely empty) known_hosts file there, the issue was probably the same: both where owned by the user who created them (root), and the app might not have been able to enter the directory, let alone to write into the file.

There are two possible solutions to this. The first you chose yourself was granting the app SUPER_USER privileges. If this is fine with you (and you trust the app for that), your issue is gone with that. Of course this requires the app to request the SUPER_USER permission, which it obviously does in your case.

A more restrictive approach would have been granting the correct privileges to the directory and the file, by e.g. chown it to the app's user, or chmod appropriately. If owned by that app, only this app would have access there, which would be the best solution. For this, you would first need to figure out the user, which could be done e.g. using ls -l /data/&lt;package_name&gt; (replace &lt;package_name&gt; with the package name of the app), and then do a chown -R &lt;user&gt;:&lt;group&gt; /data/.ssh.