View Single Post
Old 05-08-2023, 07:47 PM   #1
elinkser
Addict
elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.elinkser has survived committing the World's Second Greatest Blunder.
 
Posts: 231
Karma: 146236
Join Date: Oct 2022
Device: Kobo Clara HD
Quitting Telnet Habit

Quitting Telnet Habit

I wanted to quit telnet and turn off devmode ( Go to the Discover tab and search the store for "devmodeoff").
This means I lose a few games and the "ForceWifiOn=true" option in [DeveloperSettings] in the /mnt/onboard/.kobo/Kobo/Kobo eReader.conf file.
But in exchange , insecure telnet doesn't start by default.





***

* UPDATE: You do NOT need DEVMODEON to set the "ForceWifiOn=true" option in [DeveloperSettings] in the /mnt/onboard/.kobo/Kobo/Kobo eReader.conf file.

(In a goodereader article I had read that):

Quote:
"When developer mode is enabled you will see all sorts of games such as Sudoku, Unblock it, Solitaire (with 6 different game types)* and Word Scramble. There is also the old Kobo Sketchpad app, which allows you to draw on the screen with your finger or use a capacitive stylus...
"Under Settings and Device Information is where you will find the vast majority of the developer features. You can force WIFI on, so it will never be automatically disabled..."
https://goodereader.com/blog/kobo-er...eloper-options

Nor will DEVMODEOFF cause you to not have access to sketchpad.

So while the it might have been true at the time of the goodereader article, you no longer are deprived of these features in DEVMODEOFF.

I tested it that WiFi shuts off automatically after 1-2 minutes of inactivity, but will stay on if "ForceWifiOn=true" in [DeveloperSettings] in the /mnt/onboard/.kobo/Kobo/Kobo eReader.conf file, EVEN IF DEVMODEOFF.

Also, interestingly, "EnableDebugServices" stops and starts telnet, ftp, and logread from running automatically even if DEVMODEOFF.
Unfortunately, it also stopped my oskansi fbpad terminal from working.
I will need to investigate that..,And it's back. Just need to run Dropbear or even telnet from NickelMenu beforehand, and oskansi communicates with fbpad again.

* Edit: Mobileread wiki explained EnableDebugServices
https://www.mobileread.com/forums/sh...44&postcount=5

***




To help me break the habit, I will use a NickelMenu entry to call KOReader's ssh server:

menu_item :main : Dropbear (toggle) :cmd_output :500:quiet :/usr/bin/pkill -f "dropbear"
chain_success:skip:5
chain_failure :cmd_spawn :quiet :/bin/mount -t devpts | /bin/grep -q /dev/pts || { /bin/mkdir -p /dev/pts && /bin/mount -t devpts devpts /dev/pts; }
chain_success :cmd_spawn :quiet :export HOME="/mnt/onboard/.adds/koreader/" && cd "$HOME" && /mnt/onboard/.adds/koreader/scripts/dropbear -E -R -p2222 >/mnt/onboard/.adds/koreader/DropbearLog.txt 2>&1
chain_success :dbg_toast :Started Dropbear server on port 2222
chain_failure :dbg_toast :Error starting Dropbear server on port 2222
chain_always:skip:-1
chain_success :dbg_toast :Stopped Dropbox server on port 2222


Edit: changed logfile name to DropbearLog.txt to display multiline log file using browser from NickelMenu (requires WiFi enabled):

menu_item : main: Dropbear Log :nickel_browser : modal :file:///mnt/onboard/.adds/koreader/DropbearLog.txt


For anyone not already aware, an advantage of ssh over telnet (besides not transmitting passwords in cleartext,lol) is using scp to transfer files from your PC to your Kobo over ssh, or vice versa.
(I access the Kobo from the PC to do both directions, so as not to be accessing my precious PC from the questionably secure Kobo).


