termux ssh
install openssh
powershell
Get-WindowsCapability -Online | Where-Object Name -like 'OpenSSH*'
Name : OpenSSH.Client~~~~0.0.1.0
State : NotPresent
Name : OpenSSH.Server~~~~0.0.1.0
State : NotPresent
Add-WindowsCapability -Online -Name OpenSSH.Client~~~~0.0.1.0
Add-WindowsCapability -Online -Name OpenSSH.Server~~~~0.0.1.0
src
https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse?tabs=powershell&pivots=windows-10
https://learn.microsoft.com/en-us/windows-server/administration/openssh/openssh_install_firstuse?tabs=powershell&pivots=windows-10
install openssh
pkg update && pkg install openssh -y
set termux user password
passwd
start sshd i.e ssh daemon
sshd
get local ip address
ifconfig
wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.18.97 netmask 255.255.255.0 broadcast 192.168.18.255 unspec 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 txqueuelen 3000 (UNSPEC)
connect, default port is 8022 in termux sshd
ssh -p 8022 192.168.18.97
Get username using cmd for proot distro
id
uid=10446(u0_a446) gid=10446(u0_a446) groups=10446(u0_a446),3003(inet),9997(everybody),20446(u0_a446_cache),50446(all_a446) context=u:r:untrusted_app_27:s0:c190,c257,c512,c768
whoami
u0_a446
ssh -p 8022 [email protected]
x11 forwarding [ use vnc for speed]
termux path = /data/data/com.termux/files/usr/etc/
nano ../usr/etc/ssh/ssh_config
X11Forwarding yes
X11DisplayOffset 10
XAuthLocation /usr/bin/xauth
ssh -p 8022 192.168.18.97 -X
-Y for trusted forwarding
need xming or other client
vnc setup
cat <<'EOF' > /data/data/com.termux/files/usr/bin/startdesktop-kde
#!/bin/sh
LD_PRELOAD=/system/lib64/libskcodec.so
pulseaudio --start --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" --exit-idle-time=-1
export XDG_RUNTIME_DIR=${TMPDIR}
kill -9 $(pgrep -f "termux.x11") 2>/dev/null
kill -9 $(pgrep -f "x11") 2>/dev/nul
termux-x11 :0 >/dev/null &
sleep 3
export PULSE_SERVER=127.0.0.1
export XDG_RUNTIME_DIR=${TMPDIR}
DISPLAY=:0 dbus-launch --exit-with-session startplasma-x11
EOF
# Setting up VNC
mkdir -p ~/.vnc
# Create VNC password file (default 12345678)
printf "12345678" | vncpasswd -f > ~/.vnc/passwd
chmod 600 ~/.vnc/passwd
echo '#!/data/data/com.termux/files/usr/bin/sh
export PULSE_SERVER=127.0.0.1
export DISPLAY=:1
dbus-launch --exit-with-session startplasma-x11' >> ~/.vnc/xstartup
chmod +x ~/.vnc/xstartup
echo '#!/data/data/com.termux/files/usr/bin/sh
LD_PRELOAD=/system/lib64/libskcodec.so
pulseaudio --start --load="module-native-protocol-tcp auth-ip-acl=127.0.0.1 auth-anonymous=1" --exit-idle-time=-1
vncserver :1
echo "VNC server address: 127.0.0.1:5901 Password: 12345678"' >> /data/data/com.termux/files/usr/bin/startvnc
chmod +x /data/data/com.termux/files/usr/bin/startvnc
echo '#!/data/data/com.termux/files/usr/bin/sh
vncserver -kill :1' >> /data/data/com.termux/files/usr/bin/stopvnc
chmod +x /data/data/com.termux/files/usr/bin/stopvnc
echo '#!/data/data/com.termux/files/usr/bin/sh
stopvnc
startvnc' >> /data/data/com.termux/files/usr/bin/restartvnc
chmod +x /data/data/com.termux/files/usr/bin/restartvnc
echo 'To start termux-x11 session use startdesktop-kde command'
echo 'To start VNC use startvnc command'
echo 'To stop VNC use stopvnc command'
echo 'To restart VNC use restartvnc command'
apt clean
startvnc
ssh over usb
adb forward tcp:8022 tcp:8022
The first instance of tcp:8022 is the local port you want to bind the remote port to. The second one is the port from your Android device. Because Termux' SSHD runs on port 8022 by default, this is what you want.
ssh localhost -p 8022
src: https://glow.li/posts/access-termux-via-usb/