(See also the Termux Wiki)
# Install AutoSSH, OpenSSH and FTP server and tmux
pkg upgrade
pkg install autossh openssh openssh-sftp-server tmux
# Set password for initial connection
passwd
# Find local IP address of device
ifconfig | grep -o 192[0-9\.]*
# (Re-)start SSH server
pkill sshd; sshd
# Set IP address of device as environment variable
# SERVER=...
# Create public key (optional)
# ssh-keygen -t rsa -b 2048
# Copy public key to device
ssh-copy-id -p8022 -i ~/.ssh/id_rsa user@$SERVER
# Switch to public key authentication
ssh user@$SERVER -p8022 'c=$PREFIX/etc/ssh/sshd_config;sed -rie "s/^(PasswordAuthentication)\s.*/\1 no/g" $c;pkill sshd;sshd'
# Connect to the device using public key
ssh user@$SERVER -p8022
# Create/attach to tmux session
tmux new-session -A -s webserver
# Create a simple website
mkdir -p www && nano www/index.html
# Install python
pkg install python3
# Start local webserver (preview with xdg-open http://$SERVER:8080; to foreground using fg)
$(cd www && python3 -m http.server 8080) &
# Create public key for the server (optional)
# ssh-keygen -t rsa -b 2048
# Set requested subdomain (optional)
# SUBDOMAIN=...
# Create public tunnel to website (alternatively use localhost.run)
autossh -M 0 -R $SUBDOMAIN:80:localhost:8080 serveo.net
# Detach from tmux session using Ctrl+b d
TODO: Nextcloud