Connection via USB between Debian and Android smartphone

New to Debian (Or Linux in general)? Ask your questions here!

Connection via USB between Debian and Android smartphone

Postby de_se_77 » 2017-11-26 11:13

Hi,

I think should be a very simple operation i.e. connecting my smartphone via usb cable with PC running Debian, but it seems it is not. Simply in order to transfer general files such pdf documents or any exstension files.
I tried KDE connect: the devices simply don't see each other.
Then in some forums someone suggested to pay attention to the firewall. I did not install any firewall so I wonder if there is one default installed: it seems to be, but the default setting foresees all ports open.

I would like to transfer general files (not only .jpg or images that are managed by Gnview(?) or something like that).

Anyone can suggest me the proper tool to succeed in doing this?

I also tried ftp tools but also in this case no possibility to see the devices.

Thanks in advance
de_se_77
 
Posts: 7
Joined: 2017-11-25 15:48

Re: Connection via USB between Debian and Android smartphone

Postby L_V » 2017-11-26 11:19

In KDE, you simply need kio-mtp & libmtp9.
Normally, udev should detect your smartphone. if correctly configured to MTP protocol (and not usb).

libmtp9: Media Transfer Protocol (MTP) library
L_V
 
Posts: 717
Joined: 2007-03-19 09:04

Re: Connection via USB between Debian and Android smartphone

Postby debiman » 2017-11-26 19:18

^ well technically they do connect via USB, but then use the mtp protocol (instead of some filesystem).

de_se_77 wrote:the devices simply don't see each other.

this would suggest a more primitive problem, like a broken cable etc.

does the phone start to charge when you plug it in? does it show any sort of icon that indicates a connection?

you can verify your satement by entering
Code: Select all
dmesg -w
then plug in your device.
if you see new output, it means debian 'sees' the device.
if you're unsure, you can post the output here.
User avatar
debiman
 
Posts: 1633
Joined: 2013-03-12 07:18

Re: Connection via USB between Debian and Android smartphone

Postby makh » 2017-11-26 23:55

Hi

I assume you need to install:
Code: Select all
mtp-tools


along with the applications mentioned by: L_V

Then either those applications or the default file manager of KDE can auto detect. It seems you are using KDE.
HP Probook 440 G2: Arch, Debian Stable
Server: none
Past: Debian, Centos, Ubuntu, Opensuse
GUI: Openbox, Cinnamon
Chroot: Debian, Ubuntu, Fedora
VM: Devuan

Employing the best:
Arabic
Debian
Homeopathic

For new: Try Linux Mint
User avatar
makh
 
Posts: 568
Joined: 2011-10-09 09:16

Re: Connection via USB between Debian and Android smartphone

Postby L_V » 2017-11-27 10:23

makh wrote:I assume you need to install mtp-tools

No / not for KDE.
The key poiints are:
1 - to be detected, the smartphone should not be configured to "charge only", but to MTP (or file transfer / depending on the UI)
2 - the smartphone should be correctly detected by running:
Code: Select all
udevadm monitor --environment --udev

If not, a specific udev rule should be created ( in case of completely unknown brand).
L_V
 
Posts: 717
Joined: 2007-03-19 09:04

Re: Connection via USB between Debian and Android smartphone

Postby de_se_77 » 2017-12-03 11:12

L_V wrote:In KDE, you simply need kio-mtp & libmtp9.
Normally, udev should detect your smartphone. if correctly configured to MTP protocol (and not usb).

libmtp9: Media Transfer Protocol (MTP) library


Thank you for the suggestion L_V. I tried to install those libraries kio-mtp & libmtp9 (actually they were not present on the system) but the situation is the same as before.

The files browser sees the smartphone (main memory and SD one added, i.e. 2 memory devices) but when I try to paste some files on smartphone memories, the paste commend is in grey color i.e. the action is not allowed.

I forgot: still Kde connect (both smartphon and PC side) doesn't see anything. The files browser sees but cannot perform any paste action on phone.
de_se_77
 
Posts: 7
Joined: 2017-11-25 15:48

Re: Connection via USB between Debian and Android smartphone

Postby de_se_77 » 2017-12-03 11:17

makh wrote:Hi

I assume you need to install:
Code: Select all
mtp-tools


along with the applications mentioned by: L_V

Then either those applications or the default file manager of KDE can auto detect. It seems you are using KDE.


Ok thanks. If I understood well, this seems to be a NON KDE tool: anyway I tried but nothing changed.
I'm using KDE
de_se_77
 
Posts: 7
Joined: 2017-11-25 15:48

Re: Connection via USB between Debian and Android smartphone

Postby de_se_77 » 2017-12-03 11:22

debiman wrote:^ well technically they do connect via USB, but then use the mtp protocol (instead of some filesystem).

de_se_77 wrote:the devices simply don't see each other.

this would suggest a more primitive problem, like a broken cable etc.

does the phone start to charge when you plug it in? does it show any sort of icon that indicates a connection?

you can verify your satement by entering
Code: Select all
dmesg -w
then plug in your device.
if you see new output, it means debian 'sees' the device.
if you're unsure, you can post the output here.


