Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Use Platypus to create apps from scripts Apps
I recently read a hint about enabling email over ssh. I've been trying to set that up on Mac OS X since I switched (from OS 9), but I always received an odd error, and it never worked, no matter how much research I did, and how many different options I tried. It worked for tunneling ftp, http, and all sorts of other protocols. It's a straight-forward setup:
ssh -CN -L 2025:mail.isp.com:25 -L 2110:mail.isp.com:110 \
 myshortname@localhost
Then set Mail.app to use localhost as the SMTP and POP3 servers, and set the ports to 2025 and 2110 respectively. Oh well, for some reason, now it works. Which lead me to try to discover a way of automating the task when my user account logs in.
  • I could make a /Library/StartupItem, but that would run even when my user wasn't logged in -- that's not what I want.
  • I could make an alias in my shell, then open up the Terminal and type the alias every time -- that's too much work.
  • I could create a shell script text file and name it mailtunnel.command and add it to my user account startup items. That's messy because it opens up the Terminal.app and leaves the window open.
  • I could have a contextual menu or open a special application that I could use to select a shell command that would trigger the command without Terminal.app opening. That's still too much work. I don't want to have to do anything.
Read the rest of the hint for my solution...

After some searching, I found a fantastic application called Platypus. From their website:
Platypus is a powerful developer tool for creating application wrappers around scripts, i.e. for creating MacOS X applications that execute a bundled script. Scripts can thus be run seamlessly from the graphical window environment, making elegant Mac OS X-native applications from scripts. Here are some of the features Platypus has to offer:
  • Supports shell scripts, Perl, Python, PHP, Ruby, Expect, Tcl, AppleScript
  • Supports arbitrary interpreter setting -- thus support for any script type
  • Executing scripts with root privileges via Apple's Authentication Framework
  • Drag and drop files, which are passed to the script as arguments
  • Graphical feedback of script execution: progress bar or text window with script output
  • Can create applications which run in the background
  • Graphical interface for bundling support files with script
  • Set own application icon or select from presets
Creating installers, maintenance applications, login items and droplets is very easy using Platypus.
So I created a simple shell script:
#!/bin/sh

##
# SSH Mail Tunnel Opener
# opens ssh tunnels for smtp (2025) and pop3 (2110)
##

/usr/bin/ssh -CN -L 2110:mail.isp.com:110 -L 2025:mail.isp.com:25 \
 myshortname@localhost
Then I used Platypus to create an application with no interface (it can even be a background app which will not show up in the dock -- which Platypus can handle for you), I pointed it to my script, and I had an application I could add to my user startup items with no user interface, no mess, and the process is completely automated.

I'm going to use this program to create all sorts of little apps for stuff I used to have to enter into the command line. Yes, I know I could have used a program like SSH Tunnel manager, but for some reason, I didn't want to go that route.
    •    
  • Currently 2.67 / 5
  You rated: 4 / 5 (3 votes cast)
 
[15,604 views]  

Use Platypus to create apps from scripts | 13 comments | Create New Account
Click here to return to the 'Use Platypus to create apps from scripts' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Use Platypus to create apps from scripts
Authored by: monickels on Nov 12, '04 11:42:06AM

How does it handle the password prompt for the SSH connection?



[ Reply to This | # ]
Use Platypus to create apps from scripts
Authored by: trece on Nov 12, '04 12:18:24PM

it doesn't... probably Tiger has setup a public key login, so there is no need for a password prompt at all [assuming he didn't assign a password to the key pair].

ssh first checks for public key atentication [sp?] and tries other login methods...the last one is a password prompt.

still im new to ssh...could be wrong...



