Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

neoserver

macrumors 6502
Original poster
Apr 24, 2003
335
0
I'm trying to write a program that needs to use SSH.

This is how it is supposed to work:

The University wireless network requires you to sign in to a particular host using ssh before you are allowed to access the internet. (They're using authpf on OpenBSD if that helps.)

I want to write a program that does this for me, while using a NSStatusItem to indicate status.

Here is the problem: How should I interact with SSH? I don't need to interact with the session, I just need to set up a connection and launch a shell. Once that shell is running, the only thing I need to do is be able to disconnect.

I tried using NSTask to interact with the ssh app, but I ran into problems trying to pass a password to it.

I then tried to wrap libssh (http://0xbadc0de.be/wiki/libssh:libssh) into a Obj-C class. However, it seems to be a mess. According to everything the library is telling me, I should have a shell, but I can't confirm that using another ssh session and checking who's logged in. (The App's connection doesn't appear.)

Any ideas?

If any of this is unclear, I'll try my best to clarify it.

Thanks :)
 

neoserver

macrumors 6502
Original poster
Apr 24, 2003
335
0
Yes, I do go to the UofA.

I saw that app before, but I want to build an App that sits up in the menu bar for quick access.

I'm nearly there, I just need to write some code to respond to the keepalive messages that the gateway sends. (It disconnects me after about 5 mins if I don't)
 

matoch

macrumors member
Oct 12, 2006
78
0
Sounds like you've made some good progress. When you get it finished I'd like to see the results.

James
 

neoserver

macrumors 6502
Original poster
Apr 24, 2003
335
0
Yes, I had made good progress however I hit a rather large snag.

I was unable to implement the keepalive system necessary to keep the SSH connection to the gateway open. At least that was with the libraries I was using.

It looks as though I'm going to have to implement my own SSH framework using cocoa sockets. That way I can set it up so that I can grab notifications when packets arrive and process them. I can avoid having to poll for packets and try and work around the other library's parsing system.

A simple project very quickly became much more complex. We'll see how I progress with this. If anyone has any ideas of how to implement this in another way using libssh2 (libssh2.org), let me know. (The SSH server is sending global requests and is expecting a reply. If it doesn't get one, then it disconnects)
 

Eraserhead

macrumors G4
Nov 3, 2005
10,434
12,250
UK
Why don't you see if you can use the University of Alberta original application code to do it? And then just add your menubar applet to that.
 

neoserver

macrumors 6502
Original poster
Apr 24, 2003
335
0
Why don't you see if you can use the University of Alberta original application code to do it? And then just add your menubar applet to that.

They used RealBasic to create the application. I don't have RealBasic and I was looking to use Cocoa and obj-c for this project. Unless theres a way to link in RealBasic code to a Cocoa app perhaps?

I'll talk to them, perhaps the source code would be good as a reference to build a Cocoa version against.
 

matoch

macrumors member
Oct 12, 2006
78
0
It just occurred to me that you could take a look at the source code for ssh keychain. I use it mainly to manage my ssh keys but it is also able to create an ssh connection to set up ssh tunnels. It may or may not have some useful code that could help you figure out how to set up the ssh connections.

http://svn.sshkeychain.org/repos/tags/0.8.2/

James
 

Eraserhead

macrumors G4
Nov 3, 2005
10,434
12,250
UK
They used RealBasic to create the application. I don't have RealBasic and I was looking to use Cocoa and obj-c for this project. Unless theres a way to link in RealBasic code to a Cocoa app perhaps?

I'll talk to them, perhaps the source code would be good as a reference to build a Cocoa version against.

Maybe you could recreate the normal interface in Cocoa as well and they may well want to replace their version of the application with yours, (especially if the code is maintainable).
 

neoserver

macrumors 6502
Original poster
Apr 24, 2003
335
0
I'm still waiting for a reply from the developer, I probably won't get one until Tuesday at the earliest due to it being Thanksgiving here.

I'll take a look at the SSH keychain code and see if I can't pull something out of it.


Thanks all!
 

neoserver

macrumors 6502
Original poster
Apr 24, 2003
335
0
I've done some simple analysis (using Activity Monitor), and it turns out that their existing application just launches SSH as a subprocess.

I tried doing this once before with an NSTask, but I had issues with setting up the pipes to communicate with ssh.

I'm going to try doing it that way again and I'll keep you posted on how it turns out.
 

neoserver

macrumors 6502
Original poster
Apr 24, 2003
335
0
I heard back from the author of the application. It turns out that AICT (the campus IT dept) is going to be rolling out updates to the wireless networks on campus to eliminate the need for the SSH authentication. They're moving to a RADIUS based system.

So it turns out that my application, for what I need it for, is going to be obsolete in a month or two, and I don't think I'm going to continue to persue it.

Thanks all for your suggestions!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.