r/termux • u/ResponsibilityBig343 • 7d ago
Question How do I SSH without a LAN?
I use my mobile as a hotspot to share internet with my two laptops. I want to enable rsync on my mobile and laptops. The issue is I'm unable to ssh into the mobile. I have checked that sshd is enabled and by default using 8022 port along with passwordauth allowed. I'm simply timing out of ssh. I think this has something to do with my network topology as its not a LAN. Because when I had devices on wifi I was able to ssh easily.
4
Upvotes
11
u/DutchOfBurdock 7d ago
When you enable hotspot, you're creating a LAN.
Your phone will choose an IP in this range for itself (the gateway) and another range for connected devices.
On your laptops, look for the default gateway IP (it wont be .1) and point SSH and co to this IP. If you're running a VPN on your phone, allow the client to enable local communication.
1
u/aparna-velvet 6d ago
You can simply create a wrapper using free Cloudflare tunnel
2
u/smarthoushai 7d ago
Three different failures give you that same timeout, and "sshd is enabled" only rules out one of them.
Check what the phone is actually listening on:
ss -ltn | grep 8022. You want0.0.0.0:8022. If it shows127.0.0.1:8022nothing arriving on the hotspot interface can reach it, and if the line is missing entirely sshd died with the session it was started from - runtermux-wake-lockand start it undertermux-servicesso it survives. Then confirm the address the laptops should use, which is the gateway of their own route and not the phone's cellular IP: on a laptopip route | grep defaultprintsvia 192.168.43.1on a Wi-Fi hotspot,192.168.42.1on USB tethering. The phone can hold three or four IPv4s at once,ip -4 addr | grep -E 'ap0|swlan0|wlan1|rndis0'shows which.The one that matches "simply timing out" is the third: from a laptop run
nc -vz 192.168.43.1 8022. "Connection refused" means you did reach the phone and nothing is listening; a hang means the packets are dropped before they ever hit sshd, which on some OEM builds is the tethering firewall filtering inbound on the AP interface. There is no reliable fix for that one on a locked ROM.So I'd flip the direction. rsync does not care which end initiates it: run sshd on the laptop,
pkg install openssh rsyncon the phone, and pull from the phone over the tether as an ordinary client -rsync -avz laptop:/home/you/stuff ~/stuff. Inbound connections to the phone stop being part of the problem.1
u/seffparker 7d ago
timeout mostly happens when the port is blocked or not reachable.
Confirm the sshd works in phone using a loopback connection attempt. You may also initiate the rsync from either side. Try running the sshd on laptop
1
u/Upper_Parsley_9118 3d ago
U can use tailscale on ur laptop and phone and avoids such gateway confusions
0
u/Grand-Firefighter257 7d ago
This is the simplest way to get you from point A to point B the fastest.
Done! I would recommend using the tailscale website to rename your devices. Simply prepend "ts-" to the device name. So if the computers actual name is "server", rename it to "ts-server" in https://console.tailscale.com/admin/machines. Not doing this step can cause issues connecting to devices directly instead of through tailscale, bc by default it will always try to use the tailscale network unless the names are different.
Tailscale is a P2P VPN software. Your data never goes through a cloud server.
The hotspot wont work because the hotspot acts like a special router. All devices are treated like guests, just like in a public guest wifi network. They wont be allowed to talk to each other.
Installing a P2P VPN is the fastest and easiest solution