Linux Format

Talking to Android

-

I struggle to copy files to recent Android devices. They have ditched the ability to mount the phone’s storage as a USB device and insist we use MTP. I have tried with MTP but have found it slow and unreliable. So I wondered if there is an easy way to copy files over Wi-Fi. By easy I mean something that doesn’t involve the intricacie­s and incantatio­ns associated with the likes of Samba. Phil Wheeler I share your frustratio­n with MTP, sometimes it works well, other times it just stops when it’s least convenient. Mounting as USB storage was always a bad idea, because it meant the storage had to be unmounted on the phone first, which meant that programs would stop working. You cannot have two systems accessing the same mounted filesystem without managing to break something.

There are a number of options if you want to copy over wireless. If you want to keep directorie­s in sync between your desktop and phone, such as music or photo collection­s, Syncthing ( https://syncthing.net) is a good choice [ seeTutoria­ls,p78, LXF203]. For ‘manual’ file copying, SSH is easy to use, especially if you already have it set up on your computer. Some Android file managers support SSH or SFTP connection­s (SFTP is the file transfer part of SSH). I use ES File Explorer and you just give it the name of the computer along with the username and password, and it shows the contents of your hard drive on the mobile device. You will, of course, need the SSH server installed on your computer, and many distros only install the client by default, so install the openssh-server or similarly named package.

Alternativ­ely, you can do things the other way round, by installing SSHHelper from the Play Store. This is an SSH server that supports scp , sftp and rsync commands. It runs on port 2222 rather than the more standard port 22, because root access is needed to open ports below 1024. This means you have to specify the port using -p with ssh and -P with scp or sftp . Now you can copy your files to and from the device using scp or rsync , or you can view the contents of the device in most graphical file managers by pointing them to sftp://IP-ADDRESS:2222.

You can set a password in SSHHelper’s settings screen (you need to restart the server after doing this) but the username is irrelevant, so you can leave it out and let SSH default to

using your current username. SSHHelper has one more trick up its sleeve, you can have it mount your device with sshfs. You may need to install sshfs on your computer first, then run: $ sshfs -p 2222 IP-ADDRESS:/storage/ emulated/0 ~/android

You may need to change the path to the internal storage, the above works for recent Nexus devices, but you must make sure the mount point you use exists and is empty. Now you have your device mounted on the computer, just like in the old USB storage days. When you are done, unmount it with one of: $ sudo umount ~/android $ fusermount -u ~/android

Newspapers in English

Newspapers from Australia