[ Reply to This | # ]
creating a public key for ssh and other things
Authored by: nvdingo on Nov 12, '04 12:41:19PM

Doesn't have to be tiger.

Here is the short and simple for creating a public key

1. on your local computer, open a terminal
2. type `ssh-keygen -t rsa`
3. the following prompt comes up:
Generating public/private rsa key pair.
Enter file in which to save the key (/home/<youruserid>/.ssh/id_rsa):
4. accept the default (it's in your home directory)
5. leave passphrase field blank twice
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
6. you will get something similar to the following output
Your identification has been saved in /home/<youruserid>/.ssh/id_rsa.
Your public key has been saved in /home/<youruserid>/.ssh/id_rsa.pub.
The key fingerprint is:
a6:ca:aa:c7:fb:db:93:77:1d:da:07:c1:99:7c:3f:db <youruserid>@yourcomputer.com

7. This has created a directory, in your home directory named '.ssh'
8. `cd .ssh`
9. `cat *.pub`
This will print to the terminal the contents of your public key.
This is what you want to put on any remote server that you want passwordless login to.
10. copy the output
11. login to the remote server
12. if the .ssh dir does not exist in your home directory on the remote server, create it.
13. type the following:

echo '<use the paste command here>' >> authorized_keys

14. you should have pasted the previously copied contents in between the single quotes.
15. logout, and try logging back in. it should not ask you for a password.
16. if you have a newer system, you might need an authorized_keys2 file

In summary, for all systems that you want to login to , you copy the contents of ~/.ssh/id_rsa.pub into the authorized_keys file

the authorized_keys file can contain multiple keys, so that you can login to it from many different systems.

While you can copy the .pub file to many different systems, i recommend that you do NOT copy the private key (id_rsa) to any other system

on any system that you are going to login FROM, create a key, and copy the public key (.pub) to the systems you are going to login TO.

and yes i know you can do some of this in a more streamlined manner, but this explains exactly what is going on, and what goes where.



[ Reply to This | # ]
creating a public key for ssh and other things
Authored by: trece on Nov 12, '04 02:52:50PM

i meant Tiger the guy that posted the hint... not the OS. Sorry if that caused some kind of mixup...later.



[ Reply to This | # ]
Use Platypus to create apps from scripts
Authored by: Beernd on Nov 12, '04 12:30:36PM

One might use SSHKeyChain for this. It stores your secret key's password, and as an extra bonus it has the ability to easily dig secure tunnels for you.

By the way, are you sure your setup is secure? You connect to localhost via ssh, and then forward some ports to a remote machine. I wouldn't be surprised if forwarding would be insecure this way…
I would do something like the following:
ssh login@ssh-server.isp.com -L 10110:mail.isp.com:110
This way the connection to your isp's ssh-server is secure, and maybe the last bit from ssh-server.isp.com to mail.isp.com is not, but that's no problem.

Am I right? Anyone?

---
"Perhaps nothing is quite true, and not even that!"
Multatuli, Ideen 1



[ Reply to This | # ]
Use Platypus to create apps from scripts
Authored by: nvdingo on Nov 12, '04 12:44:06PM

no, he is not sshing into localhost.
he is sshing into the isp.
it is setup correctly.



[ Reply to This | # ]
Use Platypus to create apps from scripts
Authored by: nvdingo on Nov 12, '04 12:46:51PM

gack, scratch that.
you may be right.
not entirely sure that it is setup correctly.

he will find out if putting the public key on teh remote server in authorized_keys does NOT allow him passwordless login.
then it is definitely authenticating against the wrong ssh server



[ Reply to This | # ]
Use Platypus to create apps from scripts
Authored by: Beernd on Nov 12, '04 01:01:35PM

Yes, I'm afraid I was right: he is ssh'ing into localhost, building a secure tunnel from localhost to localhost and then an insecure tunnel from localhost to mail.isp.com, thus obtaining a false sense of security. It's just an awkward way of connecting insecurely to his isp's mail server. Any script kiddy could read his mail and steal his password…

---
"Perhaps nothing is quite true, and not even that!"
Multatuli, Ideen 1



[ Reply to This | # ]
SSHKeychain
Authored by: ssevenup on Nov 12, '04 02:18:38PM

Another vote for SSHKeychain, it's the best way to do this and invaluable for other reasons too. Having said that, Platypus (and Pashua) are very useful too. It's just the Rube Goldberg method in this case.

http://www.sshkeychain.org/

--MM

---
Mark Moorcroft
ELORET Corp. - NASA/Ames RC
Sys. Admin.



[ Reply to This | # ]
Use Platypus to create apps from scripts
Authored by: TigerKR on Nov 13, '04 02:53:51AM
Ok, time for the responses:

1. I do use password-less SSH 2-DSA keys (I use SSH Helper, for key generation and management, great app), all of my machines that have password-less keys are physically secure.

2. I screwed up in my explanation. My office box is on a LAN behind a separate firewall box, my mail server box is on a different LAN behind another separate firewall box (gotta love old blue and white G3 towers) and the two LANs are separated by the intarweb.

I actually tunnel from my office box through the remote firewall (where I have login access), straight to the mail server.

Office Workstation --> Firewall --> Intarweb --> Firewall --> Mail Server

Even though I'm a retard and screwed up the part about sshing, the point that I was trying to make, was that:

Platypus is a great solution for getting command line scripts or programs to run without any interface at user login (and it does so much more).

Please accept my sincere apologies for being a moron on the path to making my ultimate point.

[ Reply to This | # ]
Use Platypus to create apps from scripts
Authored by: nick on Nov 15, '04 08:48:10AM
you could as well use an login-hook to run shell-scripts at login (see www.bombich.com).

if you wanna have grafical feedback use ihook (umich.edu).

[ Reply to This | # ]
Use Platypus to create apps from scripts
Authored by: jeremyp on Nov 16, '04 12:40:23PM

What advantage does this give you?

The connection between sshd and your ISP's SMTP/POP3 server is in clear text. Why not just connect directly to them with Mail.app?



[ Reply to This | # ]
Use Platypus to create apps from scripts
Authored by: TigerKR on Nov 16, '04 08:44:03PM

Nick: I believe that login-hooks are user independent just like StartupItems, I wanted user non-independence

jeremyp: I would like to invite you to read my comment from Nov 13 '04



[ Reply to This | # ]