LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   LinuxQuestions.org Member Success Stories (https://www.linuxquestions.org/questions/linuxquestions-org-member-success-stories-23/)
-   -   android - linux over ssh for beginners (https://www.linuxquestions.org/questions/linuxquestions-org-member-success-stories-23/android-linux-over-ssh-for-beginners-4175673121/)

zpimp 04-13-2020 07:18 AM

android - linux over ssh for beginners
 
i like open source open standards, cause they dont change
i only run linux on computers and android on phone
so the logical option would be ssh,rsync,sshfs
they get better, they dont change, they never die
im using this in home network, dont leave stuff open on other networks

you probably know what ssh and rsync are
sshfs is a remote filesystem built ontop sftp (wich runs over ssh)
sshfs is something like nfs(unix), smb(windows), afp(apple)
sshfs is almost the same speed as all the above if optimized
the difference is sshfs is easier to setup since it runs on ssh
you only have to start the ssh service/server, and youre set (server side)

on linux-linux its pretty simple, start the service, find server ip, on the client run the command to mount or rsync

setup android ssh server
but since android is not linux its not that simple
first we need a terminal, so we install termux from playstore
run
pkg install openssh - to install ssh client/server
termux-setup-storage - to make some of our storage available to termux/ssh
passwd - to enter and confirm password (since well use this to auth)
sshd - to start the ssh server on your android device
after yo try all this remember to kill the sshd process
killall sshd

now on your linux computer connect to the android server
ssh 192.168.0.101 -p 8022
that is the ip of my android phone, and 8022 is the port which ssh runs on termux instead of default port 22
if you get key verification failed, its probably cause of dhcp, on computer you have to
rm /home/user/.ssh/known_hosts, only do this if you know it wont f*ck your shit up

now we can mount the phone storage
mkdir /home/user/phone
sshfs -p 8022 192.168.0.101:/storage/emulated/0 /home/user/phone
after youre done, close apps accessing the phone and
umount /home/user/phone

you can ofcource rsync locally (after mount), or rsync over ssh
time rsync -av --info=progress2 -e "ssh -p 8022" 192.168.0.101:/storage/emulated/0/Download/ /home/user/phone-backup/
as you can see we dont need username on android ssh server

now the interesting part
accessing sshfs target from android client
since android is not linux we cant mount sshfs like on linux but it is accessible
and i searched for apps on playstore to do this
i found
file manager +
fx file manager
mixplorer (not on google play)
solid explorer
smart file manager
x-plore

search for the option network/sftp
i like totalcmd very much on windows and android but its sftp plugin doesent actually mount sshfs, its just sftp (it has to download file first)

from all of the above
fx file manage
solid explorer
file manager +
seem to be able to access android sftp/sshfs (at username you put whatever you want)
the others seem to want the termux username, and some dont work even with that

too bad we cant mount sshfs directly in termux, but until then you should know there is at least a gui/closed source way
you can use this to watch movies from your linux box, on your phone cause you can skip forward, or whatever
after yo try all this remember to kill the sshd process on android
killall sshd
hope this was helpful


All times are GMT -5. The time now is 09:00 AM.