Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

Curious as to how I can enable the sshd to start on startup solely using terminal. The GUI is great and everything but it doesn't go well with my bash scripts.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

The short answer on how to enable sshd from the terminal is doing this:

sudo systemsetup -setremotelogin on

The long answer on how to execute daemons or scripts on startup is a bit longer. There are two ways (that I know of) to do this:

  • The first one is through Startup Items, which are executed at the final phase of bootup, these are deprecated and shouldn't be used unless you need compatibility with MacOSX v10.3 or earlier. You can take a look at how to do it this way in here.

  • The second one is launchd, a replacement for init and rc (among others). This is the recommended way and it's a bit trickier than just putting a script on a folder like in Linux. There are several ways to launch daemons, the preferred way it to launch them on demand (so they will be ready to launch but you won't see them in a ps for example, unless you are using them). The explanation is a bit lengthly and the list of options is long, you can take a look at the documentation here. You can take a look in /Library/LaunchAgents for examples, if you have Chrome installed, there is a file in there for the Google Software Updater called com.google.keystone.agent.plist, that runs at load time, you can start there.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.