-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a wrapper for mosh over pagekite
Inspired by https://gist.github.com/tribut/5285883, found on mobile-shell/mosh#285.
- Loading branch information
Francois Marier
committed
Aug 25, 2018
1 parent
c7fd6a3
commit 35568b6
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
# | ||
# spasmosh: wrapper around the mosh command for hosts which use single packet authentication | ||
# | ||
# You can protect the ssh server using fwknop, but the mosh UDP port must be forwarded to | ||
# the machine that is running the ssh server you're trying to connect to. | ||
# | ||
# External dependencies: | ||
# - perl | ||
# | ||
# NOTE: for the fwknop command to work, you must first configure it in ~/.fwknoprc | ||
|
||
PORT="9000" # must be forwarded on the gateway | ||
|
||
# Extract the hostname from an scp destination | ||
hostname="$(echo "${!#}" | perl -pe 's/^([^@]*\@)?(.*)$/$2/')" | ||
remoteip="$(dig +short A "$hostname" | tail -1)" | ||
|
||
export http_proxy="" | ||
|
||
# shellcheck disable=SC2048,SC2086 | ||
fwknop -n "$hostname" || exit 1 | ||
|
||
key="$(ssh -4 -t "$hostname" mosh-server new -p \"$PORT\" | grep '^MOSH' | cut -s -d' ' -f4 | tr -d '\r')" | ||
MOSH_KEY="$key" exec mosh-client "$remoteip" "$PORT" |