File exchange between android and (L)Ubuntu: wirelessly

Hi all, :wave: :christmas_tree:

I was wondering whether there would be a way of transferring data (like pics or mp3-files) between my android smartphone and my Lubuntu PC wirelessly :question:

I´m not keen on connecting cables if it can be avoided. So I looked around a bit on the net and found kdeconnect.

Lubuntu has it installed by default as it turned out. So all I had to do is install “KDE Connect” from the f-droid store on the phone
(KDE Connect | F-Droid - Free and Open Source Android App Repository ).

O.K. That went well but then I ran into difficulties. :slightly_frowning_face:
My “special scenario” is the following:

I don´t have a DSL router to which both the Lubuntu PC and android could connect at the same time. Lubuntu has its own mobile 4G-stick connection and android has its mobile connection. Both are separate from each other of course.

So the prerequisite “both devices have to be on the same network” can´t be fulfilled. :thinking:

Hmm, then I tried the following: I created a hotspot on Lubuntu: I.e. Lubuntu is connected to the internet via the 4G-stick stick but provides a hotspot via a wlan dongle.

This works well, as I can connect the smartphone to the hotspot this way (de-activating its mobile connection first) and can thus access the internet on the phone. :+1:

But I guess this isn´t the same as “both devices being on the same network”, right :question:
Neither does android see Lubuntu via the “KDE connect” app nor does Lubntu see the phone.

Hmm, I´m a bit stuck here. Is there any other way of getting Lubuntu and android to exchange files wirelessly?

Many thanks in advance for your help.

Season´s greetings from Rosika :slightly_smiling_face: :santa:

Happy Christmas

I dont know what phone you have, but some can do “near device scanning”
where each device will ask for permission to download or upload stuff, and away you go

Perhaps it will work

Bluetooth should be possible, with 0bill0’s “near device scanning” being likely a variation of same.

At another level is X-plore :slight_smile:

https://www.lonelycatgames.com/apps/xplore/

It will do most anything if you can delve into it…

Hi Rosika,
There are a number of apps ( including Termux) that will make your mobile phone an ssh client.
There are also some apps that will setup ftp.

Regards
Neville

Hi all, :wave: :christmas_tree:

thanks so much for your replies even on Christmas. :heart:

@0bill0 and @kgwoo:

Thanks for the suggestion. Yet somehow that doesn´t seem to work with me.

Sorry. I forgot to mention that. It´s a Samsung A04s with Android 12 on it.

Bluetooth isn´t available on my main PC. So that leaves the ssh-connection (or ftp) @nevj suggested.

@nevj:

Thanks, Neville.

As I have termux installed already this seems to be the way to go. I´ll look into it.

I guess I´d have to install openssh on termux first.
Thanks again. :heart:

Many greetings from Rosika. :slightly_smiling_face: :santa:

UPDATE:

I´ve installed opensssh on termux now. For that I was basically following the instructions given on
https://linuxconfig.org/ssh-into-linux-your-computer-from-android-with-termux .

I installed it with pk in openssh and some basic settings were taken care of automatically, it seems.
So I did not not do the command
ssh-keygen -b 4096 -t rsa as suggested.

Still I could not connect to my main PC.

I tried ssh rosika@[Public_IP_address_of_my_Lubuntu_PC] but it didn´t work. :slightly_frowning_face:
Surely I´m doing something wrong here…

Hmm. Strangest thing:
Cannot ping my Lubuntu PC either.
From termux:

ping [Public_IP_address_of_Lubuntu]

yields 100% packet loss. :thinking:

1 Like

@Rosika Some routers and hot spots have an option called ‘client isolation’. So even though the PC and phone are on the same network they are isolated from each other on purpose. This is useful for a public hot spot or on a home router if you provide a second WiFi network for visitors to use that is isolated from your main WiFi network. Those on the visitor’s WiFi network are also isolated from each other.

Check to see if there is a setting like that in the hot spot.

2 Likes

Years ago (I’m talking like 10 or something) I used to use something called AirDroid I think - basically ran a web server on the phone that let you upload or download files… From memory the “free” version had limits on how much data you could copy back and forth - if you wanted more - you had to pay…

I think there was also a Samsung product that did similar called Samsung Kies…

I mostly used AirDroid 'cause the early implementations of MTP over USB were BROKEN on Linux - so I’d use AirDroid to get round that…

I mostly use adb-sync (its like rsync) over USB these days - it does have a wireless “version” but I’ve never been able to get that to work.