Thanks debiman. I was not precise: as just replied to other users, the files browser can see the smartphone, but cannot perform any paste action on its memories. So I suppose there is a problem on the Android side and I have to find out what needs to be set on the phone in order to allow the paste action.

My phone is a Samsung Galaxy S2 Plus (GT-I9105P).
Last edited by de_se_77 on 2017-12-03 19:37, edited 1 time in total.
de_se_77
 
Posts: 7
Joined: 2017-11-25 15:48

Re: Connection via USB between Debian and Android smartphone

Postby de_se_77 » 2017-12-03 11:33

L_V wrote:
makh wrote:I assume you need to install mtp-tools

No / not for KDE.
The key poiints are:
1 - to be detected, the smartphone should not be configured to "charge only", but to MTP (or file transfer / depending on the UI)
2 - the smartphone should be correctly detected by running:
Code: Select all
udevadm monitor --environment --udev

If not, a specific udev rule should be created ( in case of completely unknown brand).


Thanks again L_V.
On Android side of the phone (Samsung Galaxy S2 Plus, GT-I9105P), I can select two options:
1. multimedia device ...
2. camera (PTP): it allows file transfer on PC of pictures and any other file type not supporting MTP

Tried both: the paste action on phone via PC browser is not allowed.
de_se_77
 
Posts: 7
Joined: 2017-11-25 15:48

Re: Connection via USB between Debian and Android smartphone

Postby L_V » 2017-12-03 20:01

de_se_77 wrote:Tried both: the paste action on phone via PC browser is not allowed.
Can you at least read ?
If you cannot write, it's a right problem (likely sdcard protection).
Internal/external memories/sdcards do not have the same permissions.
L_V
 
Posts: 717
Joined: 2007-03-19 09:04

Re: Connection via USB between Debian and Android smartphone

Postby de_se_77 » 2017-12-04 17:03

L_V wrote:
de_se_77 wrote:Tried both: the paste action on phone via PC browser is not allowed.
Can you at least read ?
If you cannot write, it's a right problem (likely sdcard protection).
Internal/external memories/sdcards do not have the same permissions.


Yes, I' ve just tried: I can copy files from phone and past on PC.

Maybe there is a level protection that doesn't allow you to do normal and simple actions. I should try to become SU and see if something change. But I think it can only be done through line command.

Ok SOLVED.

I (tried) to change user becoming SU (root and password): the system told me I could not log in as root (why?) and so I logged with the normal user. Then I opened the shell becoming SU; then typed:

lsblk
lsusb

After that I pasted some files, using normal files browser, on phone memory without any problem.

I think the above commands were irrelevant (the experts can say that.. :-) and maybe what's important is logging in having the phone plugged on usb port: somehow the system recognize it from the beginning and let you do what you want.
Last edited by de_se_77 on 2017-12-04 21:59, edited 1 time in total.
de_se_77
 
Posts: 7
Joined: 2017-11-25 15:48

Re: Connection via USB between Debian and Android smartphone

Postby L_V » 2017-12-04 21:55

It's the smartphone policy which can prevent the copy in MTP mode.
I use LineageOS and not android / cannot tell you more for your specific smartphone which is even not pure android.
L_V
 
Posts: 717
Joined: 2007-03-19 09:04

Re: Connection via USB between Debian and Android smartphone

Postby de_se_77 » 2017-12-07 17:31

L_V wrote:It's the smartphone policy which can prevent the copy in MTP mode.
I use LineageOS and not android / cannot tell you more for your specific smartphone which is even not pure android.


Thanks ones more L_V.
I'll try if can work for my phone: actually I was searching for something like that :-)
de_se_77
 
Posts: 7
Joined: 2017-11-25 15:48

Re: Connection via USB between Debian and Android smartphone

Postby michapma » 2017-12-08 12:51

de_se_77 wrote:I (tried) to change user becoming SU (root and password): the system told me I could not log in as root (why?)


Because it would be highly insecure to run an X session (session with graphical desktop environment) as root.

It sounds to me like you could get around this issue by temporarily enabling USB debugging before connecting to the machine.
https://www.kingoapp.com/root-tutorials ... ndroid.htm

Be sure to heed the warning:
USB Debugging should only be enabled when you need it. Leaving it enabled all the time is kind of a security risk for that this mode grants you high-level access to your device. Say if you connect your Android phone to a USB charging port in a public location, the port could use the USB access to your phone to access data on your phone or install malware. This could happen when and only when USB debugging mode is enabled.
User avatar
michapma
 
Posts: 539
Joined: 2008-05-04 20:49
Location: Prague

Re: Connection via USB between Debian and Android smartphone

Postby None1975 » 2017-12-08 17:34

For me, connection via usb between Debian (i use Debian 9.2+Ratpoison) and Android smartphone (i use Samsung Galaxy S7, Android version 7.0), works like a charm. After minimal installation via network installer, after installing xorg packages, i installed PCmanFM file manager. Apt installed all required dependencies. No additional configuration required.
OS: Debian 9.3 / WM: i3wm
Debian Wiki | DontBreakDebian, i3wm
User avatar
None1975
 
Posts: 230
Joined: 2015-11-29 18:23
Location: Lithuania

Next

Return to Beginners Questions

Who is online

Users browsing this forum: No registered users and 5 guests

fashionable