Mobileread
DX(G) KindleTERM - a SSH client kindlet
#1  vdp 11-17-2010, 05:15 AM
Hi,

I wrote a quick and dirty hack based on the MidpSSH J2ME SSH/telnet client, to make it run on Kindle. Well, I am somewhat hesitant on the 'quick' part, since it took me a good amount of time during the last 3 weeks, but it is certainly dirty . You can find the git repo on GitHub.

Thanks to Andrew de Quincey for making possible writing kindlets without the highly restricted Amazon development kit.

I've only had the opportunity to test it on my Kindle DXG, so I don't know how well it performs on other models.

I will describe the installation process in case someone is willing to try it.

The usual disclaimer applies: You should not take the steps described below unless you are comfortable about messing with your device and potentially bricking it. DO IT ON YOUR OWN RISK - if something goes wrong I will probably not be able to help you.

1) Copy the developer.keystore in /var/local/java/keystore directory. I wanted to use the AdQ's keystore used for KIF but unfortunatelly Ant's signjar task fails with message:

Code
[signjar] jarsigner: Certificate chain not found for: dkadq. dkadq must reference a valid KeyStore key entry containing a private key and corresponding public key certificate chain.
I am not all that familiar with the Java keystores so I am not sure yet what the problem is.
If someone have an idea how to fix it you are wellcome.

2) The Kindle framework's sandbox should be relaxed somewhat to allow SSH connections.
In /opt/amazon/ebook/security/external.policy after "grant signedBy "Kindlet" {" add the lines
Code
permission java.net.SocketPermission "localhost:1024-", "accept, connect, listen";
permission java.net.SocketPermission "192.168.2.1", "connect, accept";
permission java.net.SocketPermission "localhost", "connect, accept";
These changes permit connections to the kindlet, and from the kindlet to the localhost and usbnet host ip. Perhaps here is the place to say (as already mentioned by others on this forum) that the Amazon 3G access should be considered privilege rather than right, so I will not support any attempts to exploit the free 3G.

3) Copy the KindleTERM.azw2 to the 'documents' directory.

Known bugs and limitations:

- I am not sure if this is the case if you only make connections to the kindle (localhost), but I discovered that the connections from Kindle to other hosts are automatically disconnected after 2 or so minutes. If you want to prevent this you should stop netwatchd daemon.
Code
/etc/init.d/netwatchd stop
- MidpSSH tries to emulate a DEC vt320 terminal. It seems that it is not that common type of terminal so neither my Ubuntu 9.04 nor the Kindle have a terminfo description. I tried different terminfo files (e.g. the one from http://www.sunmanagers.org/archives/1995/1561.html) none of them work as it should for example in VIM. Don't know if the reason is the imperfect emulation in terminal.VT320 class, the way I use it in kindle.KindleTerminal or terminfo entries needs tweaking. Every help on this issue is very wellcome.

- Key events handling is far from perfect. For example there is still no way to emulate "TAB" on the device's keyboard. It should be trivial to fix though. I implemented also a "remote keyboard" feature - the kindlet listens to port 3333 for key events. On the host machine you can start:
Code
java -cp KindleTERM.azw2 kindle.RemoteKeyboard
and the keys you press when it's window is on focus are relayed to the kindlet.
It needs a java property file, named remote_keyboard.properties in the current working directory:
Code
host 192.168.2.2
port 3333
This feature is a potential security hole if you use it on a WiFi-enabled Kindle, so you should change your firewall accordingly.

- If you choose to save session info it is saved in plain text in the kindlet's 'work' directory so it is a security risk also.
Reply 

#2  NiLuJe 11-17-2010, 01:17 PM
Nice!

Here's a bunch of vt320 terminfo files (from the latest ncurses release), maybe one of them will help... .
Reply 

#3  vladm 11-17-2010, 04:35 PM
so just to confirm I understand this right - it runs as app on your kindle and allows you to connect via ssh either to the kindle itself or to a remote host - basically use kindle as ssh terminal / client?
Reply 

#4  Polvo 11-18-2010, 04:41 AM
Well done! I managed to install on my Kindle 3 (3G) and connect to localhost.
Reply 

#5  Elleo 11-21-2010, 04:05 PM
You can find vt320 terminfo in the ncurses-term package on Debian and Ubuntu, however I found that most ncurses based applications (irssi, mutt, etc.) still don't behave correctly with it.

The simplest solution I've come up with is to set the TERM environment variable to "ansi" instead of "vt320". i.e. run "export TERM=ansi" after logging in.
Reply 

#6  stormont 11-22-2010, 01:53 PM
Thank you
Reply 

#7  stasenko 12-05-2010, 02:24 PM
I try to connect to kindle with this params:
Code
host: localhost
port:22
username: root
password: (what value do I need enter to this field?)
connection log is
Code
Connecting to localhost:22 ...OK
...
...
...
Requesting authentication
Sent password
Sent password
Sent password
Sent password
Sent password
Sent password
Sent password
Sent password
Sent password
Sent password
What is wrong?
Reply 

#8  stormont 12-05-2010, 05:16 PM
Quote stasenko
I try to connect to kindle with this params:
Code
host: localhost
port:22
username: root
password: (what value do I need enter to this field?)
connection log is
Code
Connecting to localhost:22 ...OK
...
...
...
Requesting authentication
Sent password
Sent password
Sent password
Sent password
Sent password
Sent password
Sent password
Sent password
Sent password
Sent password
What is wrong?
telnet/ssh w/USB ethernet, then at root shell give your kindle a password - type 'passwd'
Reply 

#9  stasenko 12-06-2010, 01:19 AM
Quote stormont
telnet/ssh w/USB ethernet, then at root shell give your kindle a password - type 'passwd'
Thank you
Reply 

#10  ennerr 12-12-2010, 04:09 AM
Is there mapping for Ctrl key?

Thanks
Reply 

  Next »  Last »  (1/10)
Today's Posts | Search this Thread | Login | Register