There’s also TermUX - i.e. you can scp / sftp and even rsync - i.e. either

  • run sshd within termux (note - it doesn’t use port 22 - uses 8022
  • in termux, using the shell / CLI run scp or rsync to push, or pull, data

Hi Rosika,
Reasons for ping failing
https://bytesofgigabytes.com/networking/ping-is-not-working/

I tried to replicate what you have. Can not get openssh to install in Termux. Some issue with repositaries. My termux can ping the modem, so ping works in Termux.

UPDATE
Fixed the ssh install issue
Setup WiFi hotspot in my PC
Shifted my tablet from modem WiFi to PC WiFi
Can ping the PC from Termux
My ssh in Termux fails, but I can use ftp

$
$
$ ssh trinity
CANNOT LINK EXECUTABLE "ssh": library "libcrypto.so.3" not found
Aborted

$ ftp trinity
Connected to trinity.
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 50 allowed.
220-Local time is now 16:11. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Name (trinity:u0_a302): nevj
331 User nevj OK. Password required
Password:
230 OK. Current directory is /home/nevj
ftp> bye
221-Goodbye. You uploaded 0 and downloaded 0 kbytes.
221 Logout.
$ 

Not sure what is going on with ssh, but i cant find libcrypto anywhere.
I can reach the internet from Termux thru the PC WiFi link.

FURTHER UPDATE
ssh is ok now in Termux. I needed the package openssh-tool

I think @Rosika 's ping problem is probably due to a firewall in the PC not allowing an incoming connection.

Regards
Neville

I forgot to mention - to be able to see the “stuff” in your TermUX folders - you probably need to run “termux-setup-storage”…

Because I have to run the somewhat shonky older version of Termux from the Play Store, 'cause my handset is CRIPPLED by Knox, I can’t directly access the SD-Card from inside TermUX - I think with the FDroid one, you can… unable to confirm or deny as Samdung’s crippleware prevents me using F-Droid (or installing apps from F-Droid, I was able to install it as an APK using adb).

I didn’t read the complete discussion but I think an easy way should be to use to install Warpinator and connecting your devices via the same wlan. In my case it worked perfectly.

Welcome @rodolfo_81825 ,
I have tried Warpinator. It worked for be too, but my trial was with bluetooth, not Wifi. It should work with any type of connection.
Regards
Neville

Yep.
That works. As long as the two are on the same network of course.

Hi all, :wave:

I hope you all had a nice Christmas. :christmas_tree:
Thanks a lot for so many replies. :heart:

@pdecker:

Thanks for the explanation referring to “client isolation”. Didn´t know that.

I checked. There seems to be nothing of the kind with me.
Never mind. But there´s still the issue of not being able to ping my PC… :thinking:

Well, that´s not the case with me either. No same network, as my android phone and my Lubuntu PC are connected to the internet via their own mobile connection…

@daniel.m.tripp:

Never heard of airdroid before. Thanks for mentioning it. I´ll take a look at it.

That´d be my favourite of course. But I can´t get either ping or ssh working on termux.
I even switched off the firewall on Lubuntu to see whether it had any effect on the outcome.
Well, it didn´t. :frowning_face:

sshd is running in temrux; so that can´t be it.

Thanks. I already did that after installing termux. :wink:

@nevj:

Thanks a lot, Neville, for the link. I looked through it but alas couldn´t find anything applicable to my scenario.

How good of you to try out so much stuff yourself. It´s highly appreciated. :heart:

These are the steps I followed, too. But neither can I ping the PC from termux nor does ftp work… :slightly_frowning_face:

Well, nothing works as expected despite having my firewall turned off for experimental purposes.

Thanks a lot anyway.

@rodolfo_81825 and @7blade

Thanks for the suggestion. I´ll look up warpinator.
But the “same network” will surely be a stumbling block for me.

Well, if everything fails I think I could still send files as an e-mail attachment to myself and thus get mp3 or picture files from one device to another.
However they can´t be too large in size for that to work…

Thanks a lot to all of you.

Many greetings
Rosika :slightly_smiling_face:

1 Like

So, assuming you are trying to connect “remotely”, you will need to make sure you can ping your intranet node.
You will most likely need to set up a remote access system on your PC.

1 Like

Did you go to ‘connections’ in your phone and change it from the mobile system to the hotspot?

You may have to turn on ‘nearby device scanning’ to get the hotspot to show in the list of connections.

Android can only use one connection at a time.

Regards
Neville

1 Like

By default (and design?) sshd doesn’t run on port 22 in TermUX - on my handset it runs on 8022… I can’t remember if I set that manually somewhere - but - given I removed it once, tried to install via F-Droid, didn’t work, re-installed, it was a fresh “Vanilla” install - so I’m guessing 8022 is the default in TermUX.

Here’s the stanza from my ~/.ssh/config :

Host    homedung dunghome
        Hostname        x.x.x.x
        User u0_a206
        Port 8022

It always gets the same IP (i.e. what would normally be in x.x.x.x) - I’ve got a fixed IP DHCP lease setup in my router… and it doesn’t present itself over avahi / bonjour / zeroconf - so I was having to find out my phone’s IP address, then editing my ~/.ssh/config - that got tired very quickly…


Note also : I’ve NEVER had to tweak any localhost firewall doohickeys - not on 22.04 or 22.10 or MacOS… it just “works”… :slight_smile:

✅ Desktop Ubuntu 22.04 SSH to port 8022 on my Galaxy 
✅ Laptop Ubuntu 22.10 SSH to port 8022 on my Galaxy
✅ MacBook Pro M1 MacOS 12.6 SSH to port 8022 " " "
✅ ditto 
✅ Raspberry Pi4 Debian 10 : ssh to phone
✅ Raspberry Pi3 Debian 9 : ssh to phone
1 Like

Hi all and thanks a lot for your replies, :wave:

@7blade:

I see. Thanks. I´ll do some research on that matter.

@nevj:

Yes, Neville. That I did of course. :wink:

Well, as I did my experiments the day before yesterday I have to admit I cannot remember that particular point. So I repeated the action .

  • turned on “nearby device scanning”
  • connected to the hotspot provided by Lubuntu PC
  • issued pings

When trying to ping the PC´s global IP … that didn´t work

but:

pinging the PC´s local IP address now worked: :+1:

ping 192.168.8.100 gave me “0% packet loss” now.

As I can ping Lubuntu now perhaps ssh-ing into it from android may be possible as well…?

Thanks so much, Neville. :heart:

@daniel.m.tripp

I see.
Seems you have had quite some success with a varietey of devices.

UPDATE:

I got it working now. :innocent:

Following @nevj ´s advice

  • I turned on ‘nearby device scanning’
  • I also turned off the firewall on Lubuntu (otherwise it wouldn´t work)
  • now ssh-ing into Lubuntu works. :+1:

Quite and eerie experience to be able to run programmes on the smartphone that aren´t even installed here.
Well, course they run on Lubuntu (my fish history in Lubuntu tells me what I have done on android).
But it seems like doing stuff on android… :wink:

So - as next step - I´ll have to find out how to transfer files…

Many thanks to all and many greetings
Rosika :slightly_smiling_face:

1 Like

As you’ve got ssh client working - you can just pull using scp, or even rsync over ssh… You’ve already said you’ve run termux-setup-storage - you should be able to see data in your Termux folders, from elsewhere on your phone…

e.g. on your Lubuntu machine … well - here’s me in ZSH on my Ubuntu 22.04 desktop :

  1. I’ve got two entries for my phone in ~/.ssh/config (it’s actually ~/.ssh/home and reference as an include in my ssh config) - the “homedung” entry uses the fixed DHCP lease IP address it gets over WiFi from my router :
╭─x@titan ~  
╰─➤  grep -A 4 homedung .ssh/home
Host	homedung dunghome
	Hostname	RE.DAC.T.ED
	User u0_a206
	Port 8022

Don’t need to even specify that it’s SSH - rsync does that automagically :

╭─x@titan ~/ResilioSync/Music/Rammstein  
╰─➤  pwd
/home/x/ResilioSync/Music/Rammstein
╭─x@titan ~/ResilioSync/Music/Rammstein  
╰─➤  ls -al
total 36
drwxrwxr-x  9 x x 4096 Dec 16 13:39 .
drwxrwxr-x 90 x x 4096 Dec 29 08:55 ..
drwxrwxr-x  3 x x 4096 Dec 15 15:54 1995-Herzeleid-FLAC
drwxrwxr-x  4 x x 4096 Dec 16 13:42 1997-Sehnsucht-JAP-FLAC
drwxrwxr-x  4 x x 4096 Dec 27 16:44 2001-Mutter-JAP-FLAC
drwxrwxr-x  6 x x 4096 Dec 16 13:46 2004-ReiseReise-JAP-FLAC
drwxrwxr-x  4 x x 4096 Dec 16 13:43 2005-Rosenrot-JAP-FLAC
drwxrwxr-x  2 x x 4096 Dec 15 15:53 2019-RAMMSTEIN-FLAC
drwxrwxr-x  2 x x 4096 Dec 15 15:53 2022-Zeit-FLAC
╭─x@titan ~/ResilioSync/Music/Rammstein  
╰─➤  rsync -av ./1995-Herzeleid-FLAC homedung:~/storage/music/Rammstein/.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ED25519 key sent by the remote host is
SHA256:/SfOPQhONMpesZglCv5/eM+W/PJCgu12QlyuLwpKOjY.
Please contact your system administrator.
Add correct host key in /home/x/.ssh/known_hosts to get rid of this message.
Offending ED25519 key in /home/x/.ssh/known_hosts:86
  remove with:
  ssh-keygen -f "/home/x/.ssh/known_hosts" -R "[REDACTED]:8022"
Password authentication is disabled to avoid man-in-the-middle attacks.
Keyboard-interactive authentication is disabled to avoid man-in-the-middle attacks.
X11 forwarding is disabled to avoid man-in-the-middle attacks.
UpdateHostkeys is disabled because the host key is not trusted.
sending incremental file list
1995-Herzeleid-FLAC/
1995-Herzeleid-FLAC/00-pregap.flac
1995-Herzeleid-FLAC/01-Wollt ihr das bett in flammen sehen.flac
1995-Herzeleid-FLAC/02-Der meister.flac
1995-Herzeleid-FLAC/03-Weisses fleisch.flac
1995-Herzeleid-FLAC/04-Asche zu asche.flac
1995-Herzeleid-FLAC/05-Seemann.flac
1995-Herzeleid-FLAC/06-Du riechst so gut.flac
1995-Herzeleid-FLAC/07-Das alte leid.flac
1995-Herzeleid-FLAC/08-Heirate mich.flac
1995-Herzeleid-FLAC/09-Herzeleid.flac
1995-Herzeleid-FLAC/10-Laichzeit.flac
1995-Herzeleid-FLAC/11-Rammstein.flac
1995-Herzeleid-FLAC/Rammstein - Herzeleid.cue
1995-Herzeleid-FLAC/Rammstein - Herzeleid.flac
1995-Herzeleid-FLAC/Rammstein - Herzeleid.log
1995-Herzeleid-FLAC/Covers/
1995-Herzeleid-FLAC/Covers/1.jpg
1995-Herzeleid-FLAC/Covers/2.jpg
1995-Herzeleid-FLAC/Covers/3.jpg
1995-Herzeleid-FLAC/Covers/4.jpg
1995-Herzeleid-FLAC/Covers/5.jpg
1995-Herzeleid-FLAC/Covers/6.jpg
1995-Herzeleid-FLAC/Covers/7.jpg
1995-Herzeleid-FLAC/Covers/8.jpg
1995-Herzeleid-FLAC/Covers/Back.jpg
1995-Herzeleid-FLAC/Covers/CD.jpg

sent 879,701,295 bytes  received 507 bytes  11,499,369.96 bytes/sec
total size is 879,484,810  speedup is 1.00

Edit: note - above is “push” to the phone from my Linux PC as source… I tried the reverse of this and got an error :

╭─u0_a416@localhost ~/storage/music/Rammstein
╰─➤  rsync -av titan:~/ResilioSync/Music/Rammstein/1995-Herzeleid-FLAC .                                         255 ↵
ssh: Could not resolve hostname titan: No address associated with hostname
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: unexplained error (code 255) at io.c(231) [Receiver=3.2.7]

Edit 2 : that was eventually fixed by me tweaking my ssh client config files in ~/.ssh/ - and had to use the IP address of the machine titan… Note - PULL “rsync” is MUCH MUCH slower than push!

This isn’t a showstopper for me - I prefer to use USB to transfer files anyway… So I won’t research that error further…

BTW - I ignore all those boring messages about a man in the middle attack :slight_smile: - I’m also lazy - 'cause the fix is right there in the output :

  remove with:
  ssh-keygen -f "/home/x/.ssh/known_hosts" -R "[REDACTED]:8022"

Then over on my phone in TermUX :

╭─u0_a416@localhost ~
╰─➤  cd storage/music/Rammstein
╭─u0_a416@localhost ~/storage/music/Rammstein
╰─➤  ls -al
total 12
drwxrwx--- 3 root everybody 4096 Dec 30 08:57 .
drwxrwx--- 4 root everybody 4096 Dec 16 15:46 ..
drwxrwx--- 3 root everybody 4096 Dec 15 15:54 1995-Herzeleid-FLAC
╭─u0_a416@localhost ~/storage/music/Rammstein
╰─➤  ls -al 1995-Herzeleid-FLAC
total 736496
drwxrwx--- 3 root everybody      4096 Dec 15 15:54  .
drwxrwx--- 3 root everybody      4096 Dec 30 08:57  ..
-rw-rw---- 1 root everybody     17501 Dec 15 15:44  00-pregap.flac
-rw-rw---- 1 root everybody  41562409 Dec 15 15:44 '01-Wollt ihr das bett in flammen sehen.flac'
-rw-rw---- 1 root everybody  32127508 Dec 15 15:44 '02-Der meister.flac'
-rw-rw---- 1 root everybody  27560000 Dec 15 15:44 '03-Weisses fleisch.flac'
-rw-rw---- 1 root everybody  30243405 Dec 15 15:44 '04-Asche zu asche.flac'
-rw-rw---- 1 root everybody  33481849 Dec 15 15:45  05-Seemann.flac
-rw-rw---- 1 root everybody  38316971 Dec 15 15:45 '06-Du riechst so gut.flac'
-rw-rw---- 1 root everybody  44436010 Dec 15 15:45 '07-Das alte leid.flac'
-rw-rw---- 1 root everybody  34834440 Dec 15 15:45 '08-Heirate mich.flac'
-rw-rw---- 1 root everybody  28471071 Dec 15 15:45  09-Herzeleid.flac
-rw-rw---- 1 root everybody  33566900 Dec 15 15:45  10-Laichzeit.flac
-rw-rw---- 1 root everybody  32708759 Dec 15 15:45  11-Rammstein.flac
drwxrwx--- 2 root everybody      4096 Dec 15 15:54  Covers
-rw-rw---- 1 root everybody      1128 Dec 15 15:44 'Rammstein - Herzeleid.cue'
-rw-rw---- 1 root everybody 376781078 Dec 15 15:44 'Rammstein - Herzeleid.flac'
-rw-rw---- 1 root everybody      2626 Dec 15 15:44 'Rammstein - Herzeleid.log'

And - I can use my main music player - Android app “Music Folder Player Full” (as opposed to the “free” version) to browse to that folder and play content from it - like Rammstein.

Mostly I don’t need to do that - because mostly I use a shell script that runs “adb-sync” to sync my main phone Music collection folders, with my ResilioSync/Music share on my computes…

Because my phone’s not rooted, I can’t use TermUX to do stuff directly on the SD-Card… So - those ~/storage folders in TermUX are on the phone’s internal storage…

You might also like to investigate using adb-sync :

And if you have any luck using the “WiFi” version “ADB Channel” - let us know - because I’ve had ZERO success with it - but that’s not a show stopper for me - 'cause I mostly have my phone USB C connector rigged up to my Linux computer when I’m at home, or my work MacBook when I’m at the office.

1 Like

@daniel.m.tripp:

Hi Dan, :wave:

thanks a lot for your detailed response. :heart:

Yes, that´s doable. No problems there.

O.K… I still have to do that. But I guess it could be achieved.

Thanks. I´ll try that.

I just remembered I used to employ the sftp command when transferring files from or to running instances of my virtual machines (e.g. Debian).
So as a first step I tried this command within termux as well. And indeed it worked. :+1:

With sftp rosika@192.168.8.100 (issued from within termux) I established a connection to Lubuntu and then could retrieve a text file from Lubuntu with
get [text-file]
I then exited the sftp connection (bye or just exit are fine for that matter) and then checked in termux with ll . And indeeed the respective text-file was there and I could read it with cat. :blush:

So that´s been successful so far. Nevertheless I´ll look into scp and rsync as well.

Ah, that´s good to know. Thanks, Dan.

I once tried to play an mp.3 file which came with the phone. It wouldn´t work.
If I remenber correctly there was a message trying to get me to do something with Google Play beforehand. I flatly refused. :angry:

I still could play the mp3 file from within termux

play [music-file].mp3

Thanks for the link. I will look it up.

BTW:

quite an impressive music collection you have there… :+1:

Thanks a lot for your help, Dan.
Many greetings and a healthy start into the New Year. :rocket:

Many greetings from Rosika :slightly_smiling_face:

2 Likes

I use KDE Connect for a bunch of things. I just replied to an MMS by typing a long reply on my PC and hitting reply. I clean pictures off my phone by sharing to my PC. It does lots of other tricks. I use wifi which was easy to set up.
I guess I missed the part where you couldn’t run both devices on one network. If your PC connects through a modem, hook up a wifi router you get at a garage sale for two bucks.