AppleScripting SSH Tunnel...

Hi:

I’m trying to set up an SSH tunnel to another computer using ‘do shell script’ in an AppleScript.

I’ve written another script that runs the SSH command through an open Terminal window (as ‘do script’), and all works fine, but I’d like to bypass Terminal if possible.

The command I’m trying to use is similar to this:

do shell script “ssh -v -l user_name no_name.com -p 22 -L 5900:localhost:5900”

I get an error from this, though at the moment can’t recall exactly what it is/was… and the remote computer is offline at the moment, so I can’t reproduce the error. If I remember correctly it said something to the effect that the wrong shell was being used.

I’m pretty green when it comes to any shell scripting, so help would be appreciated.

Extra points for figuring out how to auto-enter the private key passphrase from the script.

Is it even possible?

Thanks.

Peter B.


Edit: Extry, extry points for the shell code to do a port scan… incorporated in an AppleScript.


For what it’s worth…

I was able to assemble a GUI script that combines a preliminary port scan (using Network Utility), the creation of an SSH tunnel with auto passphrase entry (using a third party utility ‘SSH Agent’), and the start of a VNC session (using the standalone RealVNC viewer for Mac).

It’s a kludge, but the Terminal is avoided altogether.

If anyone is interested, I’ll post details.

Peter B.


This one works for me Peter

tell application "Terminal" to do script "ssh -L 55900:127.0.0.1:5900 shortUserName@" & currIP & return
do shell script "open -a 'Chicken of the VNC'" -- or your preferred client
-- requires that you type your password in the terminal window.

I should mention that after screwing around with that for a while, I bought a pair of licenses for ShareTool – a much easier (and reliable) way.

Adam, thanks…

Though I described it as a ‘kludge’ (and it is), my workaround is indeed working very nicely for my secret and wicked needs… which involve remote VNC access of my Dad’s Windows machine.

I’m on a ridiculously slow dialup connection at my end, and have found that RealVNC is a (little) faster than COTVNC… and a quick look at Share Tool suggests it’s only suited for Mac to Mac.

So…

New to all this, but still amazed I can bring up my Dad’s desktop from some 1800 miles away… and run a virus or spyware scan or do basic maintenance or clean up for him on his Dell running XP.

Nifty stuff.

Peter B.