Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Enthusiast Zone > Networking > establishing a ssh tunnel via applescript

establishing a ssh tunnel via applescript
Thread Tools
moep
Senior User
Join Date: Nov 2003
Status: Offline
Reply With Quote
Jun 12, 2008, 07:39 AM
 
I wasn't sure where to post this, if the admins think it's more appropriate to have this in the Developer Forum... feel free to move it.

What I'm trying to accomplish is a simple applescript that automatically sets up my ssh-tunnel when I need it.

That involves two simple steps: Setting the Network-Location (set up for SOCKS on localhost) and executing an ssh script.

What I've come up with seems to work but the last command never finishes executing. Both Apple's Script Editor and Textmate end up beachballing forever after using the Applescript.

Here's the script:
---
do shell script "scselect 'ssh tunnel'"
do shell script "ssh [email protected] -f -N -p 1234 -D 9999"
---
authentication is done via PKA.
( Last edited by moep; Jun 12, 2008 at 07:41 AM. Reason: why does the [code] tag ignore line breaks?)
"The road to success is dotted with the most tempting parking spaces."
     
turtle777
Clinically Insane
Join Date: Jun 2001
Location: planning a comeback !
Status: Offline
Reply With Quote
Jun 18, 2008, 12:43 AM
 
Ok, so I can't really help you with this, since I have stopped using tunneled SSH.

I'm using HamachiX. It's a free VPN solution that allows "tunneling" of any network activity.

-t
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Jun 18, 2008, 01:17 AM
 
Can I ask why you are bothering with Applescript, and not just creating a double-clickable shell script?
     
jimsmithkka
Fresh-Faced Recruit
Join Date: Jul 2008
Status: Offline
Reply With Quote
Jul 8, 2008, 05:07 PM
 
Hello, i am also trying to setup a ssh from an apple script

My Reason for this is i need to have remote connectivity for RD to remote hosts behind various different networks, my plan is to use ARD and SSH port forwarding from the clients to allow me to RD to their machnes.

My issue is i do not want my clients to have Terminal access, which is where the apple script comes in.

My current issue is getting the AS to no lock up after the connection is established, i am using P/P keys to handle the authentication.

My apple script so far asks for a command to run, with a default answer of a script that contains the correct ssh command and flags.

Right now it creates the tunnel and locks up until i kill the tunnel via CLI with the kill command.

I guess the short version of my question is:
How do i form an apple script to run a bash script in the back ground, while also opening a dialog of some kind that allows me to kill the process in the script.

PS: i know basic OO programming and can Bash/awk script, but have zero experience with apple script
     
besson3c
Clinically Insane
Join Date: Mar 2001
Location: yes
Status: Offline
Reply With Quote
Jul 8, 2008, 05:32 PM
 
I really don't think that Applescript is your best solution here, it seems to me like a rather backwards approach.

I would work on simply disallowing anybody but admins to open the Terminal. You should be able to do this simply by changing the permissions on this app, or moving it to a folder that is only accessible by admins.
     
   
 
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Top
Privacy Policy
All times are GMT -4. The time now is 06:00 AM.
All contents of these forums © 1995-2017 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.8 © 2000-2017, Jelsoft Enterprises Ltd.,