/usr/sbin/wifi.sh and phone/laptop file transfers

versatile 64-bit multi-user Linux distribution

Moderators: kirk, jamesbond, p310don, JakeSFR, step, Forum moderators

Post Reply
fatdoguser
Posts: 175
Joined: Sat Aug 05, 2023 10:54 am
Has thanked: 22 times
Been thanked: 79 times

/usr/sbin/wifi.sh and phone/laptop file transfers

Post by fatdoguser »

There's a great little cli script /usr/sbin/wifi.sh that I'd propose you give it a try ... it's :thumbup2:

Set your android phones hotspot up and even with both the phones and laptops wifi and data disabled/disconnected running that wifi.sh script on your laptop should be able to find and connect to the phones wifi hotspot (antenna).

If you've set up your phone to have termux (from f-droid) installed, and within termux installed openssh, then running sshd within termux has it listen on port 8022 for ssh connections, when you initially wifi.sh connect to the phones hotspot from your laptop it shows the allocated IP address 192.168.200.100 (or whatever) and also the gateway IP address 192.168.200.110 or whatever and its that gateway IP that you ssh into from your laptop, so for example run ssh 192.168.200.110 -p 8022 in a terminal on your laptop

For the ssh password just run passwd within termux and enter whatever password you prefer.

It's nice being able to use your laptop keyboard/screen for running your phones termux terminal. If you also set up sshd on your laptop, or ftpd (the busybox version works fine), then you can scp or ftp files between the phone and laptop, and all without wifi or data being activated, so relatively secure.

Notes :

I installed termux from f-droid, i.e. used the phones chrome to visit the f-droid.org web site and install f-droid, which android didn't like, repeated warnings of 'not a recognised repo', but that I just ignored (accepted). Once f-droid app was installed I opened/used that to find and install termux emulator. With termux installed and opened I ran ...

Code: Select all

pkg install openssh
pkg update
pkg upgrade

Also in termux ran

Code: Select all

ssh-keygen
ssh-keygen -A

to create the user and server ssh keys files/folder

After that and running sshd in termux worked OK, just silently starts sshd in the background.

Running termux-setup-storage ... sets up a sub folder with sym-links to the phones main movies/pictures ..etc folders, making it easier to see/transfer files, you just have to select a video/picture and transfer that to the 'internal' videos/pictures storage area that termux can see.

For your laptops ftp server I found the easiest way was to use the regular busybox ftpd, run through tcpsvd i.e. syntax ...

tcpsvd -vE 0.0.0.0 21 ftpd -wA /root

where the -wA switches for ftpd permit uploading (write (w)) and automatic login (no password prompted), the /root final parameter is whichever folder you want the ftp server to serve/show.

fatdoguser
Posts: 175
Joined: Sat Aug 05, 2023 10:54 am
Has thanked: 22 times
Been thanked: 79 times

re-purpose a old phone as a web server PLUS

Post by fatdoguser »

Once you have f-droids version of termux installed, also use the f-droid app to search for and install termux:API. Additionally within termux run

Code: Select all

pkg install termux-api

Now when you ssh into your phones terminal, and have a nice sized screen and keyboard rather than trying to type things in on the phone, you can start creating scripts to do a range of things

https://wiki.termux.com/wiki/Termux:API#Settings

Have the phone take a picture for instance

Code: Select all

termux-camera-photo snap.jpg

or turn the torch on before taking the picture and then turn the torch off again

Code: Select all

termux-torch on;termux-camera-photo snap.jpg;termux-torch off

Have the phone record (mic) for a number of seconds, send a sms message, call a telephone number, turn the torch on ...etc. and along with other commands such as ftp, ssh, scp ..etc. .... is limited only by your imagination. Perhaps a old phone that's no longer used because of a scratched screen/whatever, but that still works - could be set up as a http server (I don't know about the risks of leaving a phone permanently on charge, could in some cases have the lithium battery burst into flames I guess? Maybe the phone however might still work with no battery inserted, just the mains power chord powering it?).

Note that for some functionality you'll have to have granted the permissions in ... settings, apps, termux-API, permissions ... such as phone, sms, camera, mic being permitted/enabled.

Post Reply

Return to “FatDog64”