Android and Linux

Sunday, November 7, 2010

ssh error and fix

I've helped several people with this so I might as well post it here for others to stumble across. ssh can sometimes give this error:

stderr: ssh: Warning: failed creating //.ssh:
Read-only file system
stderr: Host '[my PC's ip address]' is not in the trusted hosts file

For some reason, ssh is trying to create it's hosts file in /.ssh, which is read-only, giving the error. For me, it happened when trying to use it in a script executed through GScript, but I believe it happens in other circumstances as well.

The solution that has worked for me and a few others is to replace the stock ssh binary in /system/xbin with a link to the ssh binary from Better Terminal Emulator Pro. Unfortunately, BTEP costs money but if you're using ssh or anything else from a terminal, I highly recommend buying it.

After you install Better Terminal Emulator Pro, back up the stock binary by typing this in a terminal:

mv /system/xbin/ssh /system/xbin/ssh.bak

Then put a link in /system/xbin to the BTEP ssh binary:

ln -s /data/data/com.magicandroidapps.bettertermpro/bin/ssh /system/xbin

This has been necessary every time I install an update because they always contain the stock ssh binary. Luckily, this fix has worked every time.

Followers