I installed Tapp from Installer.app and come up with a couple scripts to turn on/off sshd, so that you can only have it running when you need to get into the phone remotely.
I know UIctl starts and stops all services but messing around in there can brick the phone, requiring a restore, and if you're one of those ppl who does not like to password-lock your phone, this is for you. This allows you to one-tap start or stop sshd using launchctl.
StartSSH
Quote:
#!/bin/bash
rm -f .tmp
launchctl load -w /Library/LaunchDaemons/com.openssh.sshd.plist > .tmp 2>&1
t=`cat .tmp`
if [ -z "$t" ]; then
echo "sshd started successfully."
else
echo "sshd could not be started:"
cat .tmp
fi
|
StopSSH
Quote:
#!/bin/bash
rm -f .tmp
launchctl unload -w /Library/LaunchDaemons/com.openssh.sshd.plist > .tmp 2>&1
t=`cat .tmp`
if [ -z "$t" ]; then
echo "sshd successfully stopped."
else
echo "sshd could not be stopped:"
cat .tmp
fi
|
The reason I redirect everything into .tmp is (and this took me a while to figure out) it seems the ppl who wrote launchctl did not make use of return codes

.. so you can't just do if launchctl ....; then do blabla; else blabla; fi because launchctl returns true no matter what happens.
Fortunately, launchctl doesn't tell you jack **** if all went well, so if you have any output at all it basically had some kind of error and apparently Tapp either redirects stderr to /dev/null, or just straight up absorbs it.. i haven't seen the source... but yeah.. so unless you redirect staerr to a file and cat it out, you won't see it in tapp's output.
so there you go. you can do this too with Apache or anything else..
I tried to make it toggle but I haven't been able to find a reliable way to detect if it's running.. i tried doing a ps aux | grep sshd | grep -v grep which I know for a fact I've used in other linux/darwin applications but for some reason it didn't work here.
but this may be better tho, this way you can't think it's turned off, and then click it "oops it was on, well now i just turned it off" type thing.
enjoy and feel free to make it better
edit: oh, i made a dir /tapp to put these in, and then you have to chmod 755 them to make them executable, then just put the stuff in .tapp, like so:
Quote:
/tapp/StartSSH
/tapp/StopSSH
|
I recommend setting the term to xterm before using vi coz it seems for some reason vi likes to crash with a bus error when hitting backspace if you are using the default TERM value .. or just use nano/pico.