You can use the scp command with the help of our new NickelMenu entry (if you prefer that over starting ssh from within KOReader, or installing/extracting from NiLuJe's kobostuff suite of tools package.)


To copy the file "bla.txt" from your PC to your kobo's /mnt/onboard/.adds/koreader/ directory:

$ scp -P 2222 bla.txt root@192.168.2.2:/mnt/onboard/.adds/koreader/
root@192.168.2.2's password:
bla.txt 100% 11 8.9KB/s 00:00
[root@kobo koreader]# cat bla.txt
blablabla


Make some changes to bla.txt on your Kobo and copy it back to your PC:

$ scp -P 2222 root@192.168.2.2:/mnt/onboard/.adds/koreader/bla.txt .
root@192.168.2.2's password:
bla.txt 100% 19 13.1KB/s 00:00
$ cat bla.txt
blablabla
hahaha



***
IMPORTANT NOTE: FOR SCP, THE TRAILING '/' IN /mnt/onboard/.adds/koreader/ MEANS THE CONTENTS OF THE DIRECTORY.
IF WE HAD LEFT OUT THE '/', AS IN /mnt/onboard/.adds/koreader, IT WOULD MEAN THE ENTIRE DIRECTORY /koreader !!!
***


Let's set up passwordless login from your PC to Kobo:
*** WARNING - POTENTIAL SECURITY VULNERABILITY IF YOU ARE LOGGING IN FROM KOBO TO PC***
*** KOBO VFAT FILE SYSTEM ON /MNT/ONBOARD PARTITION IS WORLD READABLE, NOT THAT THE ROOT PARTITION WOULD BE THAT SAFER ON A COMPROMISED KOBO***

$ ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (~/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in ~/.ssh/id_rsa.
Your public key has been saved in ~/.ssh/id_rsa.pub.
The key fingerprint is:
...

$ ssh-copy-id root@192.168.2.2 -p 2222
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "~/.ssh/id_rsa.pub"
/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
root@192.168.2.2's password:
Number of key(s) added: 1
Now try logging into the machine, with: "ssh -p '2222' 'root@192.168.2.2'"
and check to make sure that only the key(s) you wanted were added.


Now log back in to move the keys to where dropbear expects them:

$ ssh root@192.168.2.2 -p 2222
root@192.168.2.2's password:

# ls -al /.ssh/authorized_keys
-rw------- 1 392 /.ssh/authorized_keys

# ls -a /mnt/onboard/.adds/koreader/settings/SSH/
. dropbear.pid dropbear_rsa_host_key
.. dropbear_ecdsa_host_key

# cp /.ssh/authorized_keys /mnt/onboard/.adds/koreader/settings/SSH/

# ls -l /mnt/onboard/.adds/koreader/settings/SSH/authorized_keys
-rwxrwxr-x 1 392 /mnt/onboard/.adds/koreader/settings/SSH/authorized_keys

*** IF YOU HAD BEEN ACCESSING PC FROM KOBO, SOMEONE WHO ACCESSED YOUR KOBO COULD HAVE USED YOUR KOBO'S PRIVATE KEYS TO LOGIN TO YOUR PC ***
*** FORTUNATELY WE ARE ACCESSING KOBO FROM PC SO THEY ONLY GET PC PUBLIC KEYS, AND KOBO PRIVATE KEYS WHICH WE WILL NOT USE ***

# exit
Connection to 192.168.2.2 closed.


Now try passwordless login:

$ ssh root@192.168.2.2 -p 2222
[root@kobo ~]#

Now make some more changes to bla.txt on your Kobo and copy them back to PC:

[root@kobo ~]# cd /mnt/onboard/.adds/koreader/
[root@kobo koreader]# vi bla.txt
blablabla
hahaha
hi ma!
[root@kobo koreader]# exit
Connection to 192.168.2.2 closed.

From your PC:

$ scp -P 2222 root@192.168.2.2:/mnt/onboard/.adds/koreader/bla.txt .
bla.txt 100% 25 9.7KB/s 00:00

$ cat bla.txt
blablabla
hahaha
hi ma!

***

This works over USB cable as well.

FOR NETWORKING (E.G. SSH) OVER USB CABLE INSTEAD OF WIFI:
See instructions at https://www.yingtongli.me/blog/2018/...elnet-usb.html

Essentially you are creating scripts usbtoeth and usbtoethd in /mnt/onboard/opt/

usbtoeth:
#!/bin/sh
insmod /drivers/mx6sll-ntx/usb/gadget/configfs.ko
insmod /drivers/mx6sll-ntx/usb/gadget/libcomposite.ko
insmod /drivers/mx6sll-ntx/usb/gadget/u_ether.ko
insmod /drivers/mx6sll-ntx/usb/gadget/usb_f_ecm.ko
insmod /drivers/mx6sll-ntx/usb/gadget/usb_f_eem.ko
insmod /drivers/mx6sll-ntx/usb/gadget/usb_f_ecm_subset.ko
insmod /drivers/mx6sll-ntx/usb/gadget/usb_f_rndis.ko
insmod /drivers/mx6sll-ntx/usb/gadget/g_ether.ko
ifconfig usb0 192.168.2.2

usbtoethd:
#!/bin/sh
ifconfig usb0 down
rmmod g_ether usb_f_rndis usb_f_ecm_subset usb_f_eem usb_f_ecm u_ether libcomposite configfs


Instead of automatically enabling it, I created a nickel menu item:

menu_item :main :USB Networking on :cmd_spawn :quiet:exec /mnt/onboard/opt/usbtoeth
chain_success :dbg_toast :Started USB networking
chain_failure :dbg_toast :Error
menu_item :main :USB Networking off :cmd_spawn :quiet:exec /mnt/onboard/opt/usbtoethd
chain_success :dbg_toast :Stopped USB networking
chain_failure :dbg_toast :Error


So to connect the Kobo with my desktop over the USB cable:
1.On Kobo, select"USB Networking on" from the nickel menu.
2.Connect the USB cable between Kobo and Desktop.
3.The network applet icon on the desktop (/usr/bin/nm-applet from the network-manager-gnome package) will be a spinning progress bar, like it's trying to connect on ethernet. Click this icon and choose "disconnect".
4.On desktop terminal enter "sudo ifconfig usb0 192.168.2.1" and you will be connected.(Or at least I would be.)


****

From the Kobo you can run KOReader terminal's own file manager, shfm:

# sh plugins/terminal.koplugin/shfm

Or, run the ". ./korenv.sh" command listed here , to set the path:

#!/bin/sh
export PATH=$PATH:/mnt/onboard/.adds/koreader/scripts:/mnt/onboard/.adds/koreader/plugins/terminal.koplugin/
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/mnt/onboard/.adds/koreader/libs
export TERM=xterm
export HOME=/mnt/onboard/.adds/koreader/
cd $HOME

Then you can run the file manager as just:

# shfm

'?' show help in shfm:

Spoiler:


j - down
k - up
l - open file or directory
h - go up level
g - go to top
G - go to bottom
d - toggle printing directories first
q - quit
: - cd to <input>
/ - search current directory <input>*
- - go to last directory
~ - go home
! - spawn shell
. - toggle hidden files
? - show keybinds
tab - next tab (or prev tab if shift is held)
1-4 - move to tab 1-4
space - select (or deselect) current item
p - copy selected items to current folder
v - move selected items to current folder
x - trash selected items (permanently delete if in trash)
t - go to trash
r - bulk rename
a - select all
A - invert selection
n - create new file or directory





************

Actually, I haven't even been using scp because you can just use an SFTP-capable file manager to manipulate files on your kobo from the comfort of your PC.
For example, Thunar comes standard with the Xfce desktop, and allows you to seamlessly handle files on your Kobo over SSH.
There are many other SFTP-capable file managers such as PCManFM for lxde.

On android, you can use SFTP-capable Ghost Commander, but I had to use an older version to get an SFTP plugin combination that worked on my older phone:
https://sourceforge.net/projects/gho...er%20versions/

The two apk files that worked for me were:
https://sourceforge.net/projects/gho...3.apk/download
and:
https://sourceforge.net/projects/gho...1.apk/download


****

Last edited by elinkser; 01-18-2024 at 02:59 PM. Reason: shfm,devmode,wiki
elinkser is offline   Reply With Quote