Installing USBNetwork (SSH service) on Kindle

This enables you to connect to your Kindle via SSH using USB connection. With some further settings, you can SSH with WiFi.

Prerequisites

  • You have a jailbroken Kindle. If not, you can refer to this post.
  • Both KUAL and MRPI are installed. If not, refer to this post.

Installing

  1. Go to the Snapshots page on MobileRead.
  2. Under the right product category, find the USBNetwork Hack. Download the .tar.xz file.
  3. Extract the downloaded file, select the correct Update_usbnet_*.bin file. There are multiple update files for different devices, so make sure you select the correct one!
  4. Connect your Kindle to your computer via USB cable. Confirm it’s in USB Drive Mode.
  5. Place the selected file in Step 3 in /mrpackage/ under your Kindle’s root folder.
  6. Disconnect Kindle from the computer.
  7. Go to KUAL--Helper--Install MR Packages, install the USBNetwork.

SSH via USB

After installing by default, this is the only possible way to connect. Depending on the OS, some of the following steps can differ:

  1. Turn on the SSH server on the Kindle by typing ;un in the search bar then press Enter. This will start the server with its IP as 192.168.15.244 which expects a incoming connection from 192.168.15.201.
  2. Configure the network on the client side:
    • macOS: System Settings--Network--RNDIS/Ethernet Gadget--Details--TCP/IP
      • Configure IPv4: Manually
      • IP Address: 192.168.15.201
      • Subnet Mask: 255.255.255.0
      • The red dot indicating the network should turn green
    • Linux: ifconfig usb0 192.168.15.201
    • Windows: Please check the Windows section of this post.
  3. Connecting to server: ssh root@192.168.15.244. No password, so just press Enter.

SSH via WiFi

Now that you have the remote access to your Kindle, you can also turn on the SSH connection via WiFi. There are two reasons that you might want to do this:

  1. The connecting is easier as you don’t have to do the plugging and unplugging.
  2. It might be easier for the debugging as the Kindle being charged while connecting via USB might influence some system behaviors which make the debugging difficult.

This can be enabled by:

  1. Change USE_WIFI option to TRUE for /mnt/us/usbnet/etc/config
  2. Restart SSH server in KUAL

Then disconnecting the Kindle from the computer, the server can be accessed by ssh root@YourKindle'sIP (usually it’s 192.168.0|1.x).

Some tidying up

Some of the below are not closely related to SSH but they become a problem once SSH connection is possible.

Start SSH service on boot

  1. SSH into Kindle
  2. touch /mnt/us/usbnet/auto

Show logs while starting Kindle

  1. SSH into Kindle
  2. touch /mnt/us/usbnet/verbose

This will show some logs at the bottom of the screen while Kindle is starting.

Give Kindle a static IP

If you want to use SSH via WiFi consistently, it is recommended to use DHCP to give Kindle a static local IP. This can be achieved by a router.

Set a password for root user

This is a major security risk with incoming SSH connection. Essentially without password anyone within your LAN has the access to your Kindle.

  1. SSH into Kindle
  2. passwd, then enter your new password

Attention, next time when you want to Ssh into your Kindle, you should use the newly-set password.

Use pub key authentication

This is more convenient and securer than a password login. The steps are below:

  1. Run ssh-keygen on your client machine. Enter the name you would like it to have. In the end it gives you a private key xxx and a public key xxx.pub.
  2. Copy the xxx.pub to /mnt/us/usbnet/etc/ using scp, rename it to authorized_keys
  3. Copy xxx to the .ssh folder on your client machine.

Now you should be able to connect your Kindle with pub key authentication.

Some more tweaks

Similar as the SSH service on another Linux machine, there exists a sshd config file in Kindle’s system (/mnt/us/usbnet/etc/sshd_config). There you can do things like turning off password login, restrict login IPs and adjusting port etc.

Closing remarks

Connecting to Kindle via SSH to be honest is not that straightforward comparing to other Linux machines. However, this is not all impossible by following the previously mentioned steps. This exposes the system files to us and make possible further tweaking of the system via scripting.