Skip to content

Instantly share code, notes, and snippets.

@Neo-Oli
Created August 28, 2017 09:00
Show Gist options
  • Save Neo-Oli/d55db97631b2e6da2ea179e15ebf915a to your computer and use it in GitHub Desktop.
Save Neo-Oli/d55db97631b2e6da2ea179e15ebf915a to your computer and use it in GitHub Desktop.
My ssh setup
export device=droid
export PATH=~/bin:${PATH}
export BROWSER=~/bin/browser
export device=work
#!/bin/sh
dev=$(cat ~/.externaldevice)
if [ -z "$dev" ];then
dev=droid
fi
$HOME/bin/$(basename $0)-$dev $@
sleep 3
#!/bin/sh
ssh adbstinkpad DISPLAY=:0 noglob "firefox \"$@\""
echo "opening on thinkpad"
sleep 5
#!/bin/sh
ssh adbwork "tmux new-window \"/cygdrive/c/Program\ Files\ \(x86\)/Mozilla\ Firefox/firefox.exe \\\"$@\\\";sleep 10\""
# _ __ _
# ___ ___| |__ ___ ___ _ __ / _(_) __ _
#/ __/ __| '_ \ _____ / __/ _ \| '_ \| |_| |/ _` |
#\__ \__ \ | | |_____| (_| (_) | | | | _| | (_| |
#|___/___/_| |_| \___\___/|_| |_|_| |_|\__, |
# |___/
Host adb
Hostname localhost
Port 8022
# Hide warnings closed ports are contacted
LogLevel QUIET
#adbthinkpad
RemoteForward 10022 localhost:22
#adbwork
RemoteForward 11022 localhost:22
#adbpc
RemoteForward 12022 localhost:22
#http
LocalForward 8080 localhost:8080
#https
LocalForward 8443 localhost:8443
#privoxy
#LocalForward 8118 localhost:8118
#tor
#LocalForward 9050 localhost:9050
#raspi camera
LocalForward 13080 localhost:13080
#aria2-rpc
LocalForward 6800 localhost:6800
#mpd stream
LocalForward 8100 localhost:8100
Host adbstinkpad
Hostname localhost
Port 10022
User glow
Host adbwork
Hostname localhost
Port 11022
User oliver.schmidhauser
#!/bin/bash
setup(){
#ssh
adb forward tcp:8022 tcp:8022
#privoxy and tor with adb instead of ssh because of https://github.com/termux/termux-packages/issues/465
adb forward tcp:9050 tcp:9050
adb forward tcp:8118 tcp:8118
if [ "$device" == "stinkpad" ] || [ "$device" == "media" ];then
mkdir -p ~/drive
sshfs adb:/storage/54E2-F956/Android/data/com.termux/files/drive ~/drive
fi
if [ "$device" == "work" ] || [ "$device" == "olipc" ];then
# we're running tmux here because windows has no concept of DISPLAY and it just needs to be run from a non-service process
tmux ls||tmux new-session -d
fi
}
connect(){
echo "Connecting ..."
setup
ssh adb "~/bin/ext $device"
ssh adb -t "tmux ls||tmux new-session -d;tmux attach"
echo "Disconnected"
}
main(){
if [ "$(basename $0)" == "autoconnect" ]; then :
while true; do :
connect
sleep 1
done
else :
connect $0
fi
}
main
#!/bin/bash
if [[ -z "$1" ]];then
dev=droid
else
dev=$1
fi
echo -en "$dev" >~/.externaldevice
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment