Accessing the Moto E2 via SSH requires specifying the host IP, port (8022 instead of default 22), identity file, and disabling strict host key checking (the phone's IP can change). The full command looks like:
ssh -i ~/.ssh/id_moto -p 8022 -o StrictHostKeyChecking=no 192.168.1.14Typing this dozens of times a day during development is not sustainable. Additionally, the phone has two access modes: USB (via ADB port forwarding to localhost) and WiFi (via direct IP on the local network). Switching between them requires different commands.
First, assign a static IP to the phone on your router's DHCP settings. This ensures the phone always gets the same IP address on your local network.
Create or edit ~/.ssh/config on your development machine:
# ~/.ssh/config — PocketClaw phone access
# WiFi access (phone on local network)
Host moto
HostName 192.168.1.14
Port 8022
User root
IdentityFile ~/.ssh/id_moto
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
# USB access (via ADB port forwarding)
Host moto-usb
HostName localhost
Port 8022
User root
IdentityFile ~/.ssh/id_moto
StrictHostKeyChecking no
UserKnownHostsFile /dev/nullFor USB access, set up ADB port forwarding first:
# Forward local port 8022 to phone port 8022
adb forward tcp:8022 tcp:8022
# Also forward gateway port for API access
adb forward tcp:9000 tcp:9000Now connect with a single command:
# WiFi access:
ssh moto
# USB access:
ssh moto-usb
# SCP files to phone:
scp file.js moto:/data/data/com.termux/files/usr/tmp/# Test WiFi connection:
ssh moto "echo 'WiFi OK'"
# Expected: WiFi OK
# Test USB connection (after adb forward):
ssh moto-usb "echo 'USB OK'"
# Expected: USB OK
# Verify port forwarding for gateway:
curl -s http://localhost:9000/api/status | head -c 50
# Expected: JSON response$PATH in double-quoted SSH commands expands to the Windows PATH. Always use single quotes for remote commands: ssh moto 'echo $PATH'StrictHostKeyChecking no and /dev/null for known_hosts is acceptable here because it's a trusted local device. Do not use this pattern for production serversadb shell "run-as com.termux sh -c 'export LD_LIBRARY_PATH=/data/data/com.termux/files/usr/lib; /data/data/com.termux/files/usr/bin/sshd 2>&1'"| Metric | Before | After |
|---|---|---|
| SSH command length | ~80 chars | 9 chars (ssh moto) |
| Access modes | Manual switch | Config aliases |
| Key management | Per-command flag | Automatic |