Skip to content

Instantly share code, notes, and snippets.

@dmd
Created June 30, 2020 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dmd/e6a269eb38ce90cf100f17ee905d2995 to your computer and use it in GitHub Desktop.
Save dmd/e6a269eb38ce90cf100f17ee905d2995 to your computer and use it in GitHub Desktop.
#!/usr/bin/expect
trap {
set rows [stty rows]
set cols [stty columns]
stty rows $rows columns $cols < $spawn_out(slave,name)
} WINCH
set dest [lindex $argv 0];
# are we already on vpn?
spawn host ogawa.mclean.harvard.edu
expect eof
catch wait result
if { [lindex $result 3] == 1 } {
spawn ssh -A -oStrictHostKeyChecking=no -oCheckHostIP=no -J dd328@ssh.partners.org $dest
set prompt ":|#|\\\$"
interact -o -nobuffer -re $prompt return
send "my password\r"
interact
} else {
spawn ssh $dest
interact
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment