AppleScript to telnet to a remote host via a bastion
Tuesday, July 29th, 2008AppleScript to SSH to my bastion host, then telnet to a remote host. Works best if you have RSA/DSA public-key authentication and an ssh-agent configured. Could probably use some better error handling.
set myBastion to "public.example.com"
tell application "iTerm"
activate
display dialog "Enter hostname:" default answer "none"
set theResult to result
set theHost to text returned of theResult
set aTerm to (current terminal)
if (count of terminal) = 0 then
set aTerm to (make new terminal)
end if
tell aTerm
set aSession to (make new session at end of sessions)
tell aSession
set name to theHost
exec command "ssh -t " & myBastion & " telnet " & theHost
end tell
snd tell
